进程结束,python中出现退出代码1错误

2024-04-26 05:08:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在预先设定的时间内自动化whatsapp消息。我使用pycharm ide。

参见示例代码

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)

我从here获取了这段代码

我将计算机中的chromedriver路径替换为C:\Users\public\chromedriver.exe但点击运行按钮后,它显示路径是错误的。

这是截图。

chrome driver location error on PC

你能告诉我为什么在位置正确的情况下发生这种情况吗?


Tags: ofthefromimportyourbydriverselenium

热门问题