1414import org .openqa .selenium .By ;
1515import org .openqa .selenium .WebDriver ;
1616import org .openqa .selenium .chrome .ChromeDriver ;
17+ import org .openqa .selenium .chrome .ChromeOptions ;
1718
1819import 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