Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I'm having trouble using the Chrome driver for Selenium. I have the chrome driver downloaded and saved to C:\Chrome:

driver = webdriver.Chrome(executable_path="C:/Chrome/")

Using that gives me the following error:

Traceback (most recent call last):

  File "C:\Python33\lib\subprocess.py", line 1105, in _execute_child

    startupinfo)

PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\service.py", line 63, in start

    self.service_args, env=env, stdout=PIPE, stderr=PIPE)

  File "C:\Python33\lib\subprocess.py", line 817, in __init__

    restore_signals, start_new_session)

  File "C:\Python33\lib\subprocess.py", line 1111, in _execute_child

    raise WindowsError(*e.args)

PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:/Users/Wilson/Dropbox/xxx.py", line 71, in <module>

    driver = webdriver.Chrome(executable_path="C:/Chrome/")

  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 59, in __init__

    self.service.start()

  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\service.py", line 68, in start

    and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")

selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://chromedriver.storage.googleapis.com/index.html  

Any help would be appreciated.

1 Answer

0 votes
by (62.9k points)

There are mainly two reasons due to which the WebDriver is unable to launch the browser and the reasons are:

1) The WebDriver version is outdated.

2) Missed the web driver's correct location.

 

1)The WebDriver version is outdated.

 

i) I'd suggest you download the latest version of ChromeDriver, mainly because it supports the latest versions of Chrome, using this link. As per July 2019, the latest version is ChromeDriver 76.0.3809.68.

http://chromedriver.chromium.org/downloads 

ii)Click on the latest version of WebDriver, you will be navigated to a list of Chrome WebDriver based on various Operating System, choose as per your OS.

iii)Once the zip file is downloaded, you can unzip it to retrieve chromedriver.exe

 

2) Missed the web driver's correct location.

 

Use webdriver.chrome.driver system property

Using this method, you need to add an extra line of code in your test case.  To use this method, follow the steps given below –

i) Copy the entire path where you unzipped chromedriver.exe. Let us say the location is – D:\Drivers\chromedriver.exe. Add System.setProperty with the driver location to your code.

ii) Code to launch Chrome browser would look like this –

public class ChromeTest {

@Test

public void LaunchChrome_Method1() {

System.setProperty("webdriver.chrome.driver","D:\\Drivers\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.get("http://www.google.com");

}

}

iv) Run this code to verify that it works fine. It will launch the chrome browser window and will open google.com automatically.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, enroll in Selenium course online!

Browse Categories

...