以下命令

selenium.click("link=Identify Awards");

打开弹出窗口,但是测试不会继续

我已经放了

selenium.waitForPopUp(null, "1500");
selenium.windowFocus();
selenium.selectPopUp("Search -- Webpage Dialog");

单击命令无用后,链接是a to to to 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) 选择基本窗口。您没有描述它是哪种弹出窗口。是确认框,框架或模型对话框或另一个窗口。硒在所有这些方面有所不同

其他提示

我发现,在某些情况下,当触发JavaScript特别是Selenium的点击函数时,并未正确调用元素onClick命令,这可能是您遇到的问题。

如果是这样,请尝试使用以下内容明确启动OnClick事件:

selenium.fire_event("link=Identify Awards", "onClick")

希望有帮助。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top