diff --git a/.github/workflows/TestProjectWorkflow.yml b/.github/workflows/TestProjectWorkflow.yml index a8d43b9..99b41b9 100644 --- a/.github/workflows/TestProjectWorkflow.yml +++ b/.github/workflows/TestProjectWorkflow.yml @@ -22,6 +22,14 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '7.0.x' + + - name: Install Chrome dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget unzip xvfb libxi6 libgconf-2-4 + sudo apt-get install -y google-chrome-stable + google-chrome --version + which google-chrome - name: Restore dependencies run: dotnet restore diff --git a/TestProject/TestProject/Core/WebDriver/WebDriverFactory.cs b/TestProject/TestProject/Core/WebDriver/WebDriverFactory.cs index 93ea9a1..abadc5a 100644 --- a/TestProject/TestProject/Core/WebDriver/WebDriverFactory.cs +++ b/TestProject/TestProject/Core/WebDriver/WebDriverFactory.cs @@ -2,6 +2,7 @@ using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Edge; using OpenQA.Selenium.Firefox; +using TestProject.Core; namespace TestProject.WebDriver { @@ -14,9 +15,17 @@ public static IWebDriver CreateWebDriver(BrowserType browserType) case BrowserType.Chrome: { var service = ChromeDriverService.CreateDefaultService(); - ChromeOptions options = new ChromeOptions(); + ChromeOptions options = new(); + options.AddArgument("--no-sandbox"); options.AddArgument("disable-infobars"); options.AddArgument("--incognito"); + options.AddArgument("--disable-dev-shm-usage"); + + // Add headless run option + if (Configuration.Headless) + { + options.AddArgument("--headless"); + } return new ChromeDriver(service, options, TimeSpan.FromSeconds(30)); } case BrowserType.Edge: @@ -28,10 +37,11 @@ public static IWebDriver CreateWebDriver(BrowserType browserType) } } } + public enum BrowserType { Chrome, Edge, Firefox } -} +} \ No newline at end of file diff --git a/TestProject/TestProject/TestProject.csproj b/TestProject/TestProject/TestProject.csproj index 3f0821a..39554c9 100644 --- a/TestProject/TestProject/TestProject.csproj +++ b/TestProject/TestProject/TestProject.csproj @@ -20,7 +20,6 @@ - diff --git a/TestProject/TestProject/Tests/BaseTest.cs b/TestProject/TestProject/Tests/BaseTest.cs index 3c90066..f242eb3 100644 --- a/TestProject/TestProject/Tests/BaseTest.cs +++ b/TestProject/TestProject/Tests/BaseTest.cs @@ -20,7 +20,7 @@ public virtual void SetUp() WebDriverWrapper.StartBrowser(); WebDriverWrapper.NavigateTo(Configuration.AppUrl); - Logger = Logger ?? new Logger(); + Logger ??= new Logger(); } [TearDown] diff --git a/TestProject/TestProject/appsettings.json b/TestProject/TestProject/appsettings.json index 639d6fb..4d86ade 100644 --- a/TestProject/TestProject/appsettings.json +++ b/TestProject/TestProject/appsettings.json @@ -1,5 +1,6 @@ { "BrowserType": "Chrome", "ApplicationUrl": "https://www.epam.com", - "TestDataPath": "Data/TestData.json" + "TestDataPath": "Data/TestData.json", + "Headless": true } \ No newline at end of file