В настоящее время я работаю над дизайном моего проекта в Specflow.Я хочу внедрить некоторую отчетность в мой проект.В настоящее время я создал один отдельный файл .cs и сохранил все настройки отчета.Но когда я выполняю свой тестовый прогон кода и выдаю ошибку, соединение не может быть установлено, потому что целевая машина активно отказала ему 127.0.0.1:55991:
Test Name: FacebookLoginFunctionalityWithInvalidCrenditials
Test FullName: ReportDemoPOC.Feature.TestFacebookLoginFunctionalityFeature.FacebookLoginFunctionalityWithInvalidCrenditials
Test Source: C:\Users\ashish.verma\Desktop\Test-Automation-\ReportGenerateNewCode\ReportDemoPOC\ReportDemoPOC\Feature\LoginFeature.feature : line 3
Test Outcome: Failed
Test Duration: 0:00:17.026
Result StackTrace:
--TearDown
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.Close()
at ReportDemoPOC.SeleniumDriver.Close() in C:\Users\ashish.verma\Desktop\Test-Automation-\ReportGenerateNewCode\ReportDemoPOC\ReportDemoPOC\SeleniumDriver.cs:line 35
at ReportDemoPOC.Start.TearDown() in C:\Users\ashish.verma\Desktop\Test-Automation-\ReportGenerateNewCode\ReportDemoPOC\ReportDemoPOC\Start.cs:line 50
at lambda_method(Closure , IContextManager )
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioEnd()
at TechTalk.SpecFlow.TestRunner.OnScenarioEnd()
at ReportDemoPOC.Feature.TestFacebookLoginFunctionalityFeature.ScenarioTearDown()
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--SocketException
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
Result Message:
TearDown : OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:55991/session//window. The status of the exception was ConnectFailure, and the message was: Unable to connect to the remote server
----> System.Net.WebException : Unable to connect to the remote server
----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it 127.0.0.1:55991
Start.cs
<code>using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Configuration;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
namespace ReportDemoPOC {
public
class Start {
public
static ExtentReports extent;
public
static ExtentHtmlReporter htmlReporter;
public
static ExtentTest test;
static Start()
{
if (extent == null) {
BasicSetUp();
}
}
[BeforeScenario] public void Setup()
{
SeleniumDriver.Intitialize();
SeleniumDriver.Navigate();
test = extent.CreateTest(ScenarioContext.Current.ScenarioInfo.Title);
}
[AfterScenario] public void TearDown()
{
if (ScenarioContext.Current.TestError != null) {
var error = ScenarioContext.Current.TestError;
var errormessage = "<pre>" + error.Message + "
";// Добавляем сюда снимок экрана для захвата экрана экстента.{string pth = System.Reflection.Assembly.GetCallingAssembly (). CodeBase; // string pth = System.IO.Directory.GetCurrentDirectory (); строка actualPath = pth.Substring (0, pth.LastIndexOf ("bin")));string projectPath = new Uri (actualPath) .LocalPath; Console.WriteLine ("----------- Путь к проекту -------------------------------------- "); Console.WriteLine (projectPath); // строка reportPath = projectPath +" Reports \\ "+ FeatureContext.Current.FeatureInfo.Title +".html "; строка reportPath = projectPath +" Reports \\ TestRunReport.html "; // Console.WriteLine (" Путь к отчету "+ reportPath); htmlReporter = новый ExtentHtmlReporter (reportPath);htmlReporter.Configuration (). Theme = Theme.Dark;htmlReporter.Configuration (). DocumentTitle = "SpecFlow Test Resport Document";htmlReporter.Configuration (). ReportName = "Результаты выполнения компонента";экстент = новый ExtentReports ();extent.AttachReporter (htmlReporter);//extent.LoadConfig(projectPath + "Extent-Config.xml");} [AfterFeature ()] public static void EndReport () {deg .Flush ();// span.Close ();}}}
LoginSteps.cs
using NUnit.Framework;
using ReportDemoPOC.Page;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
namespace ReportDemoPOC.Steps
{
[Binding]
[TestFixture] class LoginSteps : Start {
LoginPage loginPage;
[Given(@"I am at Facebook login page")] public void GivenIAmAtFacebookLoginPage()
{
//Navigate();
loginPage = new LoginPage();
}
[When(@"I enter ashusoni(.*)@gmail\.com in the Email or Phone textbox")] public void WhenIEnterAshusoniGmail_ComInTheEmailOrPhoneTextbox(String p0)
{
loginPage.enterValueInUser("abcd" + p0 + "@gmail.com");
}
[When(@"I Enter (.*) in the password")] public void WhenIEnterInThePassword(String p0)
{
loginPage.enterValueInPassword(p0);
}
[When(@"Click on the Login button")] public void WhenClickOnTheLoginButton()
{
loginPage.clickOnLoginButton();
}
[Then(@"Application should display an error message")] public void ThenApplicationShouldDisplayAnErrorMessage()
{
Console.WriteLine("Verification");
loginPage.Shutdown();
}
}
}