-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathTestCase.java
More file actions
75 lines (65 loc) · 2.67 KB
/
Copy pathTestCase.java
File metadata and controls
75 lines (65 loc) · 2.67 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
import com.applitools.eyes.*;
import com.applitools.eyes.selenium.*;
import com.applitools.eyes.selenium.fluent.Target;
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 io.github.bonigarcia.wdm.WebDriverManager;
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class TestCase {
private static WebDriver driver;
private static BatchInfo myTestBatch;
private static EyesRunner testRunner;
private static Configuration suiteConfig;
Eyes eyes;
@BeforeAll
public static void beforeAll() {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
driver = WebDriverManager.chromedriver().capabilities(chromeOptions).create();
myTestBatch = new BatchInfo("Test Cases");
myTestBatch.setSequenceName("Advanced Visual Testing");
testRunner = new VisualGridRunner(new RunnerOptions().testConcurrency(5));
suiteConfig = new Configuration();
suiteConfig.setApiKey(System.getenv("APPLITOOLS_API_KEY"));
suiteConfig.setBatch(myTestBatch);
// suiteConfig.setBranchName("childBranch");
// suiteConfig.setParentBranchName("featureBranch1");
// suiteConfig.setBaselineBranchName("default");
suiteConfig.addBrowser(1400, 600, BrowserType.CHROME);
suiteConfig.addBrowser(1600, 1200, BrowserType.FIREFOX);
suiteConfig.addBrowser(1024, 768, BrowserType.SAFARI);
suiteConfig.addDeviceEmulation(DeviceName.Pixel_2, ScreenOrientation.PORTRAIT);
suiteConfig.addDeviceEmulation(DeviceName.Nexus_10, ScreenOrientation.LANDSCAPE);
}
@BeforeEach
public void beforeEach(TestInfo testInfo) {
eyes = new Eyes(testRunner);
eyes.setConfiguration(suiteConfig);
eyes.open(driver, "My First Tests", testInfo.getTestMethod().get().getName(), new RectangleSize(1400, 600));
}
@Test
public void GithubIntegrationTest() {
driver.get("https://applitools.com/helloworld");
eyes.check(Target.window());
}
@Test
public void example() {
driver.get("https://example.com");
eyes.check(Target.window());
}
@AfterEach
public void afterEach() {
eyes.closeAsync();
}
@AfterAll
public static void afterAll() {
driver.close();
TestResultsSummary results = testRunner.getAllTestResults();
System.out.println(results);
}
}