Reputation: 45
When trying to create a new FirFoxDriver() a new window is launched but never fully loads. Here are pieces of of my code. I have the framework set up as such. Each webpage is it's own file, Base web Page. Each set of page tests is it's own file, Base test page.
TestFixture and TestFixtureSetup and Setup on the actual test file.
[TestFixture("FireFox")]
public class LoginPageTests : BaseSeleniumTest
{
public readonly string _TestDriver;
private LoginPage _LoginPage;
private Users _Users;
private HomePage _HomePage;
public LoginPageTests(string driverToUse) { _TestDriver = driverToUse; }
[TestFixtureSetUp]
public override void TestFixtureSetUp()
{
base.DriverSetUp(_TestDriver);
_Users = new Users(Credentials.bleonard);
}
[SetUp]
public void Setup()
{
_LoginPage = new LoginPage(Driver);
}
BaseTestPage:
public abstract class BaseSeleniumTest
{
protected IWebDriver Driver;
protected Stopwatch SeleniumStopwatch = Stopwatch.StartNew();
protected BaseSeleniumTest()
{
SeleniumStopwatch = Stopwatch.StartNew();
}
public static IWebDriver GetDriver(string driverToUse)
{
IWebDriver w;
Trace.Write("Newing up driver...");
switch (driverToUse)
{
case "InternetExplorer":
w = new InternetExplorerDriver(@"C:\cst-bitbucket\Selenium\Cst.Selenium.Tests");
w.Manage().Window.Maximize();
break;
case "Chrome":
ChromeOptions options = new ChromeOptions();
options.AddArgument("test-type");
options.AddArgument("start-maximized");
w = new ChromeDriver(@"C:\cst-bitbucket\Selenium\Cst.Selenium.Tests", options);
break;
case "FireFox":
w = new FirefoxDriver();
w.Manage().Window.Maximize();
break;
default:
w = new FirefoxDriver();
w.Manage().Window.Maximize();
break;
}
w.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
return w;
}
public virtual void DriverSetUp(string driverToUse)
{
try
{
if (Driver == null)
{
Driver = GetDriver(driverToUse);
}
else
{
Driver.Quit();
Driver = GetDriver(driverToUse);
}
Driver.Manage().Cookies.DeleteAllCookies();
}
catch (Exception ex)
{
Assert.Inconclusive(TestResultReporter.AssertError = "Failed while getting web driver!" + ex);
}
}
When debugging heres what happens.The base.DriverSetup(_TestDrive) gets called on the BaseTestPage. Since Driver on that page is null, it fires off the GetDriver Method, which takes in driverToUse which is FireFox. GetDrive will move to the switch case "FireFox", and fire off new FirfoxDriver(). Load a new window but never goes to the home page or anything. It gets hung up on that line with the output showing multiple
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
and then the catch statement is thrown in the DriverSetUp
method and a final output error of:
A first chance exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
is given. Any help would be great, I've been working at it for days now.
Upvotes: 1
Views: 620
Reputation: 45
To solve my issue, first try to update Selenium to 2.45. The release for both Webdriver and Support for all languages was 2/27/15. Make sure you completley close out Visual Studio and Restart so everything is clean. If that doesn't work you need to downgrade to FireFox 34.0.5. At this point FireFoxWebDriver launched fine.
Upvotes: 0
Reputation: 473803
The symptoms are similar to what I've seen while using selenium
2.44 and Firefox
35 or higher - there are compatibility issues:
As a workaround, downgrade Firefox to 34.0.5.
Upvotes: 1