user2950720
user2950720

Reputation: 941

seleniumjs wait utill element is ready for input

my app is currently waiting for an iframe using isElementPresent then switching to it.

I am now having trouble on the iFrame itself, I need to wait until an input component is visible on the page and ready to accept keys however if the page loads slow its crashing the app (if the page loads fast it executes the key input on the iFrame component)

error message: ElementNotVisibleError: element not visible

Login.prototype.waitForIframeField = function(){
  var self = this;
  return this.driver.wait(function waitForInputField() {
    return self.driver.isElementPresent(self.page.usernameInputField.selector);
  }, this.config.driver.defaultTimeout);
}

I have also tried to use .findElement().isDisplayed() however it is also performing the same issue with no such element.

Upvotes: 1

Views: 412

Answers (1)

alecxe
alecxe

Reputation: 473893

There is a specific elementIsVisible built-in expected condition:

driver.wait(until.elementIsVisible(driver.findElement(self.page.usernameInputField.selector)));

Note that you might also improve your iframe wait by switching to ableToSwitchToFrame.

Upvotes: 1

Related Questions