-
Notifications
You must be signed in to change notification settings - Fork 2
/
AcmeBankTests.java
89 lines (79 loc) · 3.7 KB
/
AcmeBankTests.java
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
package com.applitools.example;
import com.applitools.eyes.BatchInfo;
import com.applitools.eyes.EyesRunner;
import com.applitools.eyes.RectangleSize;
import com.applitools.eyes.TestResultsSummary;
import com.applitools.eyes.selenium.BrowserType;
import com.applitools.eyes.selenium.Configuration;
import com.applitools.eyes.selenium.Eyes;
import com.applitools.eyes.selenium.fluent.Target;
import com.applitools.eyes.visualgrid.model.ChromeEmulationInfo;
import com.applitools.eyes.visualgrid.model.DesktopBrowserInfo;
import com.applitools.eyes.visualgrid.model.DeviceName;
import com.applitools.eyes.visualgrid.model.ScreenOrientation;
import com.applitools.eyes.visualgrid.services.RunnerOptions;
import com.applitools.eyes.visualgrid.services.VisualGridRunner;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.time.Duration;
public class AcmeBankTests {
private final static BatchInfo BATCH = new BatchInfo("Selenium Java Basic Quickstart");
public static void main(String [] args) {
EyesRunner runner = null;
Eyes eyes = null;
WebDriver driver = null;
try {
// Configure Applitools SDK to run on the Ultrafast Grid
runner = new VisualGridRunner(new RunnerOptions().testConcurrency(5));
eyes = new Eyes(runner);
Configuration config = eyes.getConfiguration();
config.setApiKey(System.getenv("APPLITOOLS_API_KEY"));
config.setBatch(BATCH);
config.addBrowsers(
new DesktopBrowserInfo(800, 1024, BrowserType.CHROME),
new DesktopBrowserInfo(1600, 1200, BrowserType.FIREFOX),
new DesktopBrowserInfo(1024, 768, BrowserType.SAFARI),
new ChromeEmulationInfo(DeviceName.Pixel_2, ScreenOrientation.PORTRAIT),
new ChromeEmulationInfo(DeviceName.Nexus_10, ScreenOrientation.LANDSCAPE)
);
eyes.setConfiguration(config);
ChromeOptions options = new ChromeOptions().addArguments("--headless=new");
driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
// Start Applitools Visual AI Test
eyes.open(driver,"ACME Bank", "Selenium Java Basic: Quickstart", new RectangleSize(1200, 600));
driver.get("https://sandbox.applitools.com/bank?layoutAlgo=true");
// Full Page - Visual AI Assertion
eyes.check(Target.window().fully().withName("Login page"));
driver.findElement(By.id("username")).sendKeys("user");
driver.findElement(By.id("password")).sendKeys("password");
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 Visual AI Test
eyes.closeAsync();
}
catch (Exception e) {
e.printStackTrace();
if (eyes != null)
eyes.abortAsync();
} finally {
if (driver != null)
driver.quit();
if (runner != null) {
TestResultsSummary allTestResults = runner.getAllTestResults();
System.out.println(allTestResults);
}
System.exit(0);
}
}
}