1

Hi basically I am trying to switch to a popup window then press a button on that popup window but from somereaon I am getting erros.

Here is an example of the webpage

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

and here is my code

 for (String handle : driver.getWindowHandles()) { driver.switchTo().window(handle); } WebElement clicksa = driver.findElement(By.id("ButtonCancle")); clicksa.sendKeys(Keys.ENTER); driver.switchTo().defaultContent(); 

Errers that i am getting

 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) 

Kind Regards

1
  • whats the error you are getting? "I am getting errors" doesn't explain what's gone wrong Commented Oct 20, 2010 at 15:02

2 Answers 2

3

First of all, you are probably not switching to the correct window. You are iterating all windows and switching to the first one which could be your main window.

If the pop-up window is created by window.createPopup() then you will not be able to switch to it - such windows are not supported by Selenium 2. There's some progress in implementing it - see http://code.google.com/p/selenium/issues/detail?id=27

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the anwser i will investigate further
Well I am using a dialog box, and there arnt very many selenium alternatives out there
What do you mean by dialog box? Is it JavaScript alert()? Can you post piece of html?
well i have named the the dialogbox to form1 but i still recieving an error, when doing driver.switchTo().frame("form1") or even driver.switchTo().window("form1")
It seems that we have to wait when support of popups, alerts and modal dialogs will be implemented
1

I notice that the id you're searching for is "ButtonCancle". There's a misspelling there. Is it possible that you should be looking for "ButtonCancel"?

1 Comment

nop when trying another button name e.g Accept Address i still get the same error message

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.