繁体   English   中英

尽管元素存在,Protractor 并未等待页面加载

[英]Protractor is not waiting for page to load though the element is present

  1. 我正在尝试使用 sendkeys 在文本框中输入 otp 但它不起作用。 我也尝试过使用 browser.waitForAngularEnabled(true) 但没有运气。
 element(by.css(".inputOtp > input")).sendKeys('909090');
  1. 通过使用 executescript,它在文本框中输入文本。

     browser.executeScript("document.querySelector(\".inputOtp > input\").value='909090'");
  2. 现在的问题是它不是单击同一页面上存在的继续按钮。

element(by.id('otp-verify-and-continue')).click()

在此处输入图像描述

我们在项目中这样写:

// Ensure element is loaded in DOM
browser.wait(EC.presenceOf(element.all(by.className(elementToFind)).first()), 60000);
expect(element.all(by.className(elementToFind)).first().isPresent()).toBe(true, 'the element is not presented at the page after Timeout');
// Find it
el = element.all(by.className(elementToFind)).first();
// Ensure it is displayed and do things
el.isDisplayed();
el.sendKeys(keysToSend);

等待按钮出现的最佳选择是browser.wait() 您应该在单击验证和继续按钮之前使用它。 请等待并检查可见性而不是存在)作为browser.wait(protactorObject.visibilityOf(element(by.id('otp-verify-and-continue'))),60000)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM