### DatePickerPw for Vaadin Date Picker
Source: https://github.com/simasch/mopo/blob/main/documentation.md
Facilitates reading and writing LocalDate values for vaadin-date-picker components, including getting the raw input string and handling date updates.
```Java
page.navigate("http://localhost:" + port + "/date");
DatePickerPw datePickerPw = new DatePickerPw(page.locator("#dp"));
LocalDate localDate = LocalDate.of(2001, 12, 24);
assertNull(datePickerPw.getValue());
datePickerPw.setValue(localDate);
assertEquals(localDate, datePickerPw.getValue());
assertThat(page.locator("#dpValue")).containsText(localDate.toString());
// The view has a button that sets the date to now on the server
LocalDate now = LocalDate.now();
mopo.click(page.getByText("set now"));
String valueInField = datePickerPw.getInputString();
String formattedNow = DateTimeFormatter.ofPattern("M/d/yyyy", Locale.US).format(now);
assertEquals(formattedNow, valueInField);
assertThat(page.locator("#dpValue")).containsText(now.toString());
```
--------------------------------
### Vaadin ComboBoxPw Helper
Source: https://github.com/simasch/mopo/blob/main/documentation.md
Offers convenience methods for vaadin-combo-box, including filtering, selecting the first matching option, and directly selecting an option. It also provides access to the dropdown locator for more advanced interactions.
```java
page.navigate("http://localhost:" + port + "/combobox");
ComboBoxPw cbPw = new ComboBoxPw(page.locator("vaadin-combo-box"));
Locator value = page.locator("#value");
// Type filter and pick first suggestion
cbPw.filterAndSelectFirst("foo");
assertThat(value).containsText("foo");
// Type partial and select a specific option from the overlay
cbPw.filter("ba").selectOption("baz");
assertThat(value).containsText("baz");
// Open dropdown via toggle and click an option
cbPw.openDropDown().getByText("foo").click();
assertThat(value).containsText("foo");
```
```java
Locator cb = page.locator("input[role='combobox']");
cb.fill("foo");
page.waitForTimeout(1000); // sometimes needed with newer Vaadin versions
cb.press("Enter");
```
--------------------------------
### Vaadin DateTimePickerPw Helper
Source: https://github.com/simasch/mopo/blob/main/documentation.md
Provides helpers for vaadin-date-time-picker, enabling reading separate date and time inputs as locale-formatted strings. It simplifies setting date-time values and retrieving formatted date and time strings.
```java
DateTimePickerPw dateTimePickerPw = new DateTimePickerPw(page.locator("#dtp"));
LocalDateTime localDateTime = LocalDateTime.of(2001,12,24,22,36,0,0);
dateTimePickerPw.setValue(localDateTime);
assertThat(page.locator("#dtpValue")).containsText(localDateTime.toString());
String dateInputValue = dateTimePickerPw.getDateInputString();
String timeInputValue = dateTimePickerPw.getTimeInputString();
assertEquals("12/24/2001", dateInputValue);
assertEquals("10:36:00 PM", timeInputValue);
```
--------------------------------
### Maven Dependency for Mopo
Source: https://github.com/simasch/mopo/blob/main/README.md
Add this dependency to your pom.xml to include the Mopo library in your project for testing Vaadin applications with Playwright.
```XML
in.virit
mopo
0.0.1
test
```
--------------------------------
### Mopo Utilities for Vaadin Testing
Source: https://github.com/simasch/mopo/blob/main/documentation.md
Provides utility methods for testing Vaadin applications with Playwright, including waiting for connections, reliable clicking, client-side error tracking, and executing code within specific contexts.
```Java
mopo.trackClientSideErrors();
page.navigate("http://localhost:" + port + "/addonhelpers");
mopo.waitForConnectionToSettle();
mopo.getClientSideErrors().clear(); // clear expected favicon warning
Assertions.assertEquals(0, mopo.getClientSideErrors().size(),
"There should be no console errors after the page has loaded");
// Trigger an exception on purpose and fail the test if there are errors
page.getByText("Throw JS exception").click();
boolean thrown = false;
try {
mopo.failOnClientSideErrors();
} catch (RuntimeException e) {
thrown = true;
}
Assertions.assertTrue(thrown, "There should be an exception thrown");
```
```Java
List developmentTimeViewNames = mopo.getViewsReportedByDevMode(browser, "http://localhost:" + port + "/");
developmentTimeViewNames.forEach(System.out::println);
```
```Java
// Filter input has lazy value change listener
mopo.waitForConnectionToSettle();
```
--------------------------------
### Gradle Dependency for Mopo
Source: https://github.com/simasch/mopo/blob/main/README.md
Include this in your Gradle build file to add the Mopo library as a test dependency for your Vaadin application testing with Playwright.
```Gradle
testImplementation 'in.virit:mopo:0.0.1'
```
--------------------------------
### GridPw for Vaadin Grid Interaction
Source: https://github.com/simasch/mopo/blob/main/documentation.md
Wraps the vaadin-grid component to provide convenient methods for scrolling, selecting rows, and accessing cells, facilitating interaction with grid data and editing.
```Java
page.navigate("http://localhost:" + port + "/grid");
GridPw grid = new GridPw(page);
// Basic scrolling API
assertEquals(0, grid.getFirstVisibleRowIndex());
grid.scrollToIndex(10);
assertEquals(10, grid.getFirstVisibleRowIndex());
grid.scrollToIndex(0);
// Select first row and edit via a form bound to selection
String originalFirstName = grid.getRow(0).getCell(0).textContent();
grid.getRow(0).select();
// Update the "First name" field in the edit form
String newFirstName = originalFirstName + "_changed0";
page.getByLabel("First name", new Page.GetByLabelOptions().setExact(true)).fill(newFirstName);
page.getByText("Save").click();
mopo.waitForConnectionToSettle();
// Verify via both index and header
assertThat(grid.getRow(0).getCell(0)).hasText(newFirstName);
assertThat(grid.getRow(0).getCell("First Name")).hasText(newFirstName);
```
```Java
page.getByPlaceholder("Filter by name...").locator("input").fill("Alice");
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.