我正在尝试在Linux中使用Chrome浏览器运行硒测试用例..
在Linux中设置Chrome浏览器的步骤:
从以下路径下载了chrome-linux.zip并以特定路径将其解压缩到linux计算机中
将最新的chromedriver linux版本文件(2.40)放入linux机器中
对chromedrive文件以及chrome-linux文件夹都具有完全权限(777)。
还有硒代码:
WebDriver driver = null;
DesiredCapabilities caps = DesiredCapabilities.chrome();
ChromeOptions opts = new ChromeOptions();
opts.addArguments("--headless");
opts.addArguments("--disable-extensions");
opts.setBinary("/opt/chromeos/chrome-linux/chrome");//path of the chrome application file in linux
caps.setCapability(ChromeOptions.CAPABILITY, opts);
System.setProperty("webdriver.chrome.driver", "/opt/chromeos/chomedriver");//path of the chromedriver file in linux
driver = new ChromeDriver(caps);
driver.get("https://www.google.com/");
当我尝试运行时,出现无法访问的浏览器异常。
/opt/chromeos/chromedriver: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /opt/chromeos/chromedriver)
/opt/chromeos/chromedriver: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/chromeos/chromedriver)
/opt/chromeos/chromedriver: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /opt/chromeos/chromedriver)
Jul 03, 2018 12:46:53 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
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.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'ION-MUM-PreQA-JB-61-75', ip: '10.10.61.75', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-696.el6.x86_64', java.version: '1.7.0_101'
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:138)
at com.DemoChromiumTest.main(DemoChromiumTest.java:24)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'ION-MUM-PreQA-JB-61-75', ip: '10.10.61.75', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-696.el6.x86_64', java.version: '1.7.0_101'
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)
... 6 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:16689/status] to be available after 20012 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)
... 9 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)
... 10 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)
... 11 more
任何建议或指导将不胜感激...
答案 0 :(得分:1)
此错误消息...
/opt/chromeos/chromedriver: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /opt/chromeos/chromedriver)
/opt/chromeos/chromedriver: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/chromeos/chromedriver)
/opt/chromeos/chromedriver: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /opt/chromeos/chromedriver)
Jul 03, 2018 12:46:53 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
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.
...表示 ChromeDriver 由于缺少而无法启动/产生新的 WebBrowser 即 Chrome浏览器会话GLIBC_2.15 和/或 GLIBC_2.14 。
首先,根据您使用 Selenium Java Client v2.53.0 时的问题详细信息,我看不到您的代码块有任何问题。但是,当您使用的是 Linux操作系统而不是 chrome-linux.zip 时,必须确保下载了 chrome-linux.tar / chrome-linux.tz ,并对其进行解锁以正确使用。
/lib64/libc.so.6: version 'GLIBC_2.15' not found
和/lib64/libc.so.6: version 'GLIBC_2.14' not found
您要执行的 ChromeDriver 二进制文件是在基于GLIBC-2.15
的系统上构建的,该系统不会在具有较旧版本的GLIBC的任何系统上执行。
/usr/lib64/libstdc++.so.6: version 'GLIBCXX_3.4.15' not found
类似地,您尝试执行的 ChromeDriver 二进制文件是在基于GLIBCXX_3.4.15
的系统上构建的,该系统不会在具有较旧GLIBC的任何系统上执行,因为您的GLIBC大于2.14
在DistroWatch.com中查找兼容的二进制文件。
此外,您还没有提到确切的环境详细信息,但以下是一些可能的原因和解决方案:
CentOS
,则升级到CentOS version 7
将解决您的问题。根据chromedriver_linux64_2.1.zip not working in CentOS 6.4 (latest),您需要:
/opt/google/chrome
文件夹(您需要sudo访问)。 chromedriver
复制到此文件夹(为简化起见,您可以将其放置在任何位置)。将google-chrome
的副本创建为google-chromedriver
。 vi google-chromedriver和最后一行修改为:
exec -a "$0" "$HERE/chromedriver" "$@" (you can provide custom location of driver too).
包含在路径中
sudo ln -s /opt/google/chrome/google-chromedriver /usr/bin/chromedriver
更改权限:
chmod +x chromedriver