1

I'm tring to do a code to send messages to a list of people in whatsapp to a list of people with selenium and chromedriver, but im getting this error:

C:\Users\Crist\Desktop\Whattsapp mama>prueba.py
Traceback (most recent call last):
  File "C:\Users\Crist\Desktop\Whattsapp mama\prueba.py", line 10, in <module>
    driver = webdriver.Chrome(r"C:\Users\Crist\Downloads\chromedriver\chromedriver.exe")
  File "C:\Users\Crist\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\Crist\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\Crist\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Crist\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Crist\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.19042 x86_64)

This is the code:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
contact = ["cristobal de toro", "cristobal", "gonzalo molina"]
text = "Hey, this message was sent using Selenium"
driver = webdriver.Chrome(r"C:\Users\Crist\Downloads\chromedriver\chromedriver.exe")
driver.get("https://web.whatsapp.com")
  • 1
    Please supply the expected [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) (MRE). We should be able to copy and paste a contiguous block of your code, execute that file, and reproduce your problem along with tracing output for the problem points. This lets us test our suggestions against your test data and desired output. We expect you to perform basic diagnosis to include with your post. At the very least, print the suspected values at the point of error and trace them back to their sources. – Prune Mar 19 '21 at 23:04
  • 2
    Does this answer your question? [WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome](https://stackoverflow.com/questions/50138615/webdriverexception-unknown-error-cannot-find-chrome-binary-error-with-selenium) – Gino Mempin Mar 20 '21 at 02:36
  • @Prune, i now did it, I eliminete all the code that was useless to reproduce de code – Cristobal Garcia Mar 20 '21 at 23:28

1 Answers1

0

Try that out, it might help with installing and setting correct path to chromedriver:

Install webdriver-manager package:

pip install webdriver-manager

and add that snipped to file:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())

instead of that line:

driver = webdriver.Chrome(r"C:\Users\Crist\Downloads\chromedriver\chromedriver.exe")
Vova
  • 3,117
  • 2
  • 15
  • 23
  • It worked, but now im getting a traceback: Traceback (most recent call last): File "C:\Users\Crist\Desktop\Whattsapp mama\prueba.py", line 19, in input_box_search = WebDriverWait(driver,50).until(lambda driver: driver.find_element_by_xpath(inp_xpath_search)) File "C:\Users\Crist\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: – Cristobal Garcia Mar 20 '21 at 23:21
  • And this error: DevTools listening on ws://127.0.0.1:55707/devtools/browser/0a28fb2b-e76b-4199-8780-603007fd8944 Scan QR Code, And then Enter [13760:4976:0320/201815.588:ERROR:device_event_log_impl.cc(214)] [20:18:15.589] USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection: Uno de los dispositivos conectados al sistema no funciona. (0x1F) [13760:4976:0320/201815.623:ERROR:device_event_log_impl.cc(214)] [20:18:15.624] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed. – Cristobal Garcia Mar 20 '21 at 23:21