Run ChromeDriver in headless mode if in a CI environment

This commit is contained in:
jvyden 2021-12-23 00:23:14 -05:00
commit f36038910a
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -19,7 +19,7 @@ namespace ProjectLighthouse.Tests.WebsiteTests
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestStartup>().UseWebRoot("StaticFiles").Build();
public readonly string BaseAddress;
public readonly IWebDriver Driver = new ChromeDriver();
public readonly IWebDriver Driver;
public AuthenticationTests()
{
@ -29,6 +29,15 @@ namespace ProjectLighthouse.Tests.WebsiteTests
if (serverAddressesFeature == null) throw new ArgumentNullException();
this.BaseAddress = serverAddressesFeature.Addresses.First();
ChromeOptions chromeOptions = new();
if (Convert.ToBoolean(Environment.GetEnvironmentVariable("CI") ?? "false"))
{
chromeOptions.AddArgument("headless");
Console.WriteLine("We are in a CI environment, so chrome headless mode has been enabled.");
}
this.Driver = new ChromeDriver(chromeOptions);
}
[DatabaseFact]