我在我的testing中使用Selenium WebDriver的PhantomJS二进制文件的Linux版本2.5.0-beta(可在这里 ),但它不工作。 例如,这个testing用例在Ubuntu 16.04中的设置失败:
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测试版公告 :
对于Ubuntu的二进制文件,你需要安装一些依赖项:
PNG
jpeg webp
OpenSSL的
zlib的
fontconfig和freetype
libicu