Search code examples
pythonselenium-webdriverselenium-chromedriverpytest

Selenium Python Element Click Intercepted


I'm trying to run a test in Selenium Webdriver Python, but I got an error saying as on the screenshot:

enter image description here

this is the xpath for the register button: //button[@class='tutor-btn tutor-btn-primary']

What I tried so far:

setup.find_element("xpath", "//button[@class='tutor-btn tutor-btn-primary']").click()

and

setup.find_element("xpath", "//button[@type='submit' and (contains(@class,'tutor-btn tutor-btn-primary')) and(contains(text(),'Register'))]").click()

but none works, any solution?


Solution

  • Element click intercepted indicates that some other element is obstructing selenium to perform the click() on the desired element.

    And that obstructing element is Accept Cookies window.

    enter image description here

    As soon as you open the application, just add below line and get rid of the cookies window. It should be fine:

    driver.get("https://langsungkerja.id/registration/")
    driver.maximize_window()
    # below line will accept cookies
    driver.find_element(By.XPATH, "//button[text()='Accept All']").click()