How can we use Explicit wait with Python Selenium Webdriver?

0 votes
How can we use Explicit wait with Python Selenium Webdriver?
Jul 23 in Selenium by Aryan
28 views

1 answer to this question.

0 votes

Hi Aryan, Explicit wait is used with WebDriverWait which can be applied to any element with a condition and a timeout. It throws an exception if the condition is not met or a timeout occurs. Following example shows how to implement Explicit Wait in Python Selenium:

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from pip._vendor.distlib import resources
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.get("https://www.facebook.com/")
timeout = 10

try:
    element_present = EC.presence_of_element_located((By.LINK_TEXT, 'Sitemap'))
    WebDriverWait(driver, timeout).until(element_present)
except TimeoutException:
    print("Timed out while waiting for page to load")
driver.quit()
answered Jul 29 by Abha
• 19,440 points

Related Questions In Selenium

0 votes
1 answer

How can we use Selenium with Python?

First  Install Python based on the Operating ...READ MORE

answered May 7, 2018 in Selenium by Meci Matt
• 9,400 points
57 views
0 votes
1 answer
0 votes
1 answer

Impilicit wait vs Explicit wait vs Fluent wait

Implicit wait: Your telling the WebDriver the ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,610 points
700 views
0 votes
1 answer

Implicit wait & Explicit wait in selenium WebDriver

Implicit Wait:  While loading a web page in ...READ MORE

answered May 24, 2018 in Selenium by Meci Matt
• 9,400 points
147 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
413 views
0 votes
1 answer
0 votes
1 answer

How can I download Microsoft WebDriver/Edge Driver to use with Selenium?

Hi William, to download Microsoft Webdriver or ...READ MORE

answered Jul 15 in Selenium by Abha
• 19,440 points
48 views