【问题标题】:I can't send WhatsApp message using Selenium :/ with these error [duplicate]我无法使用 Selenium 发送 WhatsApp 消息:/ 出现这些错误 [重复]
【发布时间】: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


    【解决方案1】:

    我看到您正在执行以下操作:

    driver = webdriver.Chrome('chromedriver.exe')

    如果您不想指定位置,请使用以下内容,因为您现在可能不知道它所在的位置:

    driver = webdriver.Chrome()

    您的 chrome 是否在您的 D、F 等驱动器中?

    例子:

    driver = webdriver.Chrome("F:\\chromedriver.exe")

    【讨论】:

    • 这应该给出一个不同的错误。关于chromedriver 不在 PATH 中的问题
    • 可以忽略此错误,但在大多数情况下,webdriver 的路径不正确。我发现了一个类似的线程:stackoverflow.com/questions/64927909/…
    猜你喜欢
    • 2021-12-10
    • 2022-08-18
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    • 2017-02-04
    • 1970-01-01
    相关资源
    最近更新 更多