2

后,我有一个属性文件,我使用加载不同的安装位置的位置铬:铬的webdriver在Mac IllegalStateException异常设置Webdriver.Chrome.Driver财产

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道具我记录它:

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()调用看,但我不不明白为什么我的项目的路径也包括在内。如果有人有任何建议,这将是真棒!

+1

您误解了您被要求通过的内容。您不应传入** Chrome **位置,而是** ChromeDriver **位置(除非它们位于相同的位置)。 – Arran

+0

@Arran设置属性webdriver.chrome.driver是chrome可执行文件的位置。我错过了什么? – bcar

+0

哦......我明白了。我下载了驱动程序,把它放在path/users//downloads中,设置为我的webdriver.chrome.driver属性,但我仍然看到问题:'java.lang.IllegalStateException:驱动程序可执行文件不存在:' – bcar

回答

1

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

相关问题