Reputation: 69
I am trying to use selenium in python and for some reason I cannot modify the PATH so I can only specify the location of browser driver. However, I tried several drivers and none of them worked.
Environment: Windows 7, Anaconda3-python3.6.1, selenium3.4.3, chrome59.0.3071.115 (Official Build) (64-bit), chromedriver2.30 (win32).
Here are a part of the code I have tried and the corresponding error.
from selenium import webdriver
driver = webdriver.Chrome("I:\chromedriver.exe")
Traceback (most recent call last):
File "", line 1, in driver = webdriver.Chrome("I:\chromedriver.exe")
File "C:\Users\yz\AppData\Local\Continuum\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in init self.service.start()
File "C:\Users\yz\AppData\Local\Continuum\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 96, in start self.assert_process_still_running()
File "C:\Users\yz\AppData\Local\Continuum\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 109, in assert_process_still_running % (self.path, return_code)
WebDriverException: Service I:\chromedriver.exe unexpectedly exited. Status code was: 1
Upvotes: 2
Views: 7492
Reputation: 193388
Here is the Answer to your Question:
While working with Selenium
3.4.3, chromedriver
v2.30 and Google Chrome
59.0 to initiate the WebDriver
instance we need to pass the absolute path of the chromedriver
through the argument executable_path
as follows:
from selenium import webdriver
driver = webdriver.Chrome(executable_path= r"C:\\Utility\\BrowserDrivers\\chromedriver.exe")
Let me know if this Answers your Question.
Upvotes: 1