Reputation: 111
I created some selenium tests which work pretty fine on localhost, but when I deploy the application on appharbor, I'm getting an exception thrown.
This code throws the exception on creating a new instance of InternetExplorerDriver:
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
Driver = new InternetExplorerDriver(DriverDirectory, options);
Here is the exception:
OpenQA.Selenium.WebDriverException: Cannot start the driver service on http://localhost:35187/
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(String internetExplorerDriverServerDirectory, InternetExplorerOptions options)
...
Could you please advice what could be the reason and is there any way to solve it?
Upvotes: 8
Views: 1522
Reputation: 1551
Since I can't see the code for the ie driver path I would start with this. Add a folder called Drivers to your solution. Add the ie.exe file to it.
Add the below to you driver code. My guess is that when you are going from local host to AppHarbor that path is changing. I have seen this using Jenkins and SauceLabs. Using the getBasePath will load it regadless of where it is installed.
I think the below s correct but have not tested.
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IWebDriver driver = new InternetExplorerDriver(Path.Combine(GetBasePath, @"Drivers\\"), options);
driver.Navigate().GoToUrl("http://www.somewhere.com");
public static string GetBasePath
{
get
{
var basePath =
System.IO.Path.GetDirectoryName((System.Reflection.Assembly.GetExecutingAssembly().Location));
basePath = basePath.Substring(0, basePath.Length - 10);
return basePath;
}
}
Upvotes: 1
Reputation: 17408
Adding to Niels answer, sometimes you have to download the .exe file of IE and specify it's path in the webdriver call. If you have selenium drivers installed previously i.e. during installation then it automatically searches for the drivers. Or you have to download explicitly and mention the path to IE .exe file.
To download .exe file,visit the link http://docs.seleniumhq.org/download/
Upvotes: 2
Reputation: 194
The port 333 specified for the InternetExplorerDriverService falls within the well-known-port-numbers range:
On most systems, a well-known port number can only be used by a system (root) process or by a program run by a privileged user. Allow the driver service to select its own port by not specifying one explicitly, or provide an available port.
Check a couple of things:
Upvotes: 1