Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAcmeBankTests.java
More file actions
Latest commit
99 lines (85 loc) · 4.06 KB
/
Copy pathAcmeBankTests.java
File metadata and controls
99 lines (85 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
packagecom.applitools.example;
importcom.applitools.eyes.BatchInfo;
importcom.applitools.eyes.EyesRunner;
importcom.applitools.eyes.RectangleSize;
importcom.applitools.eyes.TestResultContainer;
importcom.applitools.eyes.TestResultsSummary;
importcom.applitools.eyes.selenium.BrowserType;
importcom.applitools.eyes.selenium.Configuration;
importcom.applitools.eyes.selenium.Eyes;
importcom.applitools.eyes.selenium.fluent.Target;
importcom.applitools.eyes.visualgrid.model.ChromeEmulationInfo;
importcom.applitools.eyes.visualgrid.model.DesktopBrowserInfo;
importcom.applitools.eyes.visualgrid.model.DeviceName;
importcom.applitools.eyes.visualgrid.model.ScreenOrientation;
importcom.applitools.eyes.visualgrid.services.RunnerOptions;
importcom.applitools.eyes.visualgrid.services.VisualGridRunner;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.chrome.ChromeDriver;
importorg.openqa.selenium.chrome.ChromeOptions;
importjava.time.Duration;
publicclassAcmeBankTests {
privatefinalstaticBatchInfoBATCH = newBatchInfo("Selenium Java Basic Quickstart");
publicstaticvoidmain(String [] args) {
EyesRunnerrunner = null;
Eyeseyes = null;
WebDriverdriver = null;
try {
// Configure Applitools SDK to run on the Ultrafast Grid
runner = newVisualGridRunner(newRunnerOptions().testConcurrency(5));
eyes = newEyes(runner);
Configurationconfig = eyes.getConfiguration();
config.setApiKey(System.getenv("APPLITOOLS_API_KEY"));
config.setBatch(BATCH);
config.addBrowsers(
newDesktopBrowserInfo(800, 1024, BrowserType.CHROME),
newDesktopBrowserInfo(1600, 1200, BrowserType.FIREFOX),
newDesktopBrowserInfo(1024, 768, BrowserType.SAFARI),
newChromeEmulationInfo(DeviceName.Pixel_2, ScreenOrientation.PORTRAIT),
newChromeEmulationInfo(DeviceName.Nexus_10, ScreenOrientation.LANDSCAPE)
);
eyes.setConfiguration(config);
ChromeOptionsoptions = newChromeOptions().addArguments("--headless=new");
driver = newChromeDriver(options);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
// Start Applitools Visual AI Test
eyes.open(driver,"ACME Bank", "Selenium Java Basic: Quickstart", newRectangleSize(1200, 600));
driver.get("https://sandbox.applitools.com/bank");
// Full Page - Visual AI Assertion
eyes.check(Target.window().fully().withName("Login page"));
driver.findElement(By.id("username")).sendKeys("Chris");
driver.findElement(By.id("password")).sendKeys("CorrectHorseBatteryStaple");
driver.findElement(By.id("log-in")).click();
// Full Page - Visual AI Assertion
eyes.check(
Target.window().fully().withName("Main page")
// Uncomment to apply Layout regions and have test pass
/* .layout(
By.cssSelector(".dashboardOverview_accountBalances__3TUPB"),
By.cssSelector(".dashboardTable_dbTable___R5Du")
) */
);
// End Applitools Eyes Visual AI Test
eyes.closeAsync();
}
catch (Exceptione) {
e.printStackTrace();
if (eyes != null)
eyes.abortAsync();
} finally {
if (driver != null)
driver.quit();
if (runner != null) {
TestResultsSummaryallTestResults = runner.getAllTestResults();
for (TestResultContainercontainer : allTestResults.getAllResults()) {
if (container.getTestResults() != null && !container.getTestResults().isPassed()) {
System.exit(1);
}
}
}
System.exit(0); // All tests passed
}
System.exit(0); // Will not be reached if mismatch occurred
}
}