2017-07-19 7 views
0

私はMocha、Chai、およびSelenium webdriverを使って簡単なテストを書いています。しかし、その私を投げ:モカとチャイ - エラー:25000msのタイムアウトを超えました。このテストでdone()コールバックが呼び出されていることを確認してください

'use strict'; 

var webdriver = require ('selenium-webdriver'), 
    chai = require ('chai'), 
    until = webdriver.until, 
    By = webdriver.By, 
    wait = webdriver.wait, 
    chaiAsPromised = require("chai-as-promised"), 
    assert = chai.assert, 
    mocha = require('mocha'), 
    expect = chai.expect; 
    chai.config.includeStack = true; 

    var driver; 

    describe('Login', function(){ 
     before(function(done){ 

     driver = new webdriver 
      .Builder() 
      .withCapabilities(webdriver.Capabilities.chrome()) 
      .build(); 

     driver.get('http://someurl'); 
     driver.findElement(By.id('username')).sendKeys('username'); 
     driver.findElement(By.id('password')).sendKeys('password'); 
     driver.findElement(By.id('Login')).click(); 

     this.timeout(25000); 
     setTimeout(done, 25000); 

     }); 


     after(function(done){ 
     driver.quit(); 
     this.timeout(5000); 
     done(); 
     }); 




     it('verify the waiting for task Button', function(){ 
     driver.wait(until.elementLocated(By.css('.StartButton__btn'))) 
     .then(function(){ 
     driver.findElement(By.css('.StartButton__btn')).click(); 
     }); 

     var waitScreenTest = 
     driver.findElement(By.css('.WaitingScreen__text')).getText(); 
     assert(waitScreenTest, 'Waiting for Tasks'); 
     }); 
    }); 

を、私はこの問題を解決するにはどうすればよい:

Error: timeout of 25000ms exceeded. Ensure the done() callback is being called in this test.

ここで私が使用しているコードはありますか?

答えて

0

あなたの質問に対する標準的な答えは、「あなたの約束を返して、モカが彼らを待つことができるようにする」ことです。

しかし、selenium-webdriverは、Mochaのストック機能に関するラッパーを提供します。これらの関数は、Seleniumの約束機関にフックし、約束を返す必要性を回避するか、またはdoneコールバックを使用してSeleniumのドライバが完了するまで待つ必要があります。 selenium-webdriver/testingをインポートし、describe,itbeforeafter、...そのモジュールで提供される機能を使用するだけで済みます。

var test = require('selenium-webdriver/testing'); 

test.describe("top level", function() { 

    test.before(...); 

    test.it("some test", function() { 
    }); 
}); 
+0

ありがとうございました。しかし、それは私にも 'テスト'を使用した後も同じエラーを与えます。 –

関連する問題

 関連する問題