使用 python 在 whatsapp 中发送自动消息时出错

Error in texting automated message in whatsapp using python

我的代码是(从 geeksforgeeks 学习的):

#!/usr/bin/python
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
# Replace below path with the absolute path
# to chromedriver in your computer
driver = webdriver.Chrome('C:\webdriver\chromedriver.exe')
driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 600)
# Replace 'Friend's Name' with the name of your friend
# or the name of a group
target = "Rahul Mehta"
# Replace the below string with your own message
string = "Hi"
y_arg = '//*[@id="side"]/div[2]/div/label/input'
input_y = wait.until(EC.presence_of_element_located((By.XPATH, y_arg)))
input_y.send_keys(target + Keys.ENTER)
inp_xpath = '//*[@id="main"]/footer/div[1]/div[1]/div/div[2]'
input_box = wait.until(EC.presence_of_element_located((By.XPATH,inp_xpath)))
for i in range(2):
  input_box.send_keys(string + Keys.ENTER)
  time.sleep(1)

我得到的错误是:

[1436:4360:1017/202620.286:ERROR:shader_disk_cache.cc(237)] Failed to create 
shader cache entry: -2

当我增加范围时,我在命令提示符中重复出现相同的错误。浏览器被打开,然后它甚至搜索我朋友的名字,但最终它没有发送消息。请帮助 me.I 几乎浪费了一整天的时间,但不知道如何进一步进行:(

我也面临同样的问题,我得出的结论是,实际上,对于每个新版本,whatsapp 都会改变编写代码的方式来自动化 HTML 代码,你必须检查新版本HTML 的语法。现在我想出的是这个我不知道什么时候这段代码会有效但是现在,它工作正常。

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


driver = webdriver.Chrome(r'F:/chrome driver/chromedriver.exe')

driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 600)

target = '"friend\'s name"'

string = "your message"

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="pluggable-input-body copyable-text selectable-text"][@dir="auto"][@data-tab="1"]'
input_box = wait.until(EC.presence_of_element_located((
    By.XPATH, inp_xpath)))

for i in range(10):
    input_box.send_keys(string + Keys.ENTER)