I have two questions related to waits. First, please explain to me what is the difference between the two methods of waiting
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID,
'twotabsearchtextbox')))
# and this
driver.implicitly_wait(20)
Note that I wrote a code to see the difference before I asked, but the difference was not clear to me The code you wrote
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import *
driver = webdriver.Chrome()
driver.set_window_position(-1200, 0)
driver.maximize_window()
driver.get("http://www.amazon.com/");
# driver.implicitly_wait(20)
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, 'twotabsearchtextbox')))
search = driver.find_element(By.ID, 'twotabsearchtextbox')
search.click()
search.send_keys('Laptop hp core i5')
The second question is that I sometimes see the WebDriverWait Method assigned to a variable, I mean like this:
element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, 'twotabsearchtextbox'))))
What is the difference?
I thought WebDriverWait just waits for the item to appear
and the driver.implicitly_wait(20)
function
Waiting for the page to load.
As for what happened to me, the two methods are waiting for the page to load