1

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.

  1. WebDriverTeste (open browser - Main)
  2. LoginElements (get the web element)
  3. LoginAcitions (execute clicks or every command)
  4. PageElements (get the web element)
  5. PageActions (execute clicks or every command)
  6. Constants (my users, url and passwords)
  7. 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)  }

driver.switchTo().window(PageActions.backToParentBrowser(driver));

But didn´t work it :(

Errors:

[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.

1

I solved it with:

created a var on my main class like this:

public class ChromeTest {

    **public static String parentWindow;**

    public static void main(String[] args) throws Exception {

And inside my main :

parentWindow= driver.getWindowHandle();

And just put the switchTo in the same moment that the window close automatically

driver.switchTo().window(ChromeTest.parentWindow);

The console keep showing the msg "[81.322][SEVERE]: Unable to receive message from renderer"

The method backToParentBrowser was deleted.

But now it works :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.