java - 用于 Selenium WebDriver 的 PhantomJS 2.5.0-beta 在 Linux 中不工作

标签 java linux selenium-webdriver phantomjs

我在测试中使用 Linux 版本 2.5.0-beta 的 PhantomJS 二进制文件用于 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

最佳答案

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

来自 2.5 测试版 announcement :

For Ubuntu binaries you need to install some dependencies:
png
jpeg webp
openssl
zlib
fontconfig and freetype
libicu

关于java - 用于 Selenium WebDriver 的 PhantomJS 2.5.0-beta 在 Linux 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41675982/

相关文章:

java - 从简单表达式中获取 null

linux - 如何编写可在 Windows 和 Linux 上运行的 bash 脚本

python - 使用Python的 Selenium : Permission Denied to Launch Webdriver

java - 枚举<>枚举区别

java - 计算器算法

linux - 如何使用linux的convert命令转换图片格式?

java - 需要帮助使用 webdriver 和 java 识别灯箱上的控件

java - 无法单击 selenium webdriver 中的按钮

java - CamelContext.start() 不会阻塞

linux - Sync IO 在较新的 Linux 内核上慢得令人难以置信