I'm trying to switch between windows and put an accountant to find out if the Selenium found the second window , but does not find it , note that he sees only 01 window , which is the Father window.
how do I find It the second window and switch to It?
I use: selenium-server-standalone-2.48.2 + Eclipse + Java 1.8
I tried this:
//Get all window handles
Set<String> allHandles = driver.getWindowHandles();
//count the handles Here count is=2
System.out.println("Count of windows:"+allHandles.size());
//Get current handle or default handle
String currentWindowHandle = allHandles.iterator().next();
System.out.println("currentWindow Handle"+currentWindowHandle);
//Remove first/default Handle
allHandles.remove(allHandles.iterator().next());
//get the last Window Handle
String lastHandle = allHandles.iterator().next();
System.out.println("last window handle"+lastHandle);
//switch to second/last window, because we know there are only two windows 1-parent window 2-other window(ad window)
driver.switchTo().window(lastHandle);
System.out.println(driver.getTitle());
driver.findElement(By.tagName("body")).click();
message on the console:
我遇到了IE 11的类似问题。通过检查IE设置中所有区域的启用保护模式设置来解决此问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.