diff --git a/.github/workflows/ci_integration.yml b/.github/workflows/ci_integration.yml new file mode 100644 index 0000000..0ed6f42 --- /dev/null +++ b/.github/workflows/ci_integration.yml @@ -0,0 +1,32 @@ +name: TestUI CI integration tests workflow + +on: + push: + branches: + - master + pull_request: + branches: + - master + + workflow_dispatch: + +jobs: + integration_test: + runs-on: ubuntu-latest + continue-on-error: true + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: "zulu" + - name: Remove Chrome + run: sudo apt purge google-chrome-stable + - name: Remove default Chromium + run: sudo apt purge chromium-browser + - name: Install a new Chromium + run: sudo apt install -y chromium-browser + - name: Integration browser test with Maven + run: mvn -Dtest=TestBrowser test diff --git a/pom.xml b/pom.xml index aaee65d..d349c78 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ maven-surefire-plugin 3.0.0-M3 - true + false -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" @@ -170,7 +170,7 @@ com.codeborne selenide - 6.10.1 + 6.12.2 org.slf4j diff --git a/src/test/java/TestRunners/TestBrowser.java b/src/test/java/TestRunners/TestBrowser.java index 77d21d6..2058495 100644 --- a/src/test/java/TestRunners/TestBrowser.java +++ b/src/test/java/TestRunners/TestBrowser.java @@ -5,6 +5,7 @@ import org.junit.Test; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.remote.DesiredCapabilities; import pages.GoogleLandingPage; import testUI.Configuration; @@ -29,54 +30,33 @@ public void testDesktopBrowser() { Configuration.testUILogLevel = LogLevel.DEBUG; Configuration.softAsserts = true; Configuration.browser = "chrome"; + Configuration.headless = true; open("https://www.google.com"); UIAssert("the url is not correct", getSelenideDriver().getCurrentUrl().equals("https://www.google.com/")); executeJs("arguments[0].value='TestUI';", googleLandingPage.getGoogleSearchInput() .getSelenideElement().getWrappedElement()); googleLandingPage.getGoogleSearch() - .then().saveScreenshot("~/Documents" + - "/screen" + - ".png"); + .then().saveScreenshot("~/target/screen.png"); logAverageTime(); System.out.println(getListOfCommandsTime()); raiseSoftAsserts(); + stop(); } @Test public void setDriverTest() { ChromeOptions options = new ChromeOptions(); Configuration.softAsserts = false; - options.addArguments("--user-agent=Agent", "--ignore-certificate-errors"); + options.addArguments( + "--user-agent=Agent", "--ignore-certificate-errors", "--headless", "--remote-allow-origins=*"); Configuration.chromeOptions = options; selenideBrowserCapabilities.setBrowserName("chrome"); open("https://www.whatsmyua.info/"); E(byCssSelector("textarea")).waitFor(10).untilHasText("Agent"); sleep(1000); - } - - @Test - @DisplayName("Laptop browser test case") - public void testDesktopBrowserSafari() { - Configuration.automationType = DESKTOP_PLATFORM; - Configuration.browser = "safari"; - Configuration.serverLogLevel = "all"; - Configuration.softAsserts = true; - open("https://www.google.com"); - System.out.println(getTestUIDriver().getCurrentUrl()); - executeJs("arguments[0].value='TestUI';", googleLandingPage.getGoogleSearchInput() - .getSelenideElement().getWrappedElement()); - googleLandingPage.getGoogleSearch().given() - .then().click().saveScreenshot("/Users/alvarolasernalopez/Documents/screen" + - ".png"); stop(); - open("https://www.google.com"); - googleLandingPage.getGoogleSearch().given().waitFor(10).untilIsVisible() - .then().click().saveScreenshot("/Users/alvarolasernalopez/Documents/screen" + - ".png"); - - raiseSoftAsserts(); } @@ -86,6 +66,7 @@ public void testDesktopBrowserStatusCode() { Configuration.automationType = DESKTOP_PLATFORM; Configuration.logNetworkCalls = true; Configuration.browser = "chrome"; + Configuration.headless = true; open("https://www.google.com") .getNetworkCalls().logAllCalls().filterByExactUrl("https://www.google.com/") .logFilteredCalls() @@ -107,11 +88,14 @@ public void testDesktopBrowserStatusCode() { public void testDesktopCustomDriverBrowser() { Configuration.automationType = DESKTOP_PLATFORM; Configuration.browser = "chrome"; + Configuration.headless = true; open("https://www.google.com"); stop(); - ChromeOptions options = new ChromeOptions(); String userAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"; + ChromeOptions options = new ChromeOptions(); + options.addArguments("--remote-allow-origins=*"); options.addArguments("--user-agent=" + userAgent); + options.addArguments("--headless"); ChromeDriver chromeDriver = new ChromeDriver(options); setDriver(chromeDriver); open("https://www.whatsmyua.info/"); @@ -128,6 +112,7 @@ public void testAndroidBrowserOneLine() { Configuration.useAllure = false; Configuration.softAsserts = true; Configuration.browser = "chrome"; + Configuration.headless = true; Configuration.testUILogLevel = LogLevel.DEBUG; open("https://loadero.com/login") .given("I set element").setElement(byCssSelector("#username")) @@ -139,5 +124,6 @@ public void testAndroidBrowserOneLine() { .then("I find the submit").setElement(byCssSelector("[type=\"submit\"]")) .and("I click on it").click(); raiseSoftAsserts(); + stop(); } }