Im trying to build little helper for my work, which simulates human behaviour on the website via selenium.
My code works just fine, but one element on the website takes around 90 seconds to load and always fails to load. All I need on that particular webpage is to click a button once it appears and move on.
Is there a way to skip waiting for full page to download? The rest of the page loads in like 2-5 seconds, but this one bloody element...
Here is my code without any 'waits' applied
driver.get('https://power.dat.com/') post_trucks_button =
driver.find_element_by_xpath('/html/body/nav[2]/div[1]/div[2]/a[1]')
post_trucks_button.click()
And here is some things I tried, but none seemed to work:
###
wait = WebDriverWait(driver, 10)
element = wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="main"]/div/section[1]/div')))
###
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="main"]/div/section[1]/div')))
finally:
post_trucks_button = driver.find_element_by_xpath('/html/body/nav[2]/div[1]/div[2]/a[1]')
post_trucks_button.click()
###
wait = WebDriverWait(driver, 10)
men_menu = wait.until(ec.visibility_of_element_located((By.XPATH, '//[@id="main"]/div/section[1]/div')))
ActionChains(driver).move_to_element(men_menu).perform()
post_trucks_button = driver.find_element_by_xpath('/html/body/nav[2]/div[1]/div[2]/a[1]')
###
wait = WebDriverWait(driver, 10, poll_frequency=1, ignored_exceptions=[NoSuchElementException])element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="main"]/div/section[1]/div')))
post_trucks_button = driver.find_element_by_xpath('/html/body/nav[2]/div[1]/div[2]/a[1]')
post_trucks_button.click()
###
wait = WebDriverWait(driver, 10, poll_frequency=1, ignored_exceptions=[ElementNotVisibleException, ElementNotSelectableException])element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="main"]/div/section[1]/div')))
post_trucks_button = driver.find_element_by_xpath('/html/body/nav[2]/div[1]/div[2]/a[1]')
post_trucks_button.click()
###
P.S. all required modules are imported, just didnt include them above
P.S.S. I kinda have no idea what im doing, just started learning python