PhantomJS 2.5.0-beta for Selenium WebDriver不能在Linux中工作
问题描述:
我在测试中使用PhantomJS二进制文件的Linux版本2.5.0-beta for Selenium WebDriver(可用here),但它不起作用。例如,这个测试用例上安装失败在Ubuntu 16.04:PhantomJS 2.5.0-beta for Selenium WebDriver不能在Linux中工作
public class PhantomJsTest {
protected WebDriver driver;
@BeforeClass
public static void setupClass() {
System.setProperty("phantomjs.binary.path",
"/path/to/linux-ubuntu-trusty-x86_64/2.5.0/phantomjs");
}
@Before
public void setupTest() {
driver = new PhantomJSDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// my test
}
}
的错误跟踪我得到的是以下几点:
Jan 16, 2017 12:50:52 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: /home/boni/.m2/repository/webdriver/phantomjs/linux-ubuntu-trusty-x86_64/2.5.0/phantomjs
Jan 16, 2017 12:50:52 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 14863
Jan 16, 2017 12:50:52 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=14863, --webdriver-logfile=/home/boni/Documents/dev/other/webdrivermanager/phantomjsdriver.log]
Jan 16, 2017 12:50:52 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
/home/boni/.m2/repository/webdriver/phantomjs/linux-ubuntu-trusty-x86_64/2.5.0/phantomjs: error while loading shared libraries: libicui18n.so.52: cannot open shared object file: No such file or directory
Jan 16, 2017 12:51:13 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 127 (Exit value: 127)
是在这个时刻这个二进制越野车?
UPDATE
我安装了以下的依赖:
sudo apt-get install libicu-dev
...现在我得到这个错误:
INFO: Detected dialect: OSS
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Jan 16, 2017 2:39:35 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:11591: The target server failed to respond
Jan 16, 2017 2:39:35 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:11591
答
有你安装了所有必要的依赖?
从2.5 beta测试版announcement:
For Ubuntu binaries you need to install some dependencies:
png
jpeg webp
openssl
zlib
fontconfig and freetype
libicu
我没有,但我现在就是这么做: 命令和apt-get安装libicu-dev的 现在我得到另一个错误,现在看来很清楚,是一个bug: 信息:检测到的方言:OSS PhantomJS已经崩溃。请阅读上的错误报告指南并提交错误报告。 2017年1月16日下午1:46:01 org.apache.http.impl.execchain.RetryExec执行 –
如何在Linux中使用它。 –
@SantoshHegde下载linux版本,解压并运行它。或者你的意思是别的吗? – Vaviloff