[ad_1]
Although I have no errors, the Browser does not open when I want to run the tests
I want to run an older project, I fixed the errors but I don’t know why the browser is not open.
I have: selenium Chrome Selenium Firefox
Console: C:\Program Files\dotnet\dotnet.exe (process 23320) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . .
Output: ‘dotnet.exe’ (CoreCLR: DefaultDomain): Loaded ‘C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.25\System.Private.CoreLib.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled. ‘dotnet.exe’ (CoreCLR: clrhost): Loaded ‘C:\Users\Ariana\OneDrive\Desktop\AutomationPractice\AutomationPractice\bin\Debug\netcoreapp3.1\AutomationPractice.dll’. Symbols loaded. ‘dotnet.exe’ (CoreCLR: clrhost): Loaded ‘C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.25\System.Runtime.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled. The program ‘[8276]
Hooks class:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TestingProjectWebsite.StepDefinitions;
using Microsoft.Azure.WebJobs.Description;
using TechTalk.SpecFlow;
namespace TestingProjectWebsite
{
public enum BrowserType
{
Chrome,
Firefox
}
[TechTalk.SpecFlow.Binding]
public class Hooks
{
private BrowserType _browserType;
protected static IWebDriver Driver;
[BeforeScenario]
public void BeforeScenario()
{
var browserType = TestContext.Parameters.Get("Browser", "Chrome");
_browserType = (BrowserType)Enum.Parse(typeof(BrowserType), browserType);
if (Driver is null)
{
ChooseDriverInstance(_browserType);
Driver.Manage().Window.Maximize();
}
Driver.Navigate().GoToUrl("http://automationpractice.com/index.php");
}
public void ChooseDriverInstance(BrowserType browserType)
{
switch (browserType)
{
case BrowserType.Chrome:
Driver = new ChromeDriver();
break;
case BrowserType.Firefox:
Driver = new FirefoxDriver();
break;
}
}
[AfterScenario]
public void AfterScenario()
{
if (!(Driver is null))
{
Driver.Quit();
Driver = null;
}
}
}
}
[ad_2]