我第一次运行Node.js + Mocha + Selenium Webdriverjs的组合。我在https://code.google.com/p/selenium/wiki/WebDriverJs中根据他们的文档设置了一切,但我发现很难通过web驱动程序找到所有可用命令的列表。在使用Selenium webdriverjs编写测试时,是否有可用的命令列表?
例如,我如何使用Javascript实现以下java代码
new Wait("Couldn't find close button!") {
boolean until() {
return selenium.isElementPresent("button_Close");
}
};我知道我可以使用driver.wait,但它无法识别until命令或isElementPresent
发布于 2013-04-16 13:36:05
我在这里直接查看文档的源文件。它实际上相当不错:
https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js
在回答您的问题时,您并不是真的想在WebDriverJS中等待,而是想要习惯延迟对象和promises api。我刚刚在这里写了一篇关于它的博客文章,应该会对你有所帮助:
http://xolv.io/blog/2013/04/end-to-end-testing-for-web-apps-meteor
发布于 2015-06-27 06:19:58
我也在看源代码。他们有一个编译过的API文档版本,在这里可以更容易地浏览:
http://selenium.googlecode.com/git/docs/api/javascript/module_selenium-webdriver.html
不幸的是,只有方法名没有摘要。你仍然需要在页面中滚动。
在如何等待方面:
webdriver = require 'selenium-webdriver'
driver = ... // init your driver
driver.wait(webdriver.until...)发布于 2016-11-01 02:50:43
@op,最好使用链式语句。我使用until和isElementPresent命令,它们适用于生产就绪(CI/CD)训练过程。因此,调整您的代码应该是可行的
var isDisplayed = function(){
driver.isElementPresent(by.id('button id')).then(function(isDisplayed){
expect(isDisplayed).to.be.true
});
}; https://stackoverflow.com/questions/15506037
复制相似问题