Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: upgrade to selenium v4 #1855

Merged
merged 4 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maven Regression Test
name: Maven Regression Test (REST)

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
regression_test_ENG:
test_ENG:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,8 +19,8 @@ jobs:
- run: mvn clean
- run: mvn verify -P regression-testing-rest -D base.url=http://eng.elimu.ai

regression_test_TGL:
needs: regression_test_ENG
test_TGL:
needs: test_ENG
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -32,8 +32,8 @@ jobs:
- run: mvn clean
- run: mvn verify -P regression-testing-rest -D base.url=http://tgl.elimu.ai

regression_test_HIN:
needs: regression_test_TGL
test_HIN:
needs: test_TGL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/maven-regression-test-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Maven Regression Test (UI)

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test_ENG:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: maven
- run: mvn clean
- run: mvn verify -P regression-testing-ui -D headless=true -D base.url=http://eng.elimu.ai

test_TGL:
needs: test_ENG
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: maven
- run: mvn clean
- run: mvn verify -P regression-testing-ui -D headless=true -D base.url=http://tgl.elimu.ai

test_HIN:
needs: test_TGL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: maven
- run: mvn clean
- run: mvn verify -P regression-testing-ui -D headless=true -D base.url=http://hin.elimu.ai
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
<artifactId>selenium-java</artifactId>
<version>4.23.1</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion src/test/java/selenium/DomainHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DomainHelper {
private static final Logger logger = LogManager.getLogger();

public static String getBaseUrl() {
// Read property set on the command line:
// Read "base.url" property set on the command line:
// mvn clean verify -P regression-testing-rest -D base.url=https://eng.test.elimu.ai
String baseUrlSystemProperty = System.getProperty("base.url");
logger.info("baseUrlSystemProperty: \"" + baseUrlSystemProperty + "\"");
Expand Down
1 change: 0 additions & 1 deletion src/test/java/selenium/ErrorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ public class ErrorHelper {
public static void verifyNoScriptOrMarkupError(WebDriver driver) {
JavaScriptHelper.verifyNoJavaScriptError(driver);
// MarkupValidationHelper.verifyNoMarkupError(driver.getPageSource());
// TODO: verify no missing translations in page source ("???...???")
}
}
2 changes: 1 addition & 1 deletion src/test/java/selenium/web/WelcomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class WelcomePage {
public WelcomePage(WebDriver driver) {
this.driver = driver;

driver.findElement(By.id("welcomePageTEST"));
driver.findElement(By.id("welcomePage"));

ErrorHelper.verifyNoScriptOrMarkupError(driver);
}
Expand Down
25 changes: 22 additions & 3 deletions src/test/java/selenium/web/WelcomePageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import selenium.DomainHelper;

public class WelcomePageTest {
Expand All @@ -17,13 +20,29 @@ public class WelcomePageTest {
@BeforeEach
public void setUp() {
logger.info("setUp");

ChromeOptions chromeOptions = new ChromeOptions();

// Read "headless" property set on the command line:
// mvn clean verify -P regression-testing-ui -D headless=true -D base.url=https://eng.test.elimu.ai
String headlessSystemProperty = System.getProperty("headless");
logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\"");
if ("true".equals(headlessSystemProperty)) {
chromeOptions.addArguments("headless");
}

// See https://www.selenium.dev/documentation/en/webdriver/driver_requirements/#chromium-chrome
System.setProperty("webdriver.chrome.driver", "src/test/resources/selenium/chrome_80.0.3987.106/chromedriver_mac64/chromedriver");
driver = new ChromeDriver();
driver = new ChromeDriver(chromeOptions);

driver.get(DomainHelper.getBaseUrl());
}

@AfterEach
public void tearDown() {
logger.info("tearDown");

driver.quit();
}

@Test
public void testWelcomePage() {
logger.info("testWelcomePage");
Expand Down
Binary file not shown.