Node.js Selenium IPv6问题(SocketException协议系列不可用) [英] Node.js Selenium IPv6 Issue (SocketException Protocol family unavailable)

查看:219
本文介绍了Node.js Selenium IPv6问题(SocketException协议系列不可用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有当我将 ios-driver jar作为a jar生成时才会出现此错误Node.js child。

This error only happens when I spawn the ios-driver jar as a Node.js child.

错误是 java.net.SocketException:协议族不可用

selenium-test.js:

var spawn = require('child_process').spawn;

var selenium = spawn('java', ['-jar', './ios-server-standalone-0.6.6-SNAPSHOT.jar', '-port', '4444']);
selenium.stderr.setEncoding('utf8');
selenium.stderr.on('data', function (data){
  console.log(data);
});

webdriverjs-test.js webdriverjs

var webdriverjs = require('webdriverjs');
var options = {
    desiredCapabilities: {
        browserName: 'safari',
        platform: 'OS X 10.9',
        version: '7.1',
        device: 'iphone'
    }
};

webdriverjs
  .remote(options)
  .init()
  .end();

通过创建上述文件,在一个窗口中运行selenium-test.js和webdriverjs-重现此错误test.js在另一个窗口中。您首先需要 npm install webdriverjs curl -O http://ios-driver-ci.ebaystratus.com/userContent/ios-server -standalone-0.6.6-SNAPSHOT.jar

Reproduce this error by creating the above files, running selenium-test.js in one window and webdriverjs-test.js in another window. You will first need to npm install webdriverjs and curl -O http://ios-driver-ci.ebaystratus.com/userContent/ios-server-standalone-0.6.6-SNAPSHOT.jar

版本信息:

$ java version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

$ node -v
v0.10.26

为什么会发生此错误以及如何解决?

Why does this error happen and how do I fix it?

推荐答案

我设法通过让生成的孩子忽略stdin来解决这个问题:

I managed to solve this by making the spawned child ignore stdin:

var selenium = spawn('java', ['-jar','。/ oo-server-standalone-0.6.6-SNAPSHOT.jar',' - port','4444'],{stdio:['ignore',null,null]});

我不确定为什么这种解决方法有效。

I'm not sure why this workaround works.

这篇关于Node.js Selenium IPv6问题(SocketException协议系列不可用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆