python报错:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
1.经查不是chromdriver版本的问题
1.经查不是chromedriver版本的问题
2.代码没有问题,检查网络是否流畅
3.网络慢,页面未加载完成,元素找不到
4.解决方案,可以在访问url后面加几秒等待
例如:
driver = webdriver.Chrome()
driver.get("http://10.165.153.7")
time.sleep(5) # 添加3s等待网页加载完成,再进行下面的元素定位
E:\pythonProject\study\venv\Scripts\python.exe "D:\Program Files\JetBrains\PyCharm 2020.3.2\plugins\python\helpers\pycharm\_jb_unittest_runner.py" --path E:/pythonProject/1890_1/common/threeweb/test_login.py
Testing started at 16:34 ...
Launching unittests with arguments python -m unittest E:/pythonProject/1890_1/common/threeweb/test_login.py in E:\pythonProject\1890_1\common\threeweb
Error
Traceback (most recent call last):
File "D:\App\Python\Python39\lib\unittest\case.py", line 59, in testPartExecutor
yield
File "D:\App\Python\Python39\lib\unittest\case.py", line 593, in run
self._callTestMethod(testMethod)
File "D:\App\Python\Python39\lib\unittest\case.py", line 550, in _callTestMethod
method()
File "E:\pythonProject\1890_1\common\threeweb\test_login.py", line 21, in test_login
driver.find_element(By.XPATH, "//input[@placeholder='请输入用户名']").send_keys("admin")
File "E:\pythonProject\study\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 477, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT,
File "E:\pythonProject\study\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "E:\pythonProject\study\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "E:\pythonProject\study\venv\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=89.0.4389.114)
Assertion failed
Ran 1 test in 4.354s
FAILED (errors=1)
Process finished with exit code 1
Assertion failed
Assertion failed