Here is the code:
it('Verify Backup details if present', function(){
(profile_page.BPP_Contact_BackupDiv).isPresent().then(function(isVisible){
if (isVisible) {
expect((profile_page.BPP_Contact_Backup).getText()).toEqual("Backup:");
expect((profile_page.BPP_Contact_BackupData).getText()).not.toBe(null);
expect((profile_page.BPP_Contact_BackupData).getAttribute("href")).not.toBe(null);
} else{
console.log("BPP_Contact_BackupDiv Is not Displayed");
}
}, function(err) {
console.log("In Error");
console.log(err);
});
});
据我所知,这应该放在“如果”元素存在和“否则”如果元素不存在。 我正在关注页面对象模式并且 BPP_Contact_BackupDiv = element(by.css(我的元素标识符)); 当元素不存在时,此操作会失败。 我收到此错误: -错误:超时 - jasmine.Default_Timeout_Interval 未在超时规范内调用异步回调
我也在Before Each中尝试过这个:
beforeEach(function (done) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
setTimeout(function () {
console.log('inside timeout');
done();
}, 500);
});
最佳答案
如果您使用 browser.isElementPresent()
会怎么样?相反:
browser.isElementPresent(profile_page.BPP_Contact_BackupDiv).then(...)
关于node.js - 未找到元素时 Protractor "It"规范失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31680593/