Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of new window by application does not increase the number of Driver window handles #792

Closed
nbarrett opened this issue May 15, 2017 · 2 comments

Comments

@nbarrett
Copy link
Contributor

nbarrett commented May 15, 2017

There is an area of the the system under test where it creates a new browser window. I need to be able to switch to this and perform the necessary automation task on that, as well as switch back again afterwards. However I'm having trouble getting the browser instance to see more than the current window. So if I run this code before and after the step that creates the new window:

WebDriver driver = BrowseTheWeb.as(actor).getDriver();
System.out.println("current window title: " + driver.getTitle());
System.out.println("current window handles: " + driver.getWindowHandles());

I get this:

current window title: IBM InfoSphere Master Data Management Collaboration Server v11.3.0
current window handles: [01847c55-529c-4837-a3f6-3417819e61fa]

(navigation logic now creates window)

current window title: IBM InfoSphere Master Data Management Collaboration Server v11.3.0
current window handles: [01847c55-529c-4837-a3f6-3417819e61fa]

How do I convince the driver that there is a new window please? I'm at 1.2.5-SNAPSHOT currently and browser is IE11.

@nbarrett
Copy link
Contributor Author

nbarrett commented May 24, 2017

btw, this problem was not due to a timing issue - I could put a breakpoint on the code and leave it there for any amount of time (e.g. after I saw the new browser window appear) and the number of handles still stayed at 1. Is this something that we have no control over or is there some Serenity code that manages this please @wakaleo?

@kusumat
Copy link

kusumat commented Jul 12, 2021

I Could see only 1 Window in my sauce labs test and the below snippet could get more than one handle.

Does Sauce labs support multiple browsers with serenity?

WebDriver driver = getDriver(); String parent = driver.getWindowHandle(); Set<String> s = driver.getWindowHandles(); log.info("window handles "+s.size()); Iterator<String> i = s.iterator(); while(i.hasNext()){ String current = i.next(); if(!parent.equals(current)){ driver.switchTo().window(current); boolean exists = driver.findElements($(PayPalPage.PAYPAL_LOGO)).size() != 0; if(exists){ log.info("Method executed successfully"); } else { log.info("Method execution failed"); } } }

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants