Skip to content
CodeKruPro

Set an implicit wait and read it back

Automation taskEasy-MediumAsked in: Accenture, BrowserStack, Capgemini, Cognizant, Infosys, TCS, Wipro

"What is an implicit wait, and what is its default?" Set it, find an element, and read the value back from the driver. The default is 0, which means a lookup fails at once when the element is not there yet.

Implicit Wait

An implicit wait tells WebDriver to poll the DOM for a specified amount of time when trying to find an element that is not immediately available.

driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(n));

Once set, it applies to all subsequent findElement() calls.

Task:

  1. Set an implicit wait of 5 seconds
  2. Navigate to https://testkru.com/Elements/TextFields
  3. Find the element with ID firstName
  4. Print whether the element was found
  5. Print the implicit wait value you set

Expected output:

Element found: true
Implicit wait set: 5 seconds