From 6fc47a92185d5bfe14b6901e78a091572ed866cd Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Fri, 17 Nov 2023 12:48:53 +0200 Subject: [PATCH] Added examples of trivial grid usage without GridPw --- src/test/java/firitin/pw/GridPlaywrightIT.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/test/java/firitin/pw/GridPlaywrightIT.java b/src/test/java/firitin/pw/GridPlaywrightIT.java index 499975c..cc7b9b0 100644 --- a/src/test/java/firitin/pw/GridPlaywrightIT.java +++ b/src/test/java/firitin/pw/GridPlaywrightIT.java @@ -32,7 +32,7 @@ public class GridPlaywrightIT { public void setup() { browser = playwright.chromium() .launch(new BrowserType.LaunchOptions() - .setHeadless(false) +// .setHeadless(false) // .setDevtools(true) ); @@ -110,6 +110,21 @@ public void doRandomStuffAndChangeFirstRow() throws InterruptedException { @Test public void scrollingAndAssertingContent() { page.navigate("http://localhost:" + port + "/grid"); + + + // Examples of hacks needed without GridPo, even for trivial asserts + + // This is what one might try + String string = page.locator("#contact-grid #items td").first().textContent(); + System.out.println("string = " + string); // empty string, slot, content elsewhere :-( + + // This is how it can be done + String name = page.locator("#contact-grid #items td slot").first().getAttribute("name"); + string = page.locator("#contact-grid vaadin-grid-cell-content[slot='%s']".formatted(name)).first().textContent(); + System.out.println("string = " + string); // Now we are talking + + // Now let's drop in GridPw helper + GridPw grid = new GridPw(page.locator("#contact-grid")); System.out.println("Showing rows: %s-%s".formatted(grid.getFirstVisibleRowIndex(), grid.getLastVisibleRowIndex()));