【发布时间】:2018-01-04 08:20:12
【问题描述】:
在网站上,我有时会在表单中添加用于恢复自动保存数据的附加按钮,该按钮会随机弹出(有时有人测试某些内容并关闭表单,这会导致弹出按钮)。我尝试使用Continue if element is not visible in protractor 使用以下代码:
let DoNotRefillBtn=element.all(by.className('modal-button-no'));
var isApproachable = function(element) {
return element.isPresent().then(function (present) {
return present
? element.isDisplayed()
: false;
});
};
describe(...)
it('Open the form:', function () {
browser.driver.get('foo');
browser.sleep(1000);
isApproachable(DoNotRefillBtn).then(function(approachable) {
if (approachable) {
DoNotRefillBtn.click();
browser.sleep(500);
}
else {
browser.sleep(300);
}
});
点击正确,但点击后,在DoNotRefillBtn.click();行抛出错误Failed: element not visible。
为什么程序点击并抛出一个东西不可点击的错误(点击后)?
【问题讨论】:
-
我不确定,但
return present ? element.isDisplayed() : false;看起来很臭。它返回<Promise>或boolean。 -
我有这个问题:stackoverflow.com/questions/36201154/… 并返回布尔值
标签: jasmine protractor