Selenium webdriver 摩卡和柴-错误:超过25000毫秒超时。确保在此测试中调用了done()回调
我将使用Mocha、Chai和selenium webdriver编写一个简单的测试。但这让我感到: 错误:超过25000ms的超时时间。确保已完成()回调 在这次测试中被调用 以下是我正在使用的代码:Selenium webdriver 摩卡和柴-错误:超过25000毫秒超时。确保在此测试中调用了done()回调,selenium-webdriver,mocha.js,chai,Selenium Webdriver,Mocha.js,Chai,我将使用Mocha、Chai和selenium webdriver编写一个简单的测试。但这让我感到: 错误:超过25000ms的超时时间。确保已完成()回调 在这次测试中被调用 以下是我正在使用的代码: 'use strict'; var webdriver = require ('selenium-webdriver'), chai = require ('chai'), until = webdriver.until, By = webdriver.By, wait = w
'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');
});
});
我该如何解决这个问题呢?对你的问题的标准答案是“兑现你的承诺,让摩卡可以等待” 然而,
seleniumwebdriver
提供了有关摩卡库存功能的包装。这些函数与Selenium的promise机制挂钩,无需返回承诺或使用done
回调等待Selenium的驱动程序完成。您只需导入selenium webdriver/测试
,然后使用描述
,它
,之前
,之后,。。。该模块提供的功能
var test = require('selenium-webdriver/testing');
test.describe("top level", function () {
test.before(...);
test.it("some test", function () {
});
});
谢谢但即使在使用“test”之后,它也会给我同样的错误。