Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行此python代码时出现错误。错误是;ElementNotInteractiableException";。有人能帮我吗?_Python_Python 3.x_Selenium_Selenium Webdriver_Webautomation - Fatal编程技术网

运行此python代码时出现错误。错误是;ElementNotInteractiableException";。有人能帮我吗?

运行此python代码时出现错误。错误是;ElementNotInteractiableException";。有人能帮我吗?,python,python-3.x,selenium,selenium-webdriver,webautomation,Python,Python 3.x,Selenium,Selenium Webdriver,Webautomation,我想从该网站打开学生登录: 打开网站-->单击“登录”-->单击“学生登录” 此代码在打开并单击登录之前工作正常。但是当代码点击“学生登录”时,它遇到了一个错误 对于HTML代码,请打开网页并使用inspect元素 代码 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from sel

我想从该网站打开学生登录: 打开网站-->单击“登录”-->单击“学生登录”

此代码在打开并单击登录之前工作正常。但是当代码点击“学生登录”时,它遇到了一个错误

对于HTML代码,请打开网页并使用inspect元素

代码

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()
错误

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)
DevTools在ws://127.0.0.1:55873/DevTools/browser/0977ccf6-90ba-4f79-b746-e8ff53bd4035上侦听
回溯(最近一次呼叫最后一次):
文件“c:\Users\dile2\OneDrive\Desktop\mini\sel.py”,第19行,在
首先,点击()
文件“C:\Users\dile2\Python39\lib\site packages\selenium\webdriver\remote\webelement.py”,第80行,单击
self.\u执行(命令。单击\u元素)
文件“C:\Users\dile2\Python39\lib\site packages\selenium\webdriver\remote\webelement.py”,第633行,在\u execute中
返回self.\u parent.execute(命令,参数)
[13984:14080:0210/201137.350:错误:设备\u事件\u日志\u impl.cc(211)][20:11:37.349]USB:USB\u设备\u句柄\u win.cc:1049未能从节点连接读取描述符:连接到系统的设备未正常工作。(0x1F)
文件“C:\Users\dile2\Python39\lib\site packages\selenium\webdriver\remote\webdriver.py”,第321行,在execute中
self.error\u handler.check\u响应(响应)
文件“C:\Users\dile2\Python39\lib\site packages\selenium\webdriver\remote\errorhandler.py”,第242行,在check\u响应中
引发异常类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.ElementNotInteractiableException:消息:元素不可交互
(会话信息:chrome=88.0.4324.150)

使用
元素可点击(),而不是
元素的存在()


非常感谢,昆都克。我花了大约10个小时来解决这个问题,但你在第二秒内就解决了!!!如果您不介意,我可以知道它们之间的区别吗?@dileepNaidu:
presence\u of\u element\u located()
验证DOM树中存在但不可交互的元素。一旦元素可见,您就可以与该元素交互,并使用
元素可点击()
。明白了!谢谢你,昆都克。
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()