2010-11-22 112 views
0

以下命令點擊鏈接殺死測試

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) 

回答

1

使用selenium.selectWindow選擇彈出窗口,然後使用selenium.selectWindow(null)選擇基本窗口。你沒有描述它是哪種類型的彈出窗口。是一個確認框或框架或模型對話框或僅僅是另一個窗口。硒在所有這些治療方法不同

1

我發現,在觸發特別是硒的點擊功能不調用JavaScript的元素時,某些場合適當的onclick命令,這可能是你遇到的問題。

如果是這樣嘗試使用以下明確觸發onClick事件:

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

希望有所幫助。

+0

感謝您的建議redrah – user515867 2010-11-22 14:07:37

+0

剛發現打開的彈出窗口是模態對話框 – user515867 2010-11-23 08:50:29