Skip to content

Commit

Permalink
Added examples of trivial grid usage without GridPw
Browse files Browse the repository at this point in the history
  • Loading branch information
mstahv committed Nov 17, 2023
1 parent 04a03c3 commit 6fc47a9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/test/java/firitin/pw/GridPlaywrightIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class GridPlaywrightIT {
public void setup() {
browser = playwright.chromium()
.launch(new BrowserType.LaunchOptions()
.setHeadless(false)
// .setHeadless(false)
// .setDevtools(true)
);

Expand Down Expand Up @@ -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()));
Expand Down

0 comments on commit 6fc47a9

Please sign in to comment.