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!!
CodePudding user response:
Try (adapt it to your EC condition):
driver.find_element(By.XPATH, "// label[contains(text(), 'Upload CSV')]")
CodePudding user response:
Try this:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='bulk-upload-buttons/label and contains(., 'Upload CSV')]"))).click()
CodePudding user response:
I figured it out. This code ran successfully:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "// label[contains(text(),\'Upload CSV')]"))).click()
Resource used: Python Selenium – Find element by text
Thanks so much for your contributions!