量角器必须验证错误消息是否存在于页面中。所以错误信息可以在“alert-message”类或“fail-heading”类中。在页面显示后如何查找元素是否存在
如果我喜欢下面,它只有在显示alert-message className时才会成功。但有时候我把className当作“失败标题”。
var waitforele_confirmation = by.className('alert-message');
browser.wait(function(){return browser.driver.isElementPresent(waitforele_confirmation)}, 60000);
expect(browser.driver.isElementPresent(waitforele_confirmation)).toBeTruthy();
所以我想动态检查页面加载后存在哪个元素。另外我想在等待每个元素时使用browser.wait函数。我只是做了下面的伪代码来理解。
while (i<120 and !found)
{
int i=0;
if (element(by.className('alert-message')).isPresent())
{
found = true;
}
else if (element(by.className('fail-heading')).isPresent())
{
found = true;
}
else
{
browser.sleep(500);
}
i++;
}
有人可以转换量角器pls中的伪代码吗?
工作完美。谢谢。 –