0

I am having a problem on handling the pop up windows in robot framework.

The process I want to automate is :

When the button is clicked, the popup window appears. When the link from that popup window is clicked, the popup window is closed automatically and go back to the main page.

While the popup window appears, the main page is disabled, and it can be enabled only when the link from the pop up window is clicked.

The problem I have here is that I cannot go back to the main page after clicking the link from the popup window. I got the following error.

20140604 16:04:24.160 : FAIL : NoSuchWindowException: Message: u'Unable to get browser'

I hope you guys can help me solve this problem.

Thank you!

user3477373
  • 345
  • 1
  • 3
  • 12

3 Answers3

0

I had the same issue and here is the method to resolve the issue

 String window = driver.getWindowHandle();  

Now click the button to invoke the popup and give some wait time

and then switch to ur new window with the below code

driver.switchTo().window("your new window name");
//perform your action in the new window and then

To get back control over your main page after the popup closes, use the below code

 driver.switchTo().window(window);

This will help you activate the main window and continue your action there.

Let me know if this helpw

Sriram
  • 449
  • 3
  • 8
  • 15
  • Thanks for ur help but I am using python not java. Any advice on python? – user3477373 Jun 05 '14 at 00:09
  • @user3477373 : Probabaly this might help you. https://gist.github.com/1047207/1ac30c0f22e5080ffa9786b01e3a69e8dc624649#moving-between-windows-and-frames or http://stackoverflow.com/questions/13113954/selenium-webdriver-using-switch-to-windows-and-printing-the-title-doesnt-prin – Sriram Jun 05 '14 at 10:47
0

No idea in Python but in Java you can use below code after pop opened to solve your problem:

Object[] parentHandle = myDriver.getWindowHandles().toArray();
myDriver.switchTo().window((String) parentHandle[0]);

In the first line of code parentHandle is the number of current windows in Array form. And in second line of code I am switching to the first window, for second window you can use 1.

If still have problem or you need something else, please suggest.

Abhishek Yadav
  • 459
  • 5
  • 16
0

I have seen this issue and found that there is a recovery period where Selenium does not work correctly for a short time after closing a window. Try using a fixed delay or poll with Wait Until Keyword Succeeds combined with a keyword from Selenium2Library.

ombre42
  • 2,344
  • 15
  • 21