gpt4 book ai didi

java - AWS Redhat Chromedriver 不适用于 Java selenium

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:34 27 4
gpt4 key购买 nike

我正在尝试创建一个简单的基于 AWS 的 java selenium 应用程序。

我已经安装了java JDKgoogle-chrome

我创建了一个示例应用程序,可以在 Windows 上正常运行(使用 chrome-driver ofc)但是当我将代码复制到 AWS 并尝试运行时,我总是收到此错误。

知道如何解决这个问题吗?

[root@ip-172-31-43-139 ec2-user]# java -version
java version "1.7.0_151"
OpenJDK Runtime Environment (amzn-2.6.11.0.74.amzn1-x86_64 u151-b00)
OpenJDK 64-Bit Server VM (build 24.151-b00, mixed mode)



[root@ip-172-31-43-139 ec2-user]# google-chrome --version
Google Chrome 60.0.3112.113

我的示例代码

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );

WebDriver driver = null;

// System.setProperty("webdriver.chrome.driver", "chromedriver");
//Set up
ChromeOptions options = new ChromeOptions();
options.setBinary("/usr/bin/google-chrome");
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--screenshoot");
driver = new ChromeDriver(options); // dies here <-

driver.get("http://www.google.com");

//Tear down
driver.quit();

}

}

控制台输出:

Hello World!
/opt/google/chrome/google-chrome: symbol lookup error: /opt/google/chrome/lib/libgtk-3.so.0: undefined symbol: g_log_structured
Nov 06, 2017 1:44:12 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 127 (Exit value: 127)
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'ip-172-31-43-139', ip: '172.31.43.139', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.51-10.52.amzn1.x86_64', java.version: '1.7.0_151'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
at hu.csani.aws_test.App.setUp(App.java:33)
at hu.csani.aws_test.App.main(App.java:19)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'ip-172-31-43-139', ip: '172.31.43.139', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.51-10.52.amzn1.x86_64', java.version: '1.7.0_151'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 8 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:22678/status] to be available after 20005 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)
... 11 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
... 12 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:201)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 13 more

谷歌浏览器在终端上运行良好...

最佳答案

尝试将您的 java 更新到 JAVA 8 (1.8)

关于java - AWS Redhat Chromedriver 不适用于 Java selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47139376/

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