このエラーの原因であると思われる別の質問を作成しました: Selenium Firefox Driver は、親にオーバーフローがあるときにモーダルが表示されないと見なすのはなぜですか?
Selenium バージョン 2.33.0
Firefox ドライバー
エラーの原因となるコード:
System.Threading.Thread.Sleep(5000);
var dimentions = driver.Manage().Window.Size;
var field = driver.FindElement(By.Id("addEmployees-password")); //displayed is true
field.Click(); //works fine
var element = driver.FindElement(By.Id(buttonName)); //displayed is false
element.Click(); //errors out
クリックしようとしているボタン:
<div id="addEmployees" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addEmployeesLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Add Employee</h3>
</div>
<div class="modal-body">
<p class="alert alert-info">
<input name="addEmployees-username" id="addEmployees-username" />
<input name="addEmployees-password" id="addEmployees-password" type="password" />
<input name="addEmployees-employee" id="addEmployees-employee" />
</p>
</div>
<div class="modal-footer">
<button name="addEmployees-add" id="addEmployees-add" type="button" class="btn" data-ng-click="submit()">Add</button>
</div>
</div>
- 呼び出しを
FindElements
then に変更すると、1 つの要素が取得されるため、ページには他に何もありません。 FindElement
ボタンの直前に発生するフィールドに I がある場合addEmployees-employee
、たとえばaddEmployees-employee
はdisplayed
- ブラウザ自体では問題なく表示されます。実際にボタンをクリックするだけで目的の動作が実行されますが、Web ドライバは表示された要素を考慮することを拒否します。
一方のフィールドは表示されていると見なされ、もう一方のフィールドは表示されていないのはどうしてですか?
右下に追加ボタンがあるモーダル、他のすべての要素が表示されます = true
ウィンドウ サイズは 1200x645 perdriver.Manage().Window.Size;
要素の位置は: 800x355y per 要素の寸法 driver.FindElement(By.Id(buttonName)).Location
は: 51x30 per driver.FindElement(By.Id(buttonName)).Size
password 要素の位置は: 552x233y per driver.FindElement(By.Id("addEmployees-password")).Size