简体   繁体   English

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

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

  1. I am trying to enter otp in the text box by using sendkeys but it is not working.我正在尝试使用 sendkeys 在文本框中输入 otp 但它不起作用。 I have also tried by using browser.waitForAngularEnabled(true)but no luck.我也尝试过使用 browser.waitForAngularEnabled(true) 但没有运气。
 element(by.css(".inputOtp > input")).sendKeys('909090');
  1. By using executescript it is entering text in the textbox.通过使用 executescript,它在文本框中输入文本。

     browser.executeScript("document.querySelector(\".inputOtp > input\").value='909090'");
  2. Now the problem is it is not click on continue button which is present on the same page.现在的问题是它不是单击同一页面上存在的继续按钮。

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

在此处输入图像描述

We wrote it in our project:我们在项目中这样写:

// 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);

The best option to wait for the button presence is browser.wait() .等待按钮出现的最佳选择是browser.wait() You should use it before clicking the verify and Continue Button.您应该在单击验证和继续按钮之前使用它。 ( Do wait and check for visibility instead of Presence ) as browser.wait(protactorObject.visibilityOf(element(by.id('otp-verify-and-continue'))),60000) 请等待并检查可见性而不是存在)作为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