Selenium with C#

-1

I am new in C# and trying to run a simple driver.Naviage().GoToUrl("http://www.google.com"); with selenium and C# but I am keep getting "command line server for the IE driver has stopped working" error. And on my Script I am getting error "OpenQA.selenium.WebDriverExcption: 'cannot start the driver service on http://localhost:55459/'. complete error:

   OpenQA.Selenium.WebDriverException
      HResult=0x80131500
      Message=Cannot start the driver service on http://localhost:55459/
      Source=WebDriver
      StackTrace:
       at OpenQA.Selenium.DriverService.Start()
       at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
       at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
       at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService service, InternetExplorerOptions options)
       at OpenQA.Selenium.IE.InternetExplorerDriver..ctor()
       at SeleniumFirst.Program.Main(String[] args) in F:\clone Repo\SeleniumFirst\SeleniumFirst\SeleniumFirst\Program.cs:line 15

My Test Script:

using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumFirst

    {
        class Program
        {
            static void Main(string[] args)
            {
                IWebDriver driver = new InternetExplorerDriver();
    
                driver.Navigate().GoToUrl("https://www.google.com");
    
            }
        }
    }

My configure file:

 <?xml version="1.0" encoding="utf-8"?>
    <packages>
      <package id="Selenium.InternetExplorer.WebDriver" version="3.150.1" targetFramework="net461" />
      <package id="Selenium.Support" version="3.141.0" targetFramework="net461" />
      <package id="Selenium.WebDriver" version="3.141.0" targetFramework="net461" />
      <package id="Selenium.WebDriver.IEDriver" version="https://protect-us.mimecast.com/s/AyNYC5yXZ3f0PPoiOlacl?domain=3.150.1.2" targetFramework="net461" />
      <package id="Selenium.WebDriver.IEDriver64" version="3.141.59" targetFramework="net461" />
    </packages>
c#
selenium
asked on Stack Overflow Dec 9, 2020 by Tarishah

1 Answer

0

This works for me. So I used your configuration, as you specified, in my package.config file and also set the the .net framework to 4.6.1 as yours.

I also used your exact code.

The only difference I believe is that I downloaded the IE Driver Executable from the link below and dropped it in the bin directory:

https://www.selenium.dev/downloads/

if you don't want to use the executable, then you can modify your config file to look like this:

<packages>
  <package id="Selenium.InternetExplorer.WebDriver" version="3.150.1" targetFramework="net461" />
  <package id="Selenium.Support" version="3.141.0" targetFramework="net461" />
  <package id="Selenium.WebDriver" version="3.141.0" targetFramework="net461" />
  <package id="Selenium.WebDriver.IEDriver" version="3.150.1.2" targetFramework="net461" />
</packages>
answered on Stack Overflow Dec 9, 2020 by Stackedup • edited Dec 9, 2020 by Stackedup

User contributions licensed under CC BY-SA 3.0