public class CuangKouQieHuan {
public static void main(String[] args) {
Webdriver chrome = new Webdriver();
chrome.get("http://localhost/");
chome.findElement(By.linkText("登录")).click();
//基于网页文本连接查找登录 进行登录
Setwindows = chrome.getWindowHandles();
//建立所有打开窗口的集合
String cw = chrome.getWindowHandle();
//设置当前窗口cw
for (String s: windows) {
if (s.equals(cw) { //与当前窗口进行比对
chrome.close();
} else {
chrome.switchTo().window(s);
}
}
}
}