Cannot click an element , Selenium Python

Viewed 38

with selenium, i'm trying to click an element but not working with this element, the page is here page (username/password :admin/admin)

enter image description here

wait2 = WebDriverWait(driver, 10)
element = wait2.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="operate2a5a0448a8bf44a8898ec13e95b152fc"]/div/div[2]')))
element.click()

i tried this on other element in the same page and got no problem

no idea why not working on this element

2 Answers

operate2a5a0448a8bf44a8898ec13e95b152fc seems to be dynamically created id.
The simplest way to access this element is with text based XPath locator:

wait2.until(EC.element_to_be_clickable((By.XPATH, "//div[contains(text(),'Entry Registration')]"))).click()

you can try with below code as well :

//img[contains(@src,'registration')]/..

in code :

wait2 = WebDriverWait(driver, 10)
element = wait2.until(EC.element_to_be_clickable((By.XPATH, "//img[contains(@src,'registration')]/..")))
element.click()
Related