forked from museumsvictoria/nodel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Selenium tests to Playwright
- It's a much nicer style of testing which even comes with bundled browsers
- Loading branch information
Showing
4 changed files
with
47 additions
and
66 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
nodel-jyhost/src/test/java/org/nodel/ActiveNavItemSeleniumTest.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
nodel-jyhost/src/test/java/org/nodel/NavigationSeleniumTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.nodel; | ||
|
||
import com.microsoft.playwright.*; | ||
import org.junit.jupiter.api.*; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class PlaywrightTests { | ||
|
||
private static Playwright playwright; | ||
private static Browser browser; | ||
private static Page page; | ||
|
||
@BeforeAll | ||
public static void setup() { | ||
playwright = Playwright.create(); | ||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions(); | ||
// Add any browser options here if necessary | ||
browser = playwright.chromium().launch(options); | ||
BrowserContext context = browser.newContext(); | ||
// Customize the context if needed (viewport size, user agent, etc.) | ||
page = context.newPage(); | ||
|
||
// Wait for the application to start up | ||
page.navigate("http://127.0.0.1:8085"); | ||
page.waitForSelector(".navbar"); | ||
} | ||
|
||
@Test | ||
public void testNavigationBarPresence() { | ||
assertNotNull(page.querySelector(".navbar"), "Navigation bar should be present"); | ||
} | ||
|
||
@Test | ||
public void testActiveNavigationItem() { | ||
String activeNavItemText = page.textContent(".nav.navbar-nav .active"); | ||
assertEquals("Locals", activeNavItemText, "Active navigation item should be 'Locals'"); | ||
} | ||
|
||
@AfterAll | ||
public static void tearDown() { | ||
if (browser != null) { | ||
browser.close(); | ||
} | ||
playwright.close(); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
nodel-jyhost/src/test/java/org/nodel/WebDriverSingleton.java
This file was deleted.
Oops, something went wrong.