0

I have a C#-Visual Studio 2019 (netcoreapp3.1)-Selenium project, and I am practicing using different drivers. When I try to open Firefox, I get the 'Cannot start the driver service on http://localhost:xxxxx/' (the xxxxx number keeps changing every time I run program) error in Visual Studio, and in CMD, 'found argument '--websocket-port' which wasn't expected' - No connection could be made because the target machine actively refused it. I have Firefox (0.27.0) and Gecko (0.30.0.1) driver packages installed from NuGet, I have Firefox browser insatlled on my PC, and I have 'using OpenQA.Selenium.Firefox;'

IWebDriver driver = new InternetExplorerDriver() works completely fine.

I tried the following fixes I found on Stack Exchange from users who ran into this issue - no success:

  1. Kill all Chrome driver and browser processes running in background. I did this from CMD and Task Manager.
  2. Put file path to 'geckodriver' inside parentheses of new FirefoxDriver(); - see code below.
  3. In Edit System Variables, added NO_PROXY environment variable with value localhost.
  4. I looked up the '-- websocket-port', and found someone saying that this message comes up if geckodriver version is higher than 0.9, with advise to downgrade to earlier version. However, my geckodriver is 0.3, not higher than 0.9.
  5. Downgraded to netcoreapp2.1
  6. Went to www.whatismyproxy.com, and I am not connected to a VPN (someone suggested that VPN connection can cause this issue).
  7. Unintsalling, and then reinstalling, the Firefox browser.

namespace AutoTestFramework { public class EntryPoint {

    public static void Main()
    {
        IWebDriver driver = new FirefoxDriver(@"C:\Users\Poli's computer\source\repos\EnvironmentSetup\AutoTestFramework\bin\Debug\netcoreapp3.1");

        driver.Navigate().GoToUrl("https://www.google.com");

found argument '--websocket-port' which wasn't expected

Cannot start the driver service on http://localhost:xxxxx/

Anne Bailly
  • 391
  • 3
  • 9
  • Please [edit] your question to include all textual information (errors, console messages, etc.) as text in addition to or instead of pictures of text. Currently, visually impaired humans and search engine robots see those images as only "enter image description here", which is less than optimal. – Heretic Monkey Dec 26 '21 at 00:03
  • https://stackoverflow.com/questions/56435676/openqa-selenium-webdriverexception-cannot-start-the-driver-service-on-http-l#:~:text=OpenQA.Selenium.WebDriverException%3A%20%27Cannot%20start%20the%20driver%20service%20on%20http%3A%2F%2Flocalhost%3A20548%2F,Manager%20to%20see%20and%20end%20it%20if%20does. – Hans Passant Dec 26 '21 at 00:27

1 Answers1

2

I resolved with downloading more recent of driver in:

https://github.com/mozilla/geckodriver/releases