How to handle a window which automatically closes and back to parent window

Hi, I’m new here.

ChromeDriver Version 2.27

The case, my aplication have duble authentication (depending where the user want to access).

– First I execute the login and do some clicks, after that I click on the BTN that needs another login. Another window open (I mean, window *is not a pop up or browser alert) so the user needs to login again. When the user login the window close automatically and the driver lose itself.

I’m working with 7 classes.

WebDriverTeste (open browser – Main),

LoginElements (get the web element),

LoginAcitions (execute clicks or every command),

PageElements (get the web element),

PageActions, (execute clicks or every command),

Constants (my users, url and passwords)

SendMail (just a class who send mails)

So on PageActions I created a public method

 public static String backToParentBrowser(WebDriver driver) { String parentWindow= driver.getWindowHandle(); return parentWindow; } 

To get the first window (after open the other) and on LoginAcitions I call this method after this :

 try { for (String winHandle : driver.getWindowHandles()) { driver.switchTo().window(winHandle); } } catch (Exception e) { } 
{     (my code with Second Login)  }

But it didn´t work 🙁

Erros: [80.825][SEVERE]: Unable to receive message from renderer Exception in thread “main” org.openqa.selenium.NoSuchWindowException: no such window: target window already closed

Anyone can help me? Thanks a lot.

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.