【发布时间】:2017-03-30 22:40:59
【问题描述】:
我在使用 Selenium + mocha 打开 URL 时遇到了一些问题。这是我正在使用的代码行。
return driver.get('http://localhost/ClickSuscribe/#/MisProductos')
我发现 angular url 存在一些问题,但我还没有找到解决方案。
错误是Error: timeout of 40000ms exceeded. Ensure the done() callback is being called in this test.
这是测试用例:
it("Is visible", function() {
if(viable)
{
return driver.findElements(webdriver.By.id('activarMiSitio')).then(function(misProductos){
misProductos[0].getAttribute("class").then(function(webElement){
if(webElement==='ng-hide')
{
console.log('Element not found');
}
else{
console.log('Element exists');
}
}).then(function(){
driver.sleep(500);
//return driver.get('http://localhost/ClickSuscribe/#').catch(r => console.log(r));
return driver.get('http://localhost/ClickSuscribe/#/MisProductos').catch(r => console.log(r));
});/*.then(function(){
driver.sleep(2000);
return driver.getCurrentUrl();
}).then(function(currentUrl){
driver.sleep(1000);
console.log(currentUrl);
});*/
});
}
return console.log("No está loggeado");
});
PS:这确实适用于 Chrome 和 IE。似乎 selenium 在处理带有锚点或井号“#”的 URL 时存在问题。
【问题讨论】:
-
是get方法还是脚本执行的问题?
-
@MohamedELAYADI 我不太确定,但似乎最有可能与 get 方法有关,因为当它卡在那里大约一分钟时,会继续下一个测试。跨度>
标签: node.js selenium testing mocha.js selenium-firefoxdriver