Skip to content

Commit

Permalink
feat: heading
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhumberstone committed Aug 13, 2024
1 parent a79c079 commit 8390cc3
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Our first test: a test of tests, screenshotting playwright.dev

sudo apt-get install libxslt1.1\
sudo apt-get install libwoff1\
sudo apt-get install libvpx9\
sudo apt-get install libevent-2.1-7t64\
sudo apt-get install libopus0\
sudo apt-get install libgstreamer-plugins-base1.0-0\
sudo apt-get install libgstreamer-gl1.0-0\
sudo apt-get install libgstreamer-plugins-bad1.0-0\
sudo apt-get install libwebpdemux2\
sudo apt-get install libharfbuzz-icu0\
sudo apt-get install libenchant-2-2\
sudo apt-get install libsecret-1-0\
sudo apt-get install libhyphen0\
sudo apt-get install libmanette-0.2-0\
sudo apt-get install libflite1\
sudo apt-get install libgles2\
sudo apt-get install gstreamer1.0-libav
Binary file added example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.46.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
14 changes: 14 additions & 0 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>
<h1>XP Voting</h1>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.nickhumberstone.xpvoting;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.server.LocalServerPort;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.*;
import com.microsoft.playwright.options.AriaRole;

import java.nio.file.Paths;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)

public class PlaywrightDefaultIT {

@LocalServerPort
private Integer port;

private static Page page;
private static Playwright playwright;

@BeforeAll
static void launchInstance() {
playwright = Playwright.create();
Browser browser = playwright.webkit().launch();
page = browser.newPage();
}

@AfterAll
static void closeBrowser() {
playwright.close();
}

@Test
void shouldScreenshot() {
page.navigate("http://localhost:" + port);
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("example.png")));
}

@Test
void shouldHaveHeading() {
assertThat(page
.getByRole(AriaRole.HEADING,
new Page.GetByRoleOptions().setName("XP Voting")))
.isVisible();
}
}

0 comments on commit 8390cc3

Please sign in to comment.