使用python的Whatsapp自动化不起作用

问题描述 投票:0回答:1

我正在寻找

error in "user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))"
Error is: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[@title = "Major project"]"} 
(Session info: chrome=81.0.4044.92)

而组名存在。请帮我。(我在YouTube频道中找到了代码:获取设置Python)

from selenium import webdriver

driver = webdriver.Chrome('/home/rockie/Downloads/chromedriver')
driver.get('https://web.whatsapp.com/')

name = input('Enter the name of user or group : ')
msg = input('Enter your message : ')
count = int(input('Enter the count: '))

input('Enter anything after scanning QR code')

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

msg_box = driver.find_element_by_class_name('_1Plpp')

for i in range(count):
    msg_box.send_keys(msg)
    button = driver.find_element_by_class_name('_35EW6')
    button.click()
python-3.x selenium xpath automation whatsapp
1个回答
0
投票

[我认为,要找到组名,您可能需要向下滚动,这就是为什么当组名不在当前帧中时,selenium / python代码不会自行滚动以查找名称的原因。同样的问题..我也在寻找答案,请帮助..

© www.soinside.com 2019 - 2024. All rights reserved.