【发布时间】:2021-03-06 12:01:28
【问题描述】:
运行 Selenium 自动化时出错
我无法完全运行我的项目,因为它在呈现 web.whatsapp.com 后不久就显示错误
这是我的代码
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome('chromedriver.exe')
driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 600)
target = '"D@D"'
string = "Message sent using Python!!!"
x_arg = '//span[contains(@title,' + target + ')]'
group_title = wait.until(EC.presence_of_element_located((
By.XPATH, x_arg)))
group_title.click()
inp_xpath = '//div[@class="input"][@dir="auto"][@data-tab="1"]'
input_box = wait.until(EC.presence_of_element_located((
By.XPATH, inp_xpath)))
for i in range(100):
input_box.send_keys(string + Keys.ENTER)
time.sleep(1)
以下是错误:/
DevTools listening on ws://127.0.0.1:7568/devtools/browser/4166a9d5-5e52-4d35-98da-769f457998e7
[17452:12364:1123/234409.011:ERROR:device_event_log_impl.cc(211)] [23:44:09.012] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node
connection: A device attached to the system is not functioning. (0x1F)
[17452:12364:1123/234409.041:ERROR:device_event_log_impl.cc(211)] [23:44:09.041] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node
connection: A device attached to the system is not functioning. (0x1F)
在网上找不到任何其他解决方案
谢谢
【问题讨论】:
标签: python selenium selenium-webdriver message whatsapp