1
我想了解如何使用摩卡和硒在一起。我發現了一個簡單的教程,但一旦它開始,我得到以下錯誤摩卡硒測試簡單的例子不工作
Google Search
1) should work
0 passing (2s)
1 failing
1) Google Search should work:
Error: timeout of 2000ms exceeded
at null.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runnable.js:157:19)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
下面是代碼,我有
var assert = require('assert'),
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver');
test.describe('Google Search', function() {
test.it('should work', function() {
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.firefox()).
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();
});
});
於是我就下面的命令來測試硒的webdriver和它失敗只爲摩卡
npm test selenium-webdriver
錯誤,我得到
1) Mocha Integration it properly allows timeouts and cancels control flow :
Error: timeout of 1000ms exceeded
at Test.done (/usr/local/lib/node_modules/mocha/lib/runnable.js:204:67)
at Test.runnable.callback.mochaCallback (/Users/jcostanzo/Work/Development/automation/phantomjs/node_modules/selenium-webdriver/test/testing/index_test.js:61:30)
at Test.cleanupBeforeCallback [as callback] (/Users/jcostanzo/Work/Development/automation/phantomjs/node_modules/selenium-webdriver/testing/index.js:123:52)
at null.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runnable.js:157:10)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)