Repository navigation
Expand file tree
/
Copy pathPlaywrightExampleTest.java
More file actions
61 lines (53 loc) · 2.15 KB
/
Copy pathPlaywrightExampleTest.java
File metadata and controls
61 lines (53 loc) · 2.15 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
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import io.visual_regression_tracker.sdk_java.IgnoreAreas;
import io.visual_regression_tracker.sdk_java.TestRunOptions;
import io.visual_regression_tracker.sdk_java.VisualRegressionTracker;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.util.Base64;
import java.util.List;
public class PlaywrightExampleTest {
static VisualRegressionTracker vrt = new VisualRegressionTracker();
static Playwright playwright;
static Browser browser;
static Page page;
@BeforeClass
public static void setUp() throws IOException, InterruptedException {
playwright = Playwright.create();
browser = playwright.chromium().launch();
page = browser.newPage(new Browser.NewPageOptions().setViewportSize(800, 600));
vrt.start();
}
@AfterClass
public static void tearDown() throws IOException, InterruptedException {
playwright.close();
vrt.stop();
}
@Test
public void example() throws IOException, InterruptedException {
page.navigate("https://the-internet.herokuapp.com/");
vrt.track("Home page", Base64.getEncoder().encodeToString(page.screenshot()));
page.locator("a[href='/checkboxes']").click();
vrt.track(
"Checkboxes page",
Base64.getEncoder().encodeToString(page.screenshot()),
TestRunOptions.builder()
.device("PC")
.os(System.getProperty("os.name"))
.browser("Chromium")
.viewport("800x600")
.diffTollerancePercent(0.0f)
.ignoreAreas(List.of(
IgnoreAreas.builder()
.x(10L)
.y(10L)
.width(100L)
.height(200L)
.build()))
.build());
}
}