-1
我試圖在預設時間內自動化whatsapp消息。我使用pycharm ide。在Python中退出代碼1錯誤的進程已完成
查看示例代碼,
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:\用戶\公用\ chromedriver.exe但點擊運行後,按鈕它顯示路徑是錯誤的。
下面是截圖。
chrome driver location error on PC
你能告訴我,爲什麼出現這種情況,雖然位置是正確的?
請閱讀[問]瞭解爲什麼張貼代碼/錯誤消息的截圖是不好的。同時發佈產生錯誤的_actual_代碼 - 讓別人儘可能地幫助你。現在有人願意幫助,必須複製代碼,編輯更改內容,查看錯誤屏幕截圖,再次手動鍵入更改以達到可以重現錯誤的地步。 –
此外,快速搜索SO上的錯誤會給你帶來類似問題的多個問題,例如, http://stackoverflow.com/questions/18276283/python-open-file-unicode-error –