Categories
JavaScript Answers

How to wait till element is displayed with Node Selenium WebDriver?

Spread the love

To wait till element is displayed with Node Selenium WebDriver, we use the wait method.

For instance, we write

const el = await driver.findElement(By.id(`import-file-acqId:${acqId}`));
await driver.wait(until.elementIsVisible(el), 100);
await el.sendKeys(file);

to call findElement with By.id(import-file-acqId:${acqId}) to find the element by ID.

Then we call wait with until.elementIsVisible(el) to wait for the element.

The timeout is set to 100ms.

Then we call sendKeys to press a key.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.