I have a page that loads an iframe, but I get NoSuchElementError
error messages.
My code:
driver.wait(until.ableToSwitchToFrame(0)).then((d) => {
//*** SLEEP HERE
const button = By.css(".button");
driver.wait(until.elementLocated(dropdownElem)).then((btn) => {
btn.click();
});
});
First I switch to the correct iframe, then I try to wait for the element to load inside the iframe.
If I insert a driver.sleep(1000);
to the line //*** SLEEP HERE
it works, otherwise it fails with:
NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":".button"
}
Why doesn't the driver.wait
line waits for the element to become available?