selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable when clicking on an element using Selenium Python

前端 未结 4 1111
情深已故
情深已故 2020-11-22 15:29

I understand this question has been asked but I need some solution for this error:

 Traceback (most recent call last):
 File \"goeventz_automation.py\", line         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 16:19

    This error message...

    selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
    

    ...implies that the desired element was not interactable when you tried to invoke click() on it.

    A couple of facts:

    • When you initialize the Chrome browser always in maximized mode.
    • You can disable-extensions.
    • You need to disable-infobars as well.

    I have used the same xpath which you have constructed and you can use the following solution:

    • Code Block:

      from selenium import webdriver
      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.support import expected_conditions as EC
      from selenium.webdriver.common.by import By
      
      options = webdriver.ChromeOptions()
      options.add_argument("start-maximized");
      options.add_argument("disable-infobars")
      options.add_argument("--disable-extensions")
      driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
      driver.get("https://www.goeventz.com/")
      WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[@track-element='header-login']"))).click()
      
    • Browser Snapshot:

提交回复
热议问题