Skip to content

Commit

Permalink
Convert Selenium tests to Playwright
Browse files Browse the repository at this point in the history
- It's a much nicer style of testing which even comes with bundled browsers
  • Loading branch information
scroix committed Apr 7, 2024
1 parent 4a022b9 commit c8cb6e9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 66 deletions.

This file was deleted.

18 changes: 0 additions & 18 deletions nodel-jyhost/src/test/java/org/nodel/NavigationSeleniumTest.java

This file was deleted.

47 changes: 47 additions & 0 deletions nodel-jyhost/src/test/java/org/nodel/PlaywrightTests.java
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 nodel-jyhost/src/test/java/org/nodel/WebDriverSingleton.java

This file was deleted.

0 comments on commit c8cb6e9

Please sign in to comment.