0

I'm programming an autoreply scri pt and there is an error code that I don't quite understand

For context this is the code:

from selenium import webdriver
import time

browser = webdriver.Chrome()
browser.get("https://web.whatsapp.com/")
time.sleep(60) #time provided to sign you in on the wb app.

unreadMsgs = browser.find_elements_by_xpath(".//span[span[@class='unread-count icon-meta'] and 
not(span[@class='icon icon-meta icon-muted'])]")

if not unreadMsgs:
     print("Total unread messages: 0")
    else:
    print("Total unread messages: ")+ str(len(unreadMsgs))
    text = ""
    for msg in unreadMsgs:
        msg.click()
        time.sleep(5)
        browser.find_element_by_xpath(".//*[@id='main']/footer/div[1]/div[2]/div/div[2]").send_keys(text)
        time.sleep(2)
        browser.find_element_by_xpath(".//*[@id='main']/footer/div[1]/button").click()
        time.sleep(2)

I am using the modules:

beautifulsoup4==4.6.0
selenium==3.4.3

when I run the code I get this:

Traceback (most recent call last):
  File "D:\py hw\venv\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "D:\that python thing\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "D:\that python thing\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/py hw/autoreply.py", line 4, in <module>
    browser = webdriver.Chrome()
  File "D:\py hw\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "D:\py hw\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

how do I fix it?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

0 Answers0