Cannot locate element using Selenium Python


So I’m trying to locate this element and click it using Selenium. I’m using the following code:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[2]/div[2]/div/div/div[2]/div/div[2]/label/text() and contains(., 'Upload CSV')]"))).click()

I essentially just copied the XPATH of the ‘Upload CSV’ text.

Here’s a screenshot of the HTML:

Very new to Selenium/HTML so any help would be greatly appreciated!!


Try (adapt it to your EC condition):

driver.find_element(By.XPATH, "// label[contains(text(), 'Upload CSV')]")

Answered By – platipus_on_fire

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published