Jack
0
Q:

implicit wait

In Implicit wait, if WebDriver is not able to locate an element, it will
wait for a specified amount of time for the element to appear, before
throwing
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
Explicit wait is a type of wait , which is used to stop the execution 
till a specific condition is true;
We use WebDriverWait and ExpectedCondition classes of
Selenium web driver to implement explicit wait.
Implicit wait is general, explicit wait is applied for a particular instance
only. 
-driver.findElement(By.cssSelector(“input[name=‘firstname’]”));-
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(txtFirstname));


2
How many types of waits do you know in Selenium?
  There are 3 types of wait I use
    1- =Implicit Wait=
  - Implicit wait is triggered when driver is not able to find web element.
  - Driver will wait for the given time or until it finds the element.
  - If driver does not find web element, it will throw NoSuchElementException.

   2- =Explicit Wait=
- I use it when I want to wait for specific conditions or 
  specific web elements. 
    - Such as: elementIsClickable
    - elementIsDisplayed
    - titleIs...
       - To be able to use explicit wait:
       - You need to create instance of WebDriverWait class.
      WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
      wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a/h3")));
  
3- Thread.sleep
	I avoid to use it since it makes my test heavier and slower
0
How many types of waits do you know in Selenium?
  There are 3 types of wait I use
    1- =Implicit Wait=
  - Implicit wait is triggered when driver is not able to find web element.
  - Driver will wait for the given time or until it finds the element.
  - If driver does not find web element, it will throw NoSuchElementException.

   2- =Explicit Wait=
- I use it when I want to wait for specific conditions or 
  specific web elements. 
    - Such as: elementIsClickable
    - elementIsDisplayed
    - titleIs...
       - To be able to use explicit wait:
       - You need to create instance of WebDriverWait class.
      WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
      wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a/h3")));
  
3- Thread.sleep
	I avoid to use it since it makes my test heavier and slower
   
1
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.get("http://somedomain/url_that_delays_loading")
try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "myDynamicElement"))
    )
finally:
    driver.quit()
0
 1- =Implicit Wait=
  - Implicit wait is triggered when driver is not able to find web element.
  - Driver will wait for the given time or until it finds the element.
  - If driver does not find web element, it will throw NoSuchElementException.
0

New to Communities?

Join the community