操作Cookie
// Go to the correct domain
driver.get("http://www.example.com");
// Now set the cookie. This one's valid for the entire domain
Cookie cookie = new Cookie("key", "value");
driver.manage().addCookie(cookie);
// And now output all the available cookies for the current URL
Set<Cookie> allCookies = driver.manage().getCookies();
for (Cookie loadedCookie : allCookies) {
System.out.println(String.format("%s -> %s", loadedCookie.getName(), loadedCookie.getValue()));
}
SwitchTo Window命令
Set<String> handles = driver.getWindowHandles();
String currentHandle = driver.getWindowHandle();
for (String handle : handles ) {
if(!currentHandle.equals(handle)){
driver.switchTo().window(handle);
}
}
SwitchTo Frame命令
driver.switchTo().frame("frameName");
driver.switchTo().defaultContent(); //return default frame
SwitchTo PopUp命令
Alert alert = driver.switchTo().alert();
alert.accept();
谷歌浏览器启动配置
https://blog.csdn.net/bpz31456/article/details/80455708
启动参数
https://peter.sh/experiments/chromium-command-line-switches/
参考
https://sites.google.com/a/chromium.org/chromedriver/home
查看谷歌NetWork数据
https://blog.csdn.net/zhuyiquan/article/details/80148767