Some elements may not exist in the page, but I have to wait 30 seconds, which makes me very distressed, because I have to find many elements that may not exist. Therefore, the problem of how to modify the default 30-second element that cannot be found has been bothering me.
Is this default wait time related to the selenium package?
WebDriverWait(driver,5).until(EC.presence_of_element_located((By.XPATH, '//input[@qtype="302"]')))
WebDriverWait(driver,5).until(EC.presence_of_all_elements_located((By.XPATH, '//input[@qtype="302"]')))
But they didn't meet my expectation of waiting ten seconds
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import perf_counter
driver = webdriver.Chrome()
driver.get(‘xxx')
driver.implicitly_wait(10)
try:
start = perf_counter()
dLfy_topic = WebDriverWait(driver,5).until(EC.presence_of_all_elements_located((By.XPATH, '//input[@qtype="302"]')))
except:
during = perf_counter() - start
print(during)
finally:
if during > 10:
print("You failed")
else:
print("You are successful")
30.53863444600001 You failed
I wish I had waited ten seconds instead of thirty!
30.53863444600001 You failed
exactly? – DebanjanB