我有一个问题,我需要等到组件显示在屏幕上,有时组件延迟太久无法显示。我需要等到某个字段或变量变为真。有人知道怎么做吗?
element(by.id('nextStage-button')).isPresent().then(function (visible) {
let i = 0;
while (visible !== true){
browser.sleep(2000);
console.log("test "+ i++);
if(visible === true){
break;
}
}
最佳答案
考虑使用 Expected Conditions .
你可以这样做:
const EC = protractor.ExpectedConditions;
const nextStageButton = $('#nextStage-button');
browser.wait(EC.visibilityOf(nextStageButton), 3000);
// do whatever you wanted to do once it's visible
关于javascript - Protractor :我需要等到组件显示在屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51678249/