Search code examples
powershellselenium-chromedriver

I cannot start chrome instant using PowerShell and Selenium module


I am not sure what I am missing, but I installed Selenium module under PowerShell 7.1 and I cannot start chrome instance. I followed the steps below (from https://github.com/adamdriscoll/selenium-powershell):

Install-Module -Name Selenium -AllowPrerelease
$driver = start-SeChrome 

I get this error:

start-SeChrome: The term 'start-SeChrome' is not recognized as a name of a cmdlet, function, script file, or executable program.

I also tried running the script from vscode, still the same problem. See the snapshot below.

Edit: I was able to remove the latest Selenium version, and installed module 3.0.1. I had to uninstall the old one, delete the related module folders, kill all the session, and install 3.0.1. Now the command is available, but I am getting this error:

MethodInvocationException: Exception calling ".ctor" with "2" argument(s): "unknown error: cannot find Chrome binary"

See the snapshot below.

I appreciate your help.

enter image description here

enter image description here


Solution

  • I solved the problem by following the steps below:

    • Installed the stable version of Selenium PowerShell module which is at the time is 3.0.1. When I installed the latest version 4.x it was not working for some reason.
    • To remove the installed version, use PowerShell commands to remove it with Force, delete the related folders, and kill all related sessions.
    • In the installed module path, put the file chromedriver.exe in ...\PowerShell\Modules\Selenium\3.0.1\assemblies which is compatible with with the installed version of Chrome. Rename the existing one to be on the safe side.
    • To get the compatible driver, check https://chromedriver.chromium.org/downloads.
    • Kill the sessions, and try again.