MachinePublishers / jBrowserDriver

A programmable, embeddable web browser driver compatible with the Selenium WebDriver spec -- headless, WebKit-based, pure Java
Other
809 stars 143 forks source link

Javascript opened windows won't close when calling close(). #195

Open Bbbrinks opened 7 years ago

Bbbrinks commented 7 years ago

I have some javascript code that opens a window waits for a redirect in that window and then closes that window. (This is to do some OAuth2 authentication with angular).

var popUp = $window.open(authUrl(), 'OAuthWindow', 'width=auto,height=auto');
//Do some stuff
popUp.close();

After this code has run calling webDriver.getWindowHandles() returns 2 window handles.

Also running in non-headless mode I can see both windows still even after popUp.close() has been called.

I think this might be causing some issues. Afterwards I can no longer fill form fields by calling sendKeys, this might be because it's using the wrong window handle.

Bbbrinks commented 7 years ago

Confirmed that this causes issues with filling form fields.

A work around is to explicitly call webDriver.switchTo().window("0") //or the correct window handle.