-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Date(Time)PickerPw and cleanup
closes #4
- Loading branch information
Showing
8 changed files
with
478 additions
and
82 deletions.
There are no files selected for viewing
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
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,57 @@ | ||
package in.virit.mopo; | ||
|
||
import com.microsoft.playwright.Locator; | ||
|
||
import java.time.LocalDate; | ||
|
||
/** | ||
* A helper class to work with vaadin-date-picker component. | ||
*/ | ||
public class DatePickerPw { | ||
|
||
private final Locator root; | ||
|
||
/** | ||
* Creates a DatePicker page object for the given locator. | ||
* | ||
* @param gridLocator the Playwright locator for the vaadin-date-picker to | ||
* be interacted with | ||
*/ | ||
public DatePickerPw(Locator gridLocator) { | ||
this.root = gridLocator; | ||
} | ||
|
||
/** | ||
* Returns the value from the client side and parses it as | ||
* {@link LocalDate}. | ||
* | ||
* @return the current value of the field | ||
*/ | ||
public LocalDate getValue() { | ||
String str = (String) root.evaluate("db => db.value"); | ||
try { | ||
return LocalDate.parse(str); | ||
} catch (java.time.format.DateTimeParseException e) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Sets the value of the field. | ||
* | ||
* @param value the value to be set | ||
*/ | ||
public void setValue(LocalDate value) { | ||
root.evaluate("db => db.value = '%s'".formatted(value)); | ||
} | ||
|
||
/** | ||
* Returns the raw string value in the field. | ||
* | ||
* @return the string value as it is formatted in the field. Note, this may | ||
* be locale dependent. | ||
*/ | ||
public String getInputString() { | ||
return root.locator("input").inputValue(); | ||
} | ||
} |
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,67 @@ | ||
package in.virit.mopo; | ||
|
||
import com.microsoft.playwright.Locator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* A helper class to work with vaadin-date-time-picker | ||
*/ | ||
public class DateTimePickerPw { | ||
|
||
private final Locator root; | ||
|
||
/** | ||
* Creates a DateTimePicker page object for the given locator. | ||
* | ||
* @param gridLocator the Playwright locator for the vaadin-date-time-picker | ||
* to be interacted with | ||
*/ | ||
public DateTimePickerPw(Locator gridLocator) { | ||
this.root = gridLocator; | ||
} | ||
|
||
/** | ||
* Sets the current value of this field | ||
* | ||
* @param value the value to be set | ||
*/ | ||
public void setValue(LocalDateTime value) { | ||
root.evaluate("db => db.value = '%s'".formatted(value)); | ||
} | ||
|
||
/** | ||
* Gets the currently set value of the field and parses it as | ||
* {@link LocalDateTime}. | ||
* | ||
* @return the current value of the field | ||
*/ | ||
public LocalDateTime getValue() { | ||
String str = (String) root.evaluate("db => db.value"); | ||
try { | ||
return LocalDateTime.parse(str); | ||
} catch (java.time.format.DateTimeParseException e) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Gets the string currently in the input field defining the date part. | ||
* | ||
* @return the string value as it is formatted in the field. Note, this may | ||
* be locale dependent. | ||
*/ | ||
public String getDateInputString() { | ||
return root.locator("vaadin-date-picker input").inputValue(); | ||
} | ||
|
||
/** | ||
* Returns the string currently in the input defining the time part | ||
* | ||
* @return the string value as it is formatted in the field. Note, this may | ||
* be locale dependent. | ||
*/ | ||
public String getTimeInputString() { | ||
return root.locator("vaadin-time-picker input").inputValue(); | ||
} | ||
} |
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
Oops, something went wrong.