11package com .applitools .example ;
22
33import com .applitools .eyes .BatchInfo ;
4+ import com .applitools .eyes .EyesRunner ;
45import com .applitools .eyes .RectangleSize ;
56import com .applitools .eyes .TestResultsSummary ;
67import com .applitools .eyes .selenium .BrowserType ;
8+ import com .applitools .eyes .selenium .ClassicRunner ;
79import com .applitools .eyes .selenium .Configuration ;
810import com .applitools .eyes .selenium .Eyes ;
911import com .applitools .eyes .selenium .fluent .Target ;
2123
2224public class AcmeBankTests {
2325 // This class contains everything needed to run a full visual test against the ACME bank site.
24- // It runs the test once locally,
25- // and then it performs cross-browser testing against multiple unique browsers in Applitools Ultrafast Grid .
26+ // It runs the test once locally.
27+ // If you use the Ultrafast Grid, then it performs cross-browser testing against multiple unique browsers.
2628 // It runs the test from a main function, not through a test framework.
2729
2830 // Test constants
29- private final static BatchInfo BATCH = new BatchInfo ("Example: Selenium Java Basic with the Ultrafast Grid" );
31+ private final static boolean USE_ULTRAFAST_GRID = true ;
32+ private final static String RUNNER_NAME = (USE_ULTRAFAST_GRID ) ? "Ultrafast Grid" : "Classic runner" ;
33+ private final static BatchInfo BATCH = new BatchInfo ("Example: Selenium Java Basic with the " + RUNNER_NAME );
3034
3135 public static void main (String [] args ) {
3236
33- VisualGridRunner runner = null ;
37+ EyesRunner runner = null ;
3438 Eyes eyes = null ;
3539 WebDriver driver = null ;
3640
3741 try {
3842 // The following steps set up Applitools for testing.
3943
40- // Create the runner for the Ultrafast Grid.
41- // Concurrency refers to the number of visual checkpoints Applitools will perform in parallel.
42- // Warning: If you have a free account, then concurrency will be limited to 1.
43- runner = new VisualGridRunner (new RunnerOptions ().testConcurrency (5 ));
44+ if (USE_ULTRAFAST_GRID ) {
45+ // Create the runner for the Ultrafast Grid.
46+ // Concurrency refers to the number of visual checkpoints Applitools will perform in parallel.
47+ // Warning: If you have a free account, then concurrency will be limited to 1.
48+ runner = new VisualGridRunner (new RunnerOptions ().testConcurrency (5 ));
49+ }
50+ else {
51+ // Create the Classic runner.
52+ runner = new ClassicRunner ();
53+ }
4454
45- // Create the Applitools Eyes object connected to the VisualGridRunner and set its configuration.
55+ // Create the Applitools Eyes object connected to the runner and set its configuration.
4656 eyes = new Eyes (runner );
4757
4858 // Create a configuration for Applitools Eyes.
@@ -63,23 +73,25 @@ public static void main(String [] args) {
6373 // Batches are displayed in the Eyes Test Manager, so use meaningful names.
6474 config .setBatch (BATCH );
6575
66- // Add 3 desktop browsers with different viewports for cross-browser testing in the Ultrafast Grid.
67- // Other browsers are also available, like Edge and IE.
68- config .addBrowser (800 , 600 , BrowserType .CHROME );
69- config .addBrowser (1600 , 1200 , BrowserType .FIREFOX );
70- config .addBrowser (1024 , 768 , BrowserType .SAFARI );
76+ // If running tests on the Ultrafast Grid, configure browsers.
77+ if (USE_ULTRAFAST_GRID ) {
7178
72- // Add 2 mobile emulation devices with different orientations for cross-browser testing in the Ultrafast Grid.
73- // Other mobile devices are available, including iOS.
74- config .addDeviceEmulation (DeviceName .Pixel_2 , ScreenOrientation .PORTRAIT );
75- config .addDeviceEmulation (DeviceName .Nexus_10 , ScreenOrientation .LANDSCAPE );
79+ // Add 3 desktop browsers with different viewports for cross-browser testing in the Ultrafast Grid.
80+ // Other browsers are also available, like Edge and IE.
81+ config .addBrowser (800 , 600 , BrowserType .CHROME );
82+ config .addBrowser (1600 , 1200 , BrowserType .FIREFOX );
83+ config .addBrowser (1024 , 768 , BrowserType .SAFARI );
84+
85+ // Add 2 mobile emulation devices with different orientations for cross-browser testing in the Ultrafast Grid.
86+ // Other mobile devices are available, including iOS.
87+ config .addDeviceEmulation (DeviceName .Pixel_2 , ScreenOrientation .PORTRAIT );
88+ config .addDeviceEmulation (DeviceName .Nexus_10 , ScreenOrientation .LANDSCAPE );
89+ }
7690
7791 // Set the configuration for Eyes
7892 eyes .setConfiguration (config );
7993
8094 // Open the browser with the ChromeDriver instance.
81- // Even though this test will run visual checkpoints on different browsers in the Ultrafast Grid,
82- // it still needs to run the test one time locally to capture snapshots.
8395 driver = new ChromeDriver (new ChromeOptions ().setHeadless (headless ));
8496
8597 // Set an implicit wait of 10 seconds.
0 commit comments