//1.取消chrome正受到自动测试软件的控制的信息栏
ChromeOptions options = new ChromeOptions();
//配置参数
options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
1.关闭弹窗
当我们使用selenium脚本打开Chrome浏览器时,顶部都会弹出一个提示框
那么我们可以使用options方法去除提示框
package com.ming.Selenium;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class FirstScript {
public static void main(String[] args) throws InterruptedException {
取消 chrome正受到自动测试软件的控制的信息栏
ChromeOptions options = new ChromeOptions();
//配置参数
options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
//实例化一个携带参数的浏览器
WebDriver driver = new ChromeDriver(options);
//浏览器最大化
driver.manage().window().maximize();
//跳转到selenium官网
driver.get("https://www.selenium.dev/");
Thread.sleep(3000);
//title
try {
String Selnium_title = "Sel";
String title = driver.getTitle();
assert Selnium_title == title ;
System.out.println("pass");
} catch (Exception e) {
e.printStackTrace();
}
//关闭浏览器
driver.quit();
}
}
持续更新ing…