リンクをクリックすると、テストが殺されます
-
27-09-2019 - |
質問
次のコマンド
selenium.click("link=Identify Awards");
ポップアップを開きますが、テストは継続しません
私は配置しました
selenium.waitForPopUp(null, "1500");
selenium.windowFocus();
selenium.selectPopUp("Search -- Webpage Dialog");
クリックコマンドの後に使用できないと、リンクはJava関数に移動します。
このコマンドがリンク、ボタン、チェックボックス、またはラジオボタンをクリックすることを知っています。クリックアクションが新しいページをロードする場合(通常はリンクがするように)、電話をかけてくださいwaitForPageToLoad
。私はそうだと思います waitforPageToLoad
ポップアップロードを登録していません
アップデート
次のことを試しました
selenium.fireEvent("link=Identify Awards", "onClick");
そして、以下を手に入れました
ポップアップは別のドメインにあります。これが原因になる可能性がありますか?
Exception in thread "Main Thread" org.openqa.selenium.ie.UnexpectedJavascriptExecutionException: Cannot execute script
System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1', java.version: '1.5.0_12'
Driver info: driver.version: ie
at org.openqa.selenium.ie.ErrorHandler.verifyErrorCode(ErrorHandler.java:70)
at org.openqa.selenium.ie.InternetExplorerDriver.executeScript(InternetExplorerDriver.java:205)
at org.openqa.selenium.internal.seleniumemulation.JavascriptLibrary.callEmbeddedSelenium(JavascriptLibrary.java:47)
at org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:35)
at org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:1)
at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:33)
at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:47)
at org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:277)
at org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:209)
at com.thoughtworks.selenium.DefaultSelenium.fireEvent(DefaultSelenium.java:201)
解決
使用する selenium.selectWindow
ポップアップを選択してから使用します selenium.selectWindow(null)
ベース]ウィンドウを選択します。あなたはそれがどの種類のポップアップであるかを説明しませんでした。確認ボックス、フレーム、またはモデルダイアログ、または単に別のウィンドウです。セレンはこれらすべての治療が異なります
他のヒント
特にSeleniumのClick関数でJavaScriptをトリガーする場合、場合によっては、コマンドが適切にコマンドの要素を呼び出さない場合があり、これが遭遇する問題である可能性があることがわかりました。
もしそうなら、以下を使用して、オンクリックイベントを明示的に発射してみてください。
selenium.fire_event("link=Identify Awards", "onClick")
それが役立つことを願っています。
所属していません StackOverflow