【发布时间】:2018-08-10 14:07:56
【问题描述】:
我无法在 heroku 中执行 ChromeDriver,尝试了以下方法但没有运气
放置linux chromedriver并在源代码中设置路径如下
String UserPath =System.getProperty("user.dir");
System.out.println("Working Directory = " + System.getProperty("user.dir"));
System.setProperty("webdriver.chrome.driver",UserPath+"/chromedriver");
WebDriver driver=new ChromeDriver();
driver.get("https://www.google.com");
driver.close();
driver.quit();
注意:UserPath 取生成的路径值
2)在heroku中应用buildpack
- heroku/java
- https://github.com/heroku/heroku-buildpack-google-chrome
- https://github.com/heroku/heroku-buildpack-chromedriver
- https://github.com/heroku/heroku-buildpack-java
3) 甚至尝试如下设置二进制路径 第一种方法 ->
ChromeOptions options=new ChromeOptions();
options.setBinary("/app/.apt/opt/google/chrome/chrome");
第二种方法->
ChromeOptions options=new ChromeOptions();
options.setBinary("/app/.apt/usr/bin/google-chrome-stable");
尝试推送到 heroku 时出现错误消息
Working Directory = /tmp/build_790de6ef0cc5cb6adc2f673a25a9d247 [WARNING] java.lang.IllegalStateException: The driver executable does not exist: /app/.apt/opt/google/chrome/chrome
注意:路径“/app/.apt/opt/google/chrome/chrome”基于system.setproperty()中为chromedriver指定的路径
请在这个问题上帮助我。
【问题讨论】:
-
您应该使用 chromedriver.exe。 System.setProperty("webdriver.chrome.driver",UserPath+"/chromedriver.exe");
-
当您说
unable to exceute时,您看到的确切问题是什么?
标签: java maven selenium heroku bitbucket