I am trying to click a button using selenium so I made it find the element with the xpath since i couldn\'t find the id . EDIT: I didn\'t think the rest of the code had anyt
You need to take care of a couple of things:
While passing the absolute location of chromedriver binary use a single forward slash along with the raw i.e. r
switch. So the effective line of code will be:
driver = webdriver.Chrome(executable_path=r'C:\chromedriver.exe')
Execute your @Test
as non-administrator / non-root user.
Another possible reason is Chrome is not installed in the default location as per the specification:
There can be two approaches to solve this situation:
Use binary_location
property to point to the chrome binary location.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe", )
driver.get('http://google.com/')
you have to edit
driver = webdriver.Chrome(executable_path="C:\chromedriver.exe")
to
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
you miss \
If you get the same error, try running as administrator
or
move chromedriver.exe
to other path like c:/seleniumdriver/chromedriver.exe"
and edit executable_path