Skip to content

Commit 7e967c9

Browse files
Added headless support
1 parent 8cb1c87 commit 7e967c9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ jobs:
2727
- name: Test code
2828
run: mvn exec:exec@run-the-tests -Dexec.classpathScope=test
2929
env:
30-
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
30+
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
31+
HEADLESS: true

src/test/java/com/applitools/example/AcmeBankTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.openqa.selenium.By;
1515
import org.openqa.selenium.WebDriver;
1616
import org.openqa.selenium.chrome.ChromeDriver;
17+
import org.openqa.selenium.chrome.ChromeOptions;
1718

1819
import java.time.Duration;
1920

@@ -52,6 +53,11 @@ public static void main(String [] args) {
5253
// then the SDK will automatically read the `APPLITOOLS_API_KEY` environment variable to fetch it.
5354
config.setApiKey(System.getenv("APPLITOOLS_API_KEY"));
5455

56+
// Read the headless mode setting from an environment variable.
57+
// Use headless mode for Continuous Integration (CI) execution.
58+
// Use headed mode for local development.
59+
boolean headless = Boolean.parseBoolean(System.getenv().getOrDefault("HEADLESS", "false"));
60+
5561
// Create a new batch for tests.
5662
// A batch is the collection of visual tests.
5763
// Batches are displayed in the dashboard, so use meaningful names.
@@ -74,7 +80,7 @@ public static void main(String [] args) {
7480
// Open the browser with the ChromeDriver instance.
7581
// Even though this test will run visual checkpoints on different browsers in the Ultrafast Grid,
7682
// it still needs to run the test one time locally to capture snapshots.
77-
driver = new ChromeDriver();
83+
driver = new ChromeDriver(new ChromeOptions().setHeadless(headless));
7884

7985
// Set an implicit wait of 10 seconds.
8086
// For larger projects, use explicit waits for better control.

0 commit comments

Comments
 (0)