2010-10-20 122 views
1

嗨,基本上我試圖切換到一個彈出窗口,然後按下該彈出窗口上的一個 按鈕,但從somereaon我越來越erros。Selenium 2窗口切換:Java

這裏是網頁

http://i42.photobucket.com/albums/e326/limpep/example.png

的例子,這裏是我的代碼

Errers是我得到

Exception in thread "AWT-EventQueue-0" org.openqa.selenium.NoSuchElementException: Unable to find element by id using "Accept Address" (7) 
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_21' 
Driver info: driver.version: ie 
    at org.openqa.selenium.ie.ErrorHandler.verifyErrorCode(ErrorHandler.java:38) 
    at org.openqa.selenium.ie.Finder.handleErrorCode(Finder.java:252) 
    at org.openqa.selenium.ie.Finder.findElementById(Finder.java:126) 
    at org.openqa.selenium.By$1.findElement(By.java:66) 
    at org.openqa.selenium.ie.Finder.findElement(Finder.java:240) 
    at org.openqa.selenium.ie.InternetExplorerDriver.findElement(InternetExplorerDriver.java:297) 
    at com.capscanWebServers.CRMTesting$2.actionPerformed(CRMTesting.java:112) 
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) 
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) 
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source) 
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) 
    at java.awt.Component.processMouseEvent(Unknown Source) 
    at javax.swing.JComponent.processMouseEvent(Unknown Source) 
    at java.awt.Component.processEvent(Unknown Source) 
    at java.awt.Container.processEvent(Unknown Source) 
    at java.awt.Component.dispatchEventImpl(Unknown Source) 
    at java.awt.Container.dispatchEventImpl(Unknown Source) 
    at java.awt.Component.dispatchEvent(Unknown Source) 
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
    at java.awt.Container.dispatchEventImpl(Unknown Source) 
    at java.awt.Window.dispatchEventImpl(Unknown Source) 
    at java.awt.Component.dispatchEvent(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 

親切的問候

+0

什麼錯誤你越來越多了? 「我得到的錯誤」嘗試其他按鈕名稱,如接受地址我仍然得到同樣的錯誤信息 – AutomatedTester 2010-10-20 15:02:32

回答

3

首先,您可能沒有切換到正確的窗口。您正在迭代所有窗口並切換到可能是您主窗口的第一個窗口。

如果由window.createPopup()創建的彈出窗口,那麼你將無法切換到它 - 這樣的窗口不受硒2.支持有在實施它的一些進展 - 見http://code.google.com/p/selenium/issues/detail?id=27

+0

感謝anwser時並沒有解釋什麼出了錯 – 2010-10-21 15:56:45

+0

嗯,我正在使用一個對話框,並有在那裏找到很多硒替代品 – 2010-10-22 12:00:45

+0

對話框是什麼意思?它是JavaScript alert()嗎?你可以發佈一塊html嗎? – 2010-10-22 17:59:59

1

我注意到你正在搜索的id是「ButtonCancle」。那裏有拼寫錯誤。是否有可能找到「ButtonCancel」?

+0

NOP我會進一步調查 – 2010-10-21 08:15:53

相關問題