28 lines
835 B
C#
28 lines
835 B
C#
using System;
|
|
using OpenQA.Selenium;
|
|
using OpenQA.Selenium.Chrome;
|
|
|
|
namespace AOW4.SeleniumTests.Driver;
|
|
|
|
public static class DriverFactory
|
|
{
|
|
public static IWebDriver CreateChromeDriver()
|
|
{
|
|
var options = new ChromeOptions();
|
|
var headless = Environment.GetEnvironmentVariable("HEADLESS");
|
|
if (!string.IsNullOrEmpty(headless) && (headless == "1" || headless.Equals("true", StringComparison.OrdinalIgnoreCase)))
|
|
{
|
|
options.AddArgument("--headless=new");
|
|
}
|
|
|
|
options.AddArgument("--disable-gpu");
|
|
options.AddArgument("--no-sandbox");
|
|
options.AddArgument("--disable-dev-shm-usage");
|
|
|
|
var service = ChromeDriverService.CreateDefaultService();
|
|
service.HideCommandPromptWindow = true;
|
|
|
|
return new ChromeDriver(service, options);
|
|
}
|
|
}
|