我試圖讓webdriver.io和Jasmine工作。Webdriver.io崩潰NoSessionIdError
繼their example,我的劇本是在test/specs/first/test2.js
(根據配置),包含:
var webdriverio = require('webdriverio');
describe('my webdriverio tests', function() {
var client = {};
jasmine.DEFAULT_TIMEOUT_INTERVAL = 9999999;
beforeEach(function() {
client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} });
client.init();
});
it('test it', function(done) {
client
.url("http://localhost:3000/")
.waitForVisible("h2.btn.btn-primary")
.click("h2.btn.btn-primary")
.waitForVisible("h2.btn.btn-primary")
.call(done);
});
afterEach(function(done) {
client.end(done);
});
});
我使用wdio的測試運行,並使用交互式安裝設置。該配置是自動生成的,並且都非常簡單,所以我不認爲需要發佈它。
在另一個終端窗口中,我使用Java 7運行selenium-server-andalone-2.47.1.jar。我的計算機上安裝了Firefox(它在測試運行時會空白啓動),而我的計算機是運行OS 10.10.5。
這是當我開始測試運行會發生什麼:
$ wdio wdio.conf.js
=======================================================================================
Selenium 2.0/webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/docs.html.
=======================================================================================
[18:17:22]: SET SESSION ID 46731149-79aa-412e-b9b5-3d32e75dbc8d
[18:17:22]: RESULT {"platform":"MAC","javascriptEnabled":true,"acceptSslCerts":true,"browserName":"firefox","rotatable":false,"locationContextEnabled":true,"webdriver.remote.sessionid":"46731149-79aa-412e-b9b5-3d32e75dbc8d","version":"40.0.3","databaseEnabled":true,"cssSelectorsEnabled":true,"handlesAlerts":true,"webStorageEnabled":true,"nativeEvents":false,"applicationCacheEnabled":true,"takesScreenshot":true}
NoSessionIdError: A session id is required for this command but wasn't found in the response payload
at waitForVisible("h2.btn.btn-primary") - test2.js:21:14
/usr/local/lib/node_modules/webdriverio/node_modules/q/q.js:141
throw e;
^
NoSessionIdError: A session id is required for this command but wasn't found in the response payload
0 passing (3.90s)
$
我覺得這是非常奇怪和令人費解,尤其是考慮到它甚至打印會話ID。
任何想法?
你是正確的。我正在尋找獨立的例子,而不是wdio的例子。 – Travis