I inherited a test automation suite that I have built a lot on top of, however I am unclear on how to migrate the current setup to use drivers past the chromedriver. I'd like to also use IE, FF, and Edge if possible. I've Googled a significant amount and haven't seemed to find a scenario that works perfectly for me - I'd really appreciate a senior set of eyes on the below code. I'm pasting all of the sections I believe relevant:
This is in a class called BrowserManage.cs
using System;
using System.Diagnostics;
using System.Linq;
using OpenQA.Selenium;
namespace AutomationPackage.Infrastructure
{
public class BrowserManage
{
public void TearDownBrowser(IWebDriver currentBrowser)
{
CloseBrowser(currentBrowser);
}
protected void CloseBrowser(IWebDriver currentBrowser)
{
currentBrowser.Quit();
KillChromeDriver();
}
private static void KillChromeDriver()
{
var processes = Process.GetProcessesByName("chromedriver");
foreach (var process in processes.Where(process => !process.HasExited))
try
{
process.Kill();
}
catch (Exception)
{
process.Close();
}
}
}
}
This line is in app.config
<appSettings>
<add key="BrowserType" value="Chrome" />
This is in a BrowserUtilitiesPageObject.cs file which I have heavily cleaned up EXCEPT the browserdriver portion:
using System;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using AutomationPackage.Infrastructure;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.UI;
namespace AutomationPackage.Page_Objects
{
public class BrowserUtilitiesPageObject
{
public static IWebDriver CurrentBrowser
{
get; private set;
}
public static void SetUpBrowser(string browserName = "")
{
CurrentBrowser = new ChromeDriver();
CurrentBrowser.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(15);
}
public static IWebDriver CurrentBrowserInstance()
{
return CurrentBrowser;
}
As always clarifications/more information can be made available and I greatly appreciate the help. The above are snippets that are fairly heavily redacted, I was trying to limit down to pertinent points only. Thanks!