我正在Selenium,MacOS和Chrome上使用量角器。我正在尝试使用元素数组来运行相同的测试以提供测试数据:
我在这里阅读:Looping on a protractor test with parameters
我正在尝试该解决方案,但是当我运行它时,甚至没有找到我的测试:
for(var i = 0; casos.length; i++){
(function(cotizacion){
it('obtener $1,230.00 de la cotizacion', function(){
browser.get('https://mifel-danielarias.c9users.io');
login(user,pass);
fillVidaCotizadorForm(formData);
//browser.sleep(5000);
var primaTotal = element(by.binding('vida.primaTotal'));
browser.wait(EC.visibilityOf(primaTotal),4000);
expect(primaTotal.getText()).toBe(cotizacion);
});
})(casos[i].Fallecimiento);
}
输出消息:
> [14:13:01] I/hosted - Using the selenium server at
> http://localhost:4444/wd/hub [14:13:01] I/launcher - Running 1
> instances of WebDriver Started
>
>
> No specs found Finished in 0.003 seconds
此循环在我的describe函数内部,如果我正常运行测试而没有任何循环,它将完美运行。
正如@OptimWorks在他的评论中提到的那样,数据驱动方法正是我所要的,并且此question提供了几个很好的答案。