gpt4 book ai didi

java - 设置 Webdriver.Chrome.Driver 属性后 Mac 上的 Chrome WebDriver IllegalStateException

转载 作者:行者123 更新时间:2023-11-30 11:31:24 26 4
gpt4 key购买 nike

我有一个属性文件,用于加载 chrome 不同安装位置的位置:

mac.chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
win.xp.chrome="%HOMEPATH%\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe"
win.7.chrome="C:\\Users\\%USERNAME%\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
linux.chrome="//usr//bin//google-chrome"

我读入这些内容,并在设置 webdriver.chrome.driver prop 时作为调试记录它:

System.setProperty("webdriver.chrome.driver", (String)props.get("mac.chrome"));
log.logInfo("Mac Chrome Driver Property Set To: " + System.getProperty("webdriver.chrome.driver"));

记录器输出:

INFO: Mac Chrome Driver Property Set To: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

当我执行测试时,我看到以下错误:

[junit] The driver executable does not exist: /Users/<user>/eclipseproject/automation/com/gui/"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
[junit] java.lang.IllegalStateException: The driver executable does not exist: /Users/<user>/eclipseproject/automation/com/gui/"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
[junit] at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
[junit] at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:117)
[junit] at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:112)
[junit] at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:75)
[junit] at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
[junit] at drivermanager.DriverManagement.initializeDriver(DriverManagement.java:46)
[junit] at tests.TestChromeChrome.setUp(TestAlerts.java:44)

我在错误中看到发布了 absolutePath,这在 DriverService.checkExecutable 执行 exe.getAbsolutePath() 调用时有意义,但我不明白为什么还包括我的项目的路径。如果有人有任何建议,那就太好了!

最佳答案

需要在浏览器开始正确启动之前为 chrome 设置正确的 DesiredCapabilities 对象。还需要从我的属性文件中删除“”(解决了 IllegalStateException)。

关于java - 设置 Webdriver.Chrome.Driver 属性后 Mac 上的 Chrome WebDriver IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17193019/

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