Selenium chromedriver 无法使用Selenium在Windows 7中启动Chrome无头浏览器
我面临的错误Selenium chromedriver 无法使用Selenium在Windows 7中启动Chrome无头浏览器,selenium-chromedriver,google-chrome-headless,Selenium Chromedriver,Google Chrome Headless,我面临的错误 **Sinppet** if (os.contains("win")) { System.out.println("OS: WINDOWS"); System.setProperty("webdriver.chrome.driver", localPath+"chromedriver.exe"); ChromeOptions chromeOption
**Sinppet**
if (os.contains("win")) {
System.out.println("OS: WINDOWS");
System.setProperty("webdriver.chrome.driver", localPath+"chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("headless");
return new ChromeDriver(chromeOptions);
} else if (os.contains("mac")) {
System.out.println("OS: MAC");
System.setProperty("webdriver.chrome.driver", localPath+"chromedriver_mac64");
return new ChromeDriver();
}
无头的论点是错误的,应该是:
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //input[@id='user_id'] (tried for 180 second(s) with 500 MILLISECONDS interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:232)
at com.adp.marketplace.frwk.selenium.SeleniumFunctions.waitForVisibilityByXpath(SeleniumFunctions.java:510)
at com.adp.marketplace.prm.SSOTestInPRMSteps.The_user_logged_into_PRM_with_valid_cred(SSOTestInPRMSteps.java:28)
at ?.Given the user logged into PRM with valid creds(com/adp/marketplace/prm/SSOTestsInPRM.feature:7)
使用--before headless,就像在快捷方式中添加参数一样:
chromeOptions.addArguments("--headless");