skip to Main Content

I’m trying to run Selenium on Docker using Azure Function in C#. I’ve installed Selenium.WebDriver and Selenium.WebDriver.ChromeDriver nuget packages. In docker file I’ve also put code for installing Chrome driver, but when I try to create ChromeDriver in code, I get exception that chromedriver can’t be found.

When I list all files in directory, I can see that there is chromedriver.exe file listed:
enter image description here

but when I try to create a new Chrome driver using this line:

IWebDriver driver = new ChromeDriver(Environment.CurrentDirectory);

I get the following exception:

The file /home/site/wwwroot/bin/Debug/netcoreapp3.1/chromedriver does
not exist. The driver can be downloaded at
http://chromedriver.storage.googleapis.com/index.html.

Why chromedriver.exe file is not recognized? When I run the same code without Docker, everything works fine.

2

Answers


  1. Add the absolute path of chromedriver.exe to container PATH environment variable

    Login or Signup to reply.
  2. Typically Windows executables end with .exe while Linux executables have no file extension. A file being executable on Linux is a consequence of file permissions rather than some naming convention.

    The file path in the exception message uses forward-slashes / as file path delimiters rather than back slashes leading me to believe you have downloaded a Windows-compatible ChromeDriver which you are attempting to run on a Linux machine.

    Solution: download the Linux driver instead when deployed via Docker.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search