Traceback (most recent call last): File "D:\pythonsthl\flaskProject\SeleniumTest\24Test111.py", line 31, in <module> element = driver.find_element(By.XPATH,'//*[@id="app"]/div[1]/div[2]/div[2]/div/form/div[2]/div/div/div/span').send_keys('Sitonholy@2021') File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 231, in send_keys self._execute( File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 395, in _execute return self._parent.execute(command, params) File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute self.error_handler.check_response(response) File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=115.0.5790.99) Stacktrace: Backtrace: GetHandleVerifier [0x00FAA813+48355] (No symbol) [0x00F3C4B1] (No symbol) [0x00E45220] (No symbol) [0x00E6D046] (No symbol) [0x00E6C8B1] (No symbol) [0x00E8A73C] (No symbol) [0x00E69A36] (No symbol) [0x00E8AA94] (No symbol) [0x00E9C922] (No symbol) [0x00E8A536] (No symbol) [0x00E682DC] (No symbol) [0x00E693DD] GetHandleVerifier [0x0120AABD+2539405] GetHandleVerifier [0x0124A78F+2800735] GetHandleVerifier [0x0124456C+2775612] GetHandleVerifier [0x010351E0+616112] (No symbol) [0x00F45F8C] (No symbol) [0x00F42328] (No symbol) [0x00F4240B] (No symbol) [0x00F34FF7] BaseThreadInitThunk [0x76227D59+25] RtlInitializeExceptionChain [0x76F9B79B+107] RtlClearBits [0x76F9B71F+191] Process finished with exit code 1
时间: 2023-10-08 08:03:57 浏览: 263
这个错误是由于元素无法与`send_keys`方法进行交互导致的。可能有以下几个原因:
1. 元素可能处于不可见的状态。您可以尝试使用`WebDriverWait`等待元素可见后再进行操作。
```python
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# ...
element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/form/div[2]/div/div/div/span')))
element.send_keys('Sitonholy@2021')
```
2. 元素可能被其他元素遮挡。您可以尝试使用`ActionChains`类模拟鼠标操作来激活元素。
```python
from selenium.webdriver import ActionChains
# ...
element = driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/form/div[2]/div/div/div/span')
actions = ActionChains(driver)
actions.move_to_element(element).click().send_keys('Sitonholy@2021').perform()
```
请根据实际情况尝试以上解决方法,希望能帮助您解决问题。
阅读全文