Skip to content

Commit 94e5bbb

Browse files
Combined UFG + Classic
1 parent 7f8eacb commit 94e5bbb

File tree

3 files changed

+43
-27
lines changed

3 files changed

+43
-27
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# Applitools Example: Selenium Java Basic with the Ultrafast Grid
1+
# Applitools Example: Selenium WebDriver with Java
22

33
This is the example project for the [Selenium Java Basic tutorial](https://applitools.com/tutorials/quickstart/web/selenium/java/basic).
44
It shows how to start automating visual tests
55
with [Applitools Eyes](https://applitools.com/platform/eyes/)
6-
and the [Ultrafast Grid](https://applitools.com/platform/ultrafast-grid/)
7-
using [Selenium WebDriver](https://www.selenium.dev/) in Java.
6+
and [Selenium WebDriver](https://www.selenium.dev/) in Java.
87

98
It uses:
109

@@ -13,6 +12,9 @@ It uses:
1312
* [Google Chrome](https://www.google.com/chrome/downloads/) as the local browser for testing
1413
* [Apache Maven](https://maven.apache.org/index.html) for dependency management
1514
* [Applitools Eyes](https://applitools.com/platform/eyes/) for visual testing
15+
16+
It can also run tests with:
17+
1618
* [Applitools Ultrafast Grid](https://applitools.com/platform/ultrafast-grid/) for cross-browser execution
1719

1820
To run this example project, you'll need:
@@ -25,6 +27,8 @@ To run this example project, you'll need:
2527
6. A corresponding version of [ChromeDriver](https://chromedriver.chromium.org/downloads).
2628

2729
The main test case is [`AcmeBankTests.java`](src/test/java/com/applitools/example/AcmeBankTests.java).
30+
By default, the project will run tests with Ultrafast Grid.
31+
You can change these settings in the test class.
2832

2933
To execute tests, set the `APPLITOOLS_API_KEY` environment variable
3034
to your [account's API key](https://applitools.com/tutorials/guides/getting-started/registering-an-account).

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>org.example</groupId>
8-
<artifactId>example-selenium-java-basic-ufg</artifactId>
9-
<version>2.0.0</version>
8+
<artifactId>example-selenium-java-basic</artifactId>
9+
<version>2.1.0</version>
1010

1111
<properties>
1212
<maven.compiler.source>1.8</maven.compiler.source>
@@ -17,13 +17,13 @@
1717
<dependency>
1818
<groupId>com.applitools</groupId>
1919
<artifactId>eyes-selenium-java5</artifactId>
20-
<version>5.35.0</version>
20+
<version>5.50.0</version>
2121
<scope>test</scope>
2222
</dependency>
2323
<dependency>
2424
<groupId>org.seleniumhq.selenium</groupId>
2525
<artifactId>selenium-java</artifactId>
26-
<version>4.6.0</version>
26+
<version>4.9.1</version>
2727
<scope>test</scope>
2828
</dependency>
2929
</dependencies>

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.applitools.example;
22

33
import com.applitools.eyes.BatchInfo;
4+
import com.applitools.eyes.EyesRunner;
45
import com.applitools.eyes.RectangleSize;
56
import com.applitools.eyes.TestResultsSummary;
67
import com.applitools.eyes.selenium.BrowserType;
8+
import com.applitools.eyes.selenium.ClassicRunner;
79
import com.applitools.eyes.selenium.Configuration;
810
import com.applitools.eyes.selenium.Eyes;
911
import com.applitools.eyes.selenium.fluent.Target;
@@ -21,28 +23,36 @@
2123

2224
public 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

Comments
 (0)