Skip to content

Commit 7757bb2

Browse files
committed
test: add headless Chrome setup for Selenium tests in CI workflow
1 parent 4d7291e commit 7757bb2

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ jobs:
1111
timeout-minutes: 30
1212
steps:
1313
- uses: actions/checkout@v4
14+
1415
- name: Set up JDK ${{ matrix.java }}
1516
uses: actions/setup-java@v4
1617
with:
1718
distribution: 'temurin'
1819
java-version: ${{ matrix.java }}
1920
cache: 'maven'
21+
22+
- name: Setup Chrome
23+
uses: browser-actions/setup-chrome@v1
24+
25+
- name: Verify Chrome Installation
26+
run: google-chrome --version
27+
2028
- name: Build with Maven
2129
run: ./mvnw clean install --batch-mode -DskipTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
2230
- name: Upload coverage to codecov

.github/workflows/integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ jobs:
4545
with:
4646
flags: integration
4747
directory: ./jacoco
48+

dubbo-admin-test/src/test/java/org/apache/dubbo/admin/BaseIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.fluentlenium.core.annotation.Page;
2626
import org.junit.BeforeClass;
2727
import org.openqa.selenium.WebDriver;
28+
import org.openqa.selenium.chrome.ChromeDriver;
29+
import org.openqa.selenium.chrome.ChromeOptions;
2830
import org.slf4j.Logger;
2931
import org.slf4j.LoggerFactory;
3032

@@ -47,9 +49,22 @@ public BaseIT() {
4749
public static void beforeClass() {
4850
WebDriverManager.chromedriver().setup();
4951

52+
ChromeOptions options = new ChromeOptions();
53+
options.addArguments("--headless"); // Run in headless mode
54+
options.addArguments("--disable-gpu");
55+
options.addArguments("--no-sandbox");
56+
options.addArguments("--disable-dev-shm-usage");
57+
58+
driver = new ChromeDriver(options);
59+
5060
BASE_URL = StringUtils.defaultString(System.getenv("BASEURL"), "http://localhost:8082");
5161
}
5262

63+
@Override
64+
public WebDriver newWebDriver() {
65+
return driver;
66+
}
67+
5368
@Override
5469
public String getBaseUrl() {
5570
return BASE_URL;

0 commit comments

Comments
 (0)