2015-09-11 14 views
5

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を出力することを考えると、これは非常に奇妙で不可解見つけます。

アイデア?

答えて

4

wdioテストランナーのthe docsを確認してください。自分でinitを使用してインスタンスを作成する必要はありません。 wdioテストランナーはセッションの作成と終了に注意します。

この例では、スタンドアロンのWebdriverIOの使用法(テストランナーなし)について説明しています。 wdio hereを使用する例が見つかります。

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

+0

。私はwdioの例の代わりにスタンドアロンの例を見ていました。 – Travis

2

すべてのWebdriverコマンドが非同期で実行されます。 あなたは適切afterEachにし、あなたのtest itテストでdoneコールバックと呼ばれるが、beforeEachでそれを行うのを忘れて:あなたは正しいです

beforeEach(function(done) { 
    client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} }); 
    client.init(done); 
}); 
関連する問題