1

Due to random loading times of the website that I'm working with, I have to wait for certain html elements to appear in order to work with them. I ve used the time.sleep command for testing purposes, but wanna optimize everything now. I ve tried various explicit wait suggestions from the web but all of them collided at some point.

Here is a code example:

folder = driver.find_element_by_xpath("//button[@id='submit']")
folder.click()
time.sleep(6)
folder = driver.find_element_by_xpath("//button[@ngbtooltip='Create New Project']")
folder.click()

Thanks in advance guys!

1 Answers1

-1

stackoverflow.com/a/26567563/10306224 Had a working solution. Here is the code example with header:

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
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
timeout = 10
driver.get("https://yoururl.com/")

folder = driver.find_element_by_xpath("//button[@id='submit']")
folder.click()
element_present = EC.presence_of_element_located((By.XPATH, "//button[@ngbtooltip='Create New Project']"))
WebDriverWait(driver, timeout).until(element_present)

folder = driver.find_element_by_xpath("//button[@ngbtooltip='Create New Project']")
folder.click()

I think that XPATH was my problem.