You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instruction example in case of our SpecFlow-based template:
Add CustomBrowserFactory
Add respective nuget package of driver e.g. Selenium.WebDriver.ChromeDriver
Add hook to be executed before tests:
[BeforeTestRun(Order = 0)]
public static void ConfigureBrowserFactory()
{
AqualityServices.BrowserFactory = new CustomBrowserFactory(
AqualityServices.Get(),
AqualityServices.Get(),
AqualityServices.Get(),
AqualityServices.LocalizedLogger);
}
The text was updated successfully, but these errors were encountered:
using Aquality.Selenium.Browsers;
using Aquality.Selenium.Configurations;
using Aquality.Selenium.Core.Localization;
using Aquality.Selenium.Core.Utilities;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using System;
using System.IO;
using System.Reflection;
namespace Web.Autotests.Framework.BrowserUtilities
{
public class CustomBrowserFactory : BrowserFactory
{
public CustomBrowserFactory(IActionRetrier actionRetrier, IBrowserProfile browserProfile, ITimeoutConfiguration timeoutConfiguration, ILocalizedLogger localizedLogger)
: base(actionRetrier, browserProfile, timeoutConfiguration, localizedLogger)
{
}
protected override RemoteWebDriver Driver
{
get
{
var commandTimeout = TimeoutConfiguration.Command;
var browserName = BrowserProfile.BrowserName;
var driverSettings = BrowserProfile.DriverSettings;
RemoteWebDriver driver;
switch (browserName)
{
case BrowserName.IExplorer:
driver = GetDriver<InternetExplorerDriver>(InternetExplorerDriverService.CreateDefaultService(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location)),
(InternetExplorerOptions)driverSettings.DriverOptions, commandTimeout);
break;
case BrowserName.Chrome:
driver = GetDriver<ChromeDriver>(ChromeDriverService.CreateDefaultService(),
(ChromeOptions)driverSettings.DriverOptions, commandTimeout);
break;
default:
throw new NotSupportedException($"Browser [{browserName}] is not supported.");
}
return driver;
}
}
private RemoteWebDriver GetDriver<T>(DriverService driverService, DriverOptions driverOptions, TimeSpan commandTimeout) where T : RemoteWebDriver
{
return (T)Activator.CreateInstance(typeof(T), driverService, driverOptions, commandTimeout);
}
}
}
Instruction example in case of our SpecFlow-based template:
[BeforeTestRun(Order = 0)]
public static void ConfigureBrowserFactory()
{
AqualityServices.BrowserFactory = new CustomBrowserFactory(
AqualityServices.Get(),
AqualityServices.Get(),
AqualityServices.Get(),
AqualityServices.LocalizedLogger);
}
The text was updated successfully, but these errors were encountered: