简体   繁体   English

引发TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException:消息:

[英]raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

I'm trying to use WhatsApp via python following the below code, but I'm receiving the following error: raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: 我正在尝试按照以下代码通过python使用WhatsApp,但收到以下错误: raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:跟踪raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

Is there something wrong with the code, or something that I'm missing here? 代码是否有问题,或者我在这里缺少什么? Could some one please help me here in fixing this and how do I send auto-reply using python scrips in WhatsApp. 有人可以帮我解决这个问题,以及如何在WhatsApp中使用python脚本发送自动回复。

Thank you for the help. 感谢您的帮助。

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('/home/saket/Downloads/chromedriver')

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 = '"Friend\'s Name"'

# Replace the below string with your own message
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)

You can handle that exception, 您可以处理该异常,

from selenium.common.exceptions import TimeoutException

try:
    driver.get("https://web.whatsapp.com/")
except TimeoutException:
    # You can write retry code here

I hope this helps. 我希望这有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: 消息: - TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: 引发TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException:消息:使用Selenium Python - raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: using Selenium Python 引发 TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException:消息:断言失败 - raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: for send whatsapp to all conatcts - raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: for sending whatsapp to all conatcts 引发 TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException:消息 - raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message 元素不可见。 引发TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException - Element is not visible. raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException Python selenium:超时异常(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException:消息: - Python selenium : TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: 消息:selenium.common.exceptions.TimeoutException - Message: selenium.common.exceptions.TimeoutException selenium.common.exceptions.TimeoutException:消息: - selenium.common.exceptions.TimeoutException: Message: 错误:selenium.common.exceptions.TimeoutException:消息: - error: selenium.common.exceptions.TimeoutException: Message:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM