0

運行硒節點JS測試情況下得到錯誤錯誤:ECONNREFUSED連接ECONNREFUSED。運行節點JS硒測試用例得到錯誤錯誤:ECONNREFUSED連接ECONNREFUSED 127.0.0.1:63528

測試用例

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)

回答

0

我不確定你的例子會工作,如果你想在本地運行測試,你需要安裝並加載正確的硒驅動程序。

對於鉻我嘗試使用var driver = new webdriver.Builder().forBrowser('chrome')語法沒有運氣,鉻會啓動但不運行測試,我剛剛看到你描述的錯誤。 但是對於FireFox var driver = new webdriver.Builder().forBrowser('firefox').build();完美工作!

我發現這個工作(本地運行)

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 
相關問題