-1

I'am trying to automate whatsapp messages in pre-set time. I use pycharm ide.

See the sample code,

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)

I took this code from here

I replaced the chromedriver path in my computer to C:\Users\public\chromedriver.exe but after hit the run button It shows the path is error.

Here's the screenshot.

chrome driver location error on PC

Can you tell me why that happens though the location is correct?

2
  • Please read How to Ask to understand why posting screenshots of code/error messages is bad. Also post the actual code that produced the error - make it as easy for someone to help you as possible. Right now someone willing to help would have to copy your code, edit in your changes, have a look at the screenshot of the error, manually type in the changes again to get to the point where you can reproduce the error. Commented Apr 27, 2017 at 8:13
  • Also a quick search of the error here on SO would have given you multiple questions with similar problems, e.g. stackoverflow.com/questions/18276283/… Commented Apr 27, 2017 at 8:15

1 Answer 1

1

Your screenshot of the error message (Don't do that! Post text!) shows different source code than the one you have posted.

You have to escape the \ in your path, so C:\Users should be C:\\Users.

Sign up to request clarification or add additional context in comments.

1 Comment

Sure Christian I'm new to stack overflow and thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.