Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从jar文件启动时,Selenium服务器没有响应_Java_Selenium_Selenium Webdriver_Selenium Grid2 - Fatal编程技术网

Java 从jar文件启动时,Selenium服务器没有响应

Java 从jar文件启动时,Selenium服务器没有响应,java,selenium,selenium-webdriver,selenium-grid2,Java,Selenium,Selenium Webdriver,Selenium Grid2,我正在设置一个无头Ubuntu服务器作为节点。这个节点通过Chromedriver运行Chrome,我可以在通过bash启动jar时运行测试。这是我正在使用的命令: java -jar /opt/selenium-server-standalone-2.39.0.jar -role node -hub http://qwautomation02:4444/grid/register -port 5555 -Dwebdriver.chrome.driver=/opt/chromedriver.

我正在设置一个无头Ubuntu服务器作为节点。这个节点通过Chromedriver运行Chrome,我可以在通过bash启动jar时运行测试。这是我正在使用的命令:

java -jar /opt/selenium-server-standalone-2.39.0.jar -role node -hub 
http://qwautomation02:4444/grid/register -port 5555 
-Dwebdriver.chrome.driver=/opt/chromedriver.exe -nodeConfig /mnt/smb/Configuration/nodeConfig.json
我已经编写了一个Java应用程序来运行这个命令,并将正在使用的端口插入数据库。此应用程序使用与上述相同的bash命令启动Selenium服务器。我从/opt目录启动这个jar,与Selenium服务器jar所在的目录相同。以下是适用的方法:

    public static Process startupNode(int portNumber, String browser) throws IOException{
    //If Linux, else Windows.
    String port = String.valueOf(portNumber);
    if (Portability.isUnix()) {
        return Runtime.getRuntime().exec(String.format("java -jar /opt/selenium-server-standalone-2.39.0.jar -role node -hub http://qwautomation02:4444/grid/register -port %s -Dwebdriver.chrome.driver=/opt/chromedriver -nodeConfig /mnt/smb/Configuration/nodeConfig.json"
                , port));   
    }
    else
        return Runtime.getRuntime().exec(String.format("java -jar C:\\Selenium\\vendor\\selenium-server-standalone-2.39.0.jar -role node -hub http://qwautomation02:4444/grid/register -port %s -Dwebdriver.chrome.driver=C:\\Chromedriver\\chromedriver.exe -nodeConfig \\\\qwautomation02\\WebDriver\\Configuration\\nodeConfig.json"
                , port));   
}
我可以启动测试和部分运行,但此异常总是在执行期间抛出,无法捕获


在执行过程中,会话似乎正在失去与中心的通信。但是,考虑到当我手动运行bash命令时测试将一直运行到完成,我不知道为什么会发生这种情况。

这听起来像是Ubuntu权限错误。您的个人Ubuntu用户具有执行权限,但运行java文件的用户/进程可能没有。

我将尝试从这里实现答案。不过,实际的jar会执行。它只是与其他服务器存在通信问题。我不确定getRuntime().exec与主线程在同一个线程上是否存在问题,主线程有ReadLine()语句来保持jar运行。这也可能是集线器的轮询超时。我遇到过更复杂的元素选择器。你能详细说明一下吗?当然,我很乐意。Selenium Webdriver网格/集线器模式在并行运行时,有时会在等待来自每个节点的回调时锁定。我的安装程序是一个Ubuntu主机,运行3个Windows和IE各种配置的VM映像。selenium hub在Ubuntu中运行,节点在Windows中运行。优化建议:尝试在异常行之前添加一些wait hust。从…起