cannot find Chrome binary问题解决办法
新手一枚,最近一直在学习Jenkins+testng+maven测试框架,遇到一个这样问题:本地IDEA执行测试用例正常,但使用Jenkins时就会报以下错误信息:-------------------------------------------------------T E S T S---------------------------------------------
·
新手一枚,最近一直在学习Jenkins+testng+maven测试框架,遇到一个这样问题:
本地IDEA执行测试用例正常,但使用Jenkins时就会报以下错误信息:
------------------------------------------------------- T E S T S ------------------------------------------------------- Running TestSuite [TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your file, otherwise TestNG may fail or not work as expected. Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 12009 Only local connections are allowed. log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies). log4j:WARN Please initialize the log4j system properly. Tests run: 2, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 2.714 sec <<< FAILURE! - in TestSuite beforeMethod(cases.ALoginTest) Time elapsed: 2.547 sec <<< FAILURE! org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 112 milliseconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: '123-PC', ip: '172.16.20.181', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65' Driver info: driver.version: ChromeDriver
经过Google后发现这样一篇文章:https://stackoverflow.com/questions/41144934/cannot-find-chrome-binary-when-executing-a-selenium-testng-test-in-jenkins-on
然后按照上面方法进行操作:
ChromeOptions options = new ChromeOptions(); options.setBinary("C:\\Users\\123\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"); System.setProperty("webdriver.chrome.driver","E:/seleniumsever/chromedriver.exe"); driver = new ChromeDriver();经过验证还是报同样问题。
考虑到权限问题,于是重装了chrome,目录在
C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe
然后代码改成如下:
ChromeOptions options = new ChromeOptions(); options.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"); System.setProperty("webdriver.chrome.driver","E:/seleniumsever/chromedriver.exe"); driver = new ChromeDriver();再次在Jenkins上重试,问题解决!!!
更多推荐
已为社区贡献2条内容
所有评论(0)