gpt4 book ai didi

python - Selenium send_keys() 消息 : element not interactable

转载 作者:行者123 更新时间:2023-12-04 17:26:47 28 4
gpt4 key购买 nike

from selenium import webdriver
import time
import os, time

driver = webdriver.Chrome(executable_path=r"C:\Users\carlo\OneDrive\Escritorio\chromedriver.exe")
driver.get("https://web.whatsapp.com/")

time.sleep(10)

name = 'me'

user = driver.find_elements_by_xpath('//span[@title = "{}"]'.format(name))[0]
user.click()

msj_box = driver.find_element_by_xpath('//div[@class="_2FbwG"]')
msj_box.send_keys('la caja')
msj_box = driver.find_element_by_xpath('//button[@class="_1U1xa"]')
msj_box.click()

运行以下行时出现问题

msj_box.send_keys('la caja')

输出是这样的

 File "c:/Users/carlo/OneDrive/Escritorio/wp3.py", line 23, in <module>
msj_box.send_keys('la caja')
File "C:\MIS programas\python\lib\site-packages\selenium\webdriver\remote\webelement.py", line 477, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT,
File "C:\MIS programas\python\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\MIS programas\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\MIS programas\python\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=83.0.4103.116)

请帮忙

最佳答案

您收到错误的原因似乎是因为您将 SendKeys 方法与 Div 元素一起使用,而不是用于输入或文本区域。

msj_box = driver.find_element_by_xpath('//div[@class="_2FbwG"]')

关于python - Selenium send_keys() 消息 : element not interactable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62702419/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com