【发布时间】:2016-12-24 09:05:09
【问题描述】:
我已经开始使用 Web Driver 和 Mocha 来学习测试,但我遇到了一些障碍。从
返回承诺时driver.findElement(By.id('promo'))
.then(element => console.log(element))
我得到一个 WebElement 对象,它确实不是我想要的已解决承诺。 Web 元素对象为 { Object {driver_, id_} }。 我真的找不到任何可以帮助我理解 Web Driver 如何与 JavaScript 和 Mocha 一起工作的文档。
我运行这个测试只是为了返回承诺,它是唯一返回预期结果的测试
it('has the correct title', function(done) {
driver.get('http://www.seleniumhq.org/projects/webdriver/')
.then(() => driver.getTitle())
.then(title => console.log(title))
.then(() => done())
.catch(error => done(error));
});
这将返回“Selenium WebDriver”,这是我希望我可以做出断言的结果。但是,我尝试的任何其他函数要么不是函数,要么返回 Web Element 对象。
【问题讨论】:
标签: selenium webdriver promise mocha.js