仅当我将iOS驱动程序 jar生成为Node.js子级时,才会发生此错误。
错误是 java.net.SocketException: Protocol family unavailable
java.net.SocketException: Protocol family unavailable
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
npm install webdriverjs
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
为什么会发生此错误,我该如何解决?
我设法通过使生成的孩子忽略stdin来解决此问题:
var selenium = spawn('java', ['-jar', './ios-server- standalone-0.6.6-SNAPSHOT.jar', '-port', '4444'], {stdio: ['ignore', null, null]});
我不确定为什么这种解决方法有效。