本文介绍了在Chrome上运行节点js selenium测试用例获取错误错误:ECONNREFUSED连接ECONNREFUSED 127.0.0.1:63528的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在selenium node js上运行测试用例得到错误错误:ECONNREFUSED连接ECONNREFUSED。

Running a test case on selenium node js got error Error: ECONNREFUSED connect ECONNREFUSED.

测试用例

var assert = require('assert'),
    test = require('selenium-webdriver/testing'),
    webdriver = require('selenium-webdriver');
test.describe('Google Search', function () {
    test.it('should work', function (done) {
        this.timeout(100000);
        var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).build();
        driver.get('http://www.google.com');
        var searchBox = driver.findElement(webdriver.By.name('q'));
        searchBox.sendKeys('simple programmer');
        searchBox.getAttribute('value').then(function (value) {
            assert.equal(value, 'simple programmer');
        });
        driver.quit();
        done();
    });
});

错误堆栈跟踪如下

错误:ECONNREFUSED在ClientRequest上连接ECONNREFUSED 127.0.0.1:63528
。 (node_modules\selenium-webdriver\http\index.js:238:15)

推荐答案

我我不确定你的例子是否可行,如果你想在本地运行测试,你需要安装和加载正确的selenium驱动程序。

I'm not sure your example would work, if you want to run the tests locally you would need to install and load the correct selenium drivers.

对于chrome我尝试使用 var驱动程序=新的webdriver.Builder()。forBrowser('chrome')语法没有运气,chrome会启动但不会运行测试,我刚看到错误你描述。
但是对于FireFox var driver = new webdriver.Builder()。forBrowser('firefox')。build(); 完美运行!

For chrome I tried to use the var driver = new webdriver.Builder().forBrowser('chrome') syntax with no luck, chrome would fire up but not run tests, I just saw the error you describe.However for FireFox var driver = new webdriver.Builder().forBrowser('firefox').build(); workes perfectly !

我发现这有效(在本地运行)

I found this works (running locally)

  var assert = require('assert'),
    webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until,
    chrome = require('selenium-webdriver/chrome'),
    firefox = require('selenium-webdriver/firefox');

  var path = require('chromedriver').path;
  var driver = chrome.Driver.createSession(new chrome.Options(), new
  chrome.ServiceBuilder(path).build());

  driver.get('http://mysite/myapp/tests/functional/start.html');

  //tests here

这篇关于在Chrome上运行节点js selenium测试用例获取错误错误:ECONNREFUSED连接ECONNREFUSED 127.0.0.1:63528的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 21:26