入力タグに何も入力せずにOKボタンを押すと、入力タグに「入力してください」といったメッセージを動的に表示します
この画面を記録するとき、「入力してください」メッセージを表示している間にスクリーンショットを記録するようにタイミングをとります
このタイミングは、個々によって違うので動作しながら調整します
2014年8月28日木曜日
IE11の場合
IEでテストを行う場合、IE使用に条件がある
https://code.google.com/p/selenium/wiki/InternetExplorerDriver のRequired Configurationを見ると
IE11でテストを行う場合、
インターネットオプションのセキュリティの保護モードを無効にする必要があります
無効にしないとエラーになります
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)...
他のバージョンにも条件がありますが、未確認なのでRequired Configurationを参照してください
確認したら投稿します
詳しくは、https://code.google.com/p/selenium/wiki/InternetExplorerDriver のRequired Configurationを参照してください
https://code.google.com/p/selenium/wiki/InternetExplorerDriver のRequired Configurationを見ると
IE11でテストを行う場合、
インターネットオプションのセキュリティの保護モードを無効にする必要があります
無効にしないとエラーになります
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)...
他のバージョンにも条件がありますが、未確認なのでRequired Configurationを参照してください
確認したら投稿します
詳しくは、https://code.google.com/p/selenium/wiki/InternetExplorerDriver のRequired Configurationを参照してください
時々css指定できない
SeleniumIDEの右クリックで指定した css指定のlocator を変換したJavaコードで実行すると、時々、locator を認識できずエラーになる
こんなときは xpath指定でやってみる
これまでのところ、この対応でOK - FireFox, IE, Chrome
SeleniumIDE
waitForText css=div.formpad > table > tbody > tr > td タグ名
変換コード
for (int second = 0;; second++) {
こんなときは xpath指定でやってみる
これまでのところ、この対応でOK - FireFox, IE, Chrome
SeleniumIDE
waitForText css=div.formpad > table > tbody > tr > td タグ名
変換コード
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if ("タグ名".equals(selenium.getText("css=div.formpad > table > tbody > tr > td"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
css指定でエラーになるので
selenium.getText("xpath=//div[@class='formpad']//table//tbody//tr//td")
これはOK
なぜ、この要素だけ?と思うのだが、理由はわからない
css指定でエラーになるので
selenium.getText("xpath=//div[@class='formpad']//table//tbody//tr//td")
これはOK
なぜ、この要素だけ?と思うのだが、理由はわからない
ラベル:
Selenium,
マルチブラウザ対応,
時々css指定できない
waitFor系でエラーと決める場合は時間かかる
SeleniumコマンドのwaitFor系のJavaコードはエラーと決めるまで時間が掛かるようになっている
例えば
SeleniumIDEで
waitForText id=dialog-caption タグの管理
のJavaコードは
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if ("タグの管理".equals(selenium.getText("id=dialog-caption"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
と変換しているのでエラーと決めるまで時間かかる
ブラウザの実行とプログラムの実行のスピードに差があるので、for文にしてThread.sleep(1000); で、要素がページに表示されるのを待っているのだと思う
例えば
SeleniumIDEで
waitForText id=dialog-caption タグの管理
のJavaコードは
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if ("タグの管理".equals(selenium.getText("id=dialog-caption"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
と変換しているのでエラーと決めるまで時間かかる
ラベル:
Selenium,
waitForText,
マルチブラウザ対応
ダイアログのまだ表示してない要素をクリックする
ダイアログボックスに表示している項目を編集・削除を行いたいけれどフォーカスが当たっていないときのこと
FireFox、IE、Chrome でのこと
例えば、こんなとき
(項目の緑は文字色・背景色)
SeleniumIDEで作成したとき、
click css=a[name="delete"] > div.ui-act-inner > span.ui-act-label
これだけで削除できた
But!
Javaソースに変換して実行するとエラーになってしまった
Javaソースコード
selenium.click("css=a[name=\"delete\"] > div.ui-act-inner > span.ui-act-label");
ここでエラー発生
com.thoughtworks.selenium.SeleniumException: Element is not currently visible and so may not be interacted with ...
フォーカスが当たっていない為にエラーなので
selenium.click("css=div.el-label");
でフォーカス当てて
selenium.click("css=a[name=\"delete\"] > div.ui-act-inner > span.ui-act-label");
を実行してOK
FireFox、IE、Chrome でのこと
例えば、こんなとき
(項目の緑は文字色・背景色)
SeleniumIDEで作成したとき、
click css=a[name="delete"] > div.ui-act-inner > span.ui-act-label
これだけで削除できた
But!
Javaソースに変換して実行するとエラーになってしまった
Javaソースコード
selenium.click("css=a[name=\"delete\"] > div.ui-act-inner > span.ui-act-label");
com.thoughtworks.selenium.SeleniumException: Element is not currently visible and so may not be interacted with ...
フォーカスが当たっていない為にエラーなので
selenium.click("css=div.el-label");
でフォーカス当てて
selenium.click("css=a[name=\"delete\"] > div.ui-act-inner > span.ui-act-label");
を実行してOK
登録:
投稿 (Atom)