1

I want to essentially "click" a button on a webpage using python. I am trying to use the selenium package (as seen in this example how_can_i_essentially_click_a_button_on_a_webpage/) but then I get the following message right after running the code:

I really don't understand what's going on. I would appreciate any help if possible.

from selenium import webdriver
browsre = webdriver.Chrome()
Traceback (most recent call last):
  File "C:\Users\pablo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\pablo\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\pablo\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    browsre = webdriver.Chrome()
  File "C:\Users\pablo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\pablo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, 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
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Irving Lee
  • 13
  • 3

2 Answers2

1

Where is your chromedriver.exe located? Is it located in the path that is specified in yours tests?

Try this in your code:

 browser = webdriver.Chrome('/path/to/chromedriver') 
Siva
  • 113
  • 1
  • 16
0

Looking into

'chromedriver' executable needs to be in PATH

it seems that your script is not able to find the chromedriver.exe under PATH so you need to add the folder, containing the chromedriver.exe to your system PATH

enter image description here

If you're running your test via PyCharm you can do the same in Run/Debug configurations:

enter image description here

and last, but not the least, you can amend the driver initialization line to contain the full path to your chromedriver.exe

driver = webdriver.Chrome("c:\\path\\to\\chromedriver.exe")

References:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133