I have read a lots of guides over internet, but stuck in this issue.
I have created a Class Library (.NET Framework)
project called JuiceShopAutomation
.
where I have installed following Nuget
packages:
Selenium.WebdDriver (v3.8.0)<br>
Selenium.Support (v3.8.0)<br>
Selenium.Chrome.WebDriver (v2.33.0)<br>
Selenium.Firefox.WebDriver (v0.19.1)<br>
Selenium.WebDriver.IEDriver (v3.8.0)<br>
MSTest.TestFramework (v1.2.0)<br>
MSTest.TestAdapter(v1.2.0)
I have also added following code to Class1.CS
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
namespace JuiceShopAutomation
{
public class Class1
{
public void Go()
{
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\WebDriver", "geckodriver.exe");
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);
driver.Navigate().GoToUrl("http://www.google.com");
}
}
}
I also have added another project to my solution, a new Unit Test Project (.NET Framework)
called JuiceshopTests
.
For JuiceShopTests
I add the reference Project>Juiceshop Automation
where all things are installed.
To the new Unit test project I add following code into the file UnitTest1.cs
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JuiceshopAutomation;
namespace JuiceshopTests
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var c = new Class1();
c.Go();
}
}
}
Then when I run the unit test
it fails and throws the below error
:
Test Name: TestMethod1
Test FullName: JuiceShopTests.UnitTest1.TestMethod1
Test Source: C:\Users\XXXXXX\source\repos\Creating an Automated Framework With Selenium\JuiceShopAutomation\JuiceShopTests\UnitTest1.cs : line 12
Test Outcome: Failed
Test Duration: 0:01:01,3130361
Result StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
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.Firefox.FirefoxDriver..ctor(FirefoxDriverService service)
at JuiceShopAutomation.Class1.Go() in C:\Users\XXXXXX\source\repos\Creating an Automated Framework With Selenium\JuiceShopAutomation\JuiceShopAutomation\Class1.cs:line 20
at JuiceShopTests.UnitTest1.TestMethod1() in C:\Users\XXXXXX\source\repos\Creating an Automated Framework With Selenium\JuiceShopAutomation\JuiceShopTests\UnitTest1.cs:line 16
Result Message:
Test method JuiceShopTests.UnitTest1.TestMethod1 threw exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:60378/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
Could someone help me out?
CreateDefaultSerivce()
without params? And what is your Firefox browser version?