Explain implicit wait in Selenium webdriver in Python.

SeleniumAutomation TestingTesting Tools

An implicit wait is applied to instruct the webdriver for polling the DOM(Document Object Model) for a specific amount of time while making an attempt to identify an element that is currently unavailable.

The default value of the implicit wait time is 0. Once a wait time is set, it remains applicable throughout the entire life of the webdriver object. If an implicit wait is not set and an element is still not present in DOM, an exception is thrown.

Syntax

driver.implicitly_wait(5)

Here, a wait time of five seconds is applied to the webdriver object.

Example

Code Implementation

from selenium import webdriver
#set path of chromedriver.exe
driver = webdriver.Chrome(executable_path='../drivers/chromedriver')
#implicit wait of 0.5s
driver.implicitly_wait(0.5)
#url launch
driver.get("https://www.tutorialspoint.com/about/about_careers.htm")
#identify link with link text
l = driver.find_element_by_link_text('FAQ')
#perform click
l.click()
print('Page navigated after click: ' + driver.title)
#driver quit
driver.quit()

Output

raja
Published on 19-Nov-2021 11:34:29
Advertisements