【问题标题】:Issue while Executing the chromeDriver in Heroku - Java Maven在 Heroku 中执行 chromeDriver 时出现问题 - Java Maven
【发布时间】: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

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


【解决方案1】:

这是适合我的配置。

它是 Java 8、Maven 和 Springboot。

System.setProperty("GOOGLE_CHROME_BIN", "/app/.apt/usr/bin/google-chrome"); 
System.setProperty("CHROMEDRIVER_PATH", "/app/.chromedriver/bin/chromedriver");

ChromeOptions options = new ChromeOptions();
options.setBinary("/app/.apt/usr/bin/google-chrome");   
options.addArguments("--enable-javascript"); 
options.addArguments("--headless"); 
options.addArguments("--disable-gpu"); 
options.addArguments("--no-sandbox");

WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("https://the-web_you_want");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-04
    • 1970-01-01
    • 1970-01-01
    • 2011-08-08
    • 2020-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多