我正在尝试创建一个简单的基于AWS
的java selenium应用程序。
我已安装 java JDK 和 google-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
google-chrome在终端上运行良好......
答案 0 :(得分:0)
尝试将您的java更新为JAVA 8(1.8)
答案 1 :(得分:0)
面临同样的问题,但错误略有不同
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 139 (Exit value: 139)
从存档中提取驱动程序有问题 - 正确的大小是~8MB
失败
drwxrwxr-x 2 jenkins jenkins 4096 Mar 12 10:01 .
drwxrwxr-x 6 jenkins jenkins 4096 Oct 10 10:10 ..
-rwxrw-r-- 1 jenkins jenkins 1376159 Oct 10 10:10 chromedriver
成功
drwxrwxr-x 2 jenkins jenkins 4096 Oct 10 10:11 .
drwxrwxr-x 7 jenkins jenkins 4096 Oct 10 10:11 ..
-rwxrw-r-- 1 jenkins jenkins 8950080 Oct 10 10:11 chromedriver