// 引入geckodriver驱动 ---第二个参数是驱动所在路径
System.setProperty("webdriver.gecko.driver",".\\geckodriver.exe");
// 新建一个firefox浏览器实例,并设置headless,不显示浏览器的情况下运行程序
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
//WebDriver driver = new FirefoxDriver();
// 打开outlook首页
driver.get("https://outlook.live.com/owa/?nlp=1&signup=1");
环境:
Firefox 版本:61.0.1;
geckodriver 版本:v0.21.0;
selenium-java-3.13.0;
selenium+java+firefox 静默启动浏览器方法
最新推荐文章于 2024-06-17 00:09:44 发布