gpt4 book ai didi

selenium-chromedriver - 无法使用 Selenium 在 Windows 7 中启动 Chrome headless 浏览器

转载 作者:行者123 更新时间:2023-12-01 01:49:31 25 4
gpt4 key购买 nike

 **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)

最佳答案

headless 的论点是错误的,应该是:

chromeOptions.addArguments("--headless");

使用 -- before headless ,就像您从快捷方式添加参数一样:
enter image description here

关于selenium-chromedriver - 无法使用 Selenium 在 Windows 7 中启动 Chrome headless 浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45671767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com