Selenium WebDriver的PhantomJS 2.5.0-beta无法在Linux中运行

时间:2017-01-16 12:01:12

标签: java linux selenium-webdriver phantomjs

我在测试中使用了PhantomJS二进制的Linux版本2.5.0-beta for Selenium WebDriver(可用here),但它无效。例如,此测试用例在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)

此刻这是二元车吗?

更新

我安装了以下依赖项:

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

1 个答案:

答案 0 :(得分:1)

您是否安装了所有必需的依赖项?

来自2.5 beta announcement

  

对于Ubuntu二进制文件,您需要安装一些依赖项:
  PNG
  JPEG   WEBP
  OpenSSL的
  zlib的
  fontconfig和freetype
  的 libicu