Cannot locate element using Selenium Python
Question:
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!!
Answers:
Try this:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='bulk-upload-buttons/label and contains(., 'Upload CSV')]"))).click()
Try (adapt it to your EC condition):
driver.find_element(By.XPATH, "// label[contains(text(), 'Upload CSV')]")
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 this:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='bulk-upload-buttons/label and contains(., 'Upload CSV')]"))).click()
Try (adapt it to your EC condition):
driver.find_element(By.XPATH, "// label[contains(text(), 'Upload CSV')]")