简体   繁体   中英

I am getting error while running this python code. The error is “ElementNotInteractableException”. Can any on help me out?

I want to open student login from this website: https://exams.mlrinstitutions.ac.in/ open website-->click on 'Logins'-->click on 'Student Login'

This code is working fine up to the opening and clicking Logins. But when the code clicks on 'Student Login' it is encountering an error.

For HTML code please open the webpage and use inspect elements.

CODE

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

path = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(executable_path=path)
driver.get("https://exams.mlrinstitutions.ac.in/")

first = WebDriverWait(driver, 60).until(
    EC.presence_of_element_located((By.ID, "lnkLogins"))
)
first.click()

first = WebDriverWait(driver, 60).until(
    EC.presence_of_element_located((By.ID, "lnkStudent"))
)
first.click()

ERROR

DevTools listening on ws://127.0.0.1:55873/devtools/browser/0977ccf6-90ba-4f79-b746-e8ff53bd4035
Traceback (most recent call last):
  File "c:\Users\dile2\OneDrive\Desktop\mini\sel.py", line 19, in <module>
    first.click()
  File "C:\Users\dile2\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Users\dile2\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
[13984:14080:0210/201137.350:ERROR:device_event_log_impl.cc(211)] [20:11:37.349] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
  File "C:\Users\dile2\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\dile2\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=88.0.4324.150)

Instead of presence_of_element_located() use element_to_be_clickable()

driver.get("https://exams.mlrinstitutions.ac.in/")

first = WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.ID, "lnkLogins")))
first.click()

first = WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.ID, "lnkStudent")))
first.click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM