Using Python Selenium Not able to perform click operation



  • I am automating for the following page on CHROME Browser

    https://study.yupl.us/studies/5d5a64aa8b5bb92fb776753b?auth=false
    

    Here I'm able to identify the unique element from the console for the XPATH used

    $x('//button[text()="START STUDY"]')
    

    But when the same code is integrated with the script and run.

    Integrated Script -

    from selenium.webdriver import Chrome
    
    driver = Chrome('/Users/downloads/chromedriver')
    driver.get('https://study.yupl.us/studies/5d5a64aa8b5bb92fb776753b?auth=false')
    driver.maximize_window()
    
    sleep(8)
    driver.find_element_by_xpath('//button[text()="START STUDY"]').click()
    

    I get the following error

    Traceback (most recent call last):
      File "/Users/PycharmProjects/Practice/t.py", line 54, in <module>
        driver.find_element_by_xpath('//button[text()="START STUDY"]').click()
      File "/Users/PycharmProjects/Study/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
        self._execute(Command.CLICK_ELEMENT)
      File "/Users/PycharmProjects/Study/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
        return self._parent.execute(command, params)
      File "/Users/PycharmProjects/Study/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
        self.error_handler.check_response(response)
      File "/Users/PycharmProjects/Study/venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
        raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button class="ui button" role="button" style="background-color: rgb(31, 186, 238); color: white; border-radius: 0px; padding-left: 40px; padding-right: 40px; font-family: &quot;Open Sans&quot;; font-size: 17px; font-weight: 600; line-height: 20px; text-align: center; width: 200px; height: 50px; margin-top: 26px;">...</button> is not clickable at point (1047, 320). Other element would receive the click: <div>...</div>
      (Session info: chrome=76.0.3809.132)
    

    I have tried to click on the element using the ActionChains class as well. Even then the same issue is got



  • Try using JavaScriptExecutor

    C#

    IWebElement element = driver.FindElement(By.XPath("//button[@role='button']"));
    IJavaScriptExecutor jse2 = (IJavaScriptExecutor)driver;
    jse2.ExecuteScript("arguments[0].click()", element);
    

    Python

    element = driver.find_element_by_xpath("//button[@role='button']")
    driver.execute_script("arguments[0].click();", element)
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2