5

webdriver.io と Jasmine を機能させようとしています。

彼らの例に従って、私のスクリプトは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 がインストールされており (テストを実行すると、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 も出力されることを考えると。

何か案は?

4

2 に答える 2

6

wdio テスト ランナーのドキュメントを確認してください。自分で init を使用してインスタンスを作成する必要はありません。wdio テスト ランナーは、セッションの作成と終了を処理します。

あなたの例は、スタンドアロンの WebdriverIO の使用法 (testrunner なし) をカバーしています。ここでwdio を使用する例を見つけることができます。

それを明確にするために: WebdriverIO を使用するには 2 つの方法があります。自分でテストシステムに埋め込むことができます(スタンドアロン/またはスクレーパーとして使用)。次に、インスタンスの作成と終了、またはそれらの並列実行などを処理する必要があります。WebdriverIO を使用するもう 1 つの方法は、wdio と呼ばれるテスト ランナーを使用することです。テストランナーは、テストセットアップに関する一連の情報を含む構成ファイルを取得し、インスタンスを生成して、Sauce Labs などのジョブ情報を更新します。

于 2015-09-14T22:14:32.680 に答える
2

すべての Webdriver コマンドは非同期で実行されます。テスト内とテスト内でdoneコールバックを適切に呼び出しましたが、でそれを行うのを忘れていました:afterEachtest itbeforeEach

beforeEach(function(done) {
    client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} });
    client.init(done);
});
于 2015-11-30T23:46:48.043 に答える