Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@PlaywrightElement(AccordionElement.FIELD_TAG_NAME)
public class AccordionElement extends VaadinElement implements HasStyleElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-accordion";

/**
Expand All @@ -27,6 +28,8 @@ public AccordionElement(Locator locator) {

/**
* Assert the number of panels present in the accordion.
*
* @param count the expected number of panels
*/
public void assertPanelCount(int count) {
Locator panels = getLocator().locator(AccordionPanelElement.FIELD_TAG_NAME);
Expand All @@ -35,48 +38,64 @@ public void assertPanelCount(int count) {

/**
* Get a panel by its summary text.
*
* @param summary the summary text of the panel
* @return the matching {@code AccordionPanelElement}
*/
public AccordionPanelElement getPanel(String summary) {
return AccordionPanelElement.getAccordionPanelBySummary(getLocator(), summary);
}

/**
* Open a panel by its summary text.
*
* @param summary the summary text of the panel to open
*/
public void openPanel(String summary) {
getPanel(summary).setOpen(true);
}

/**
* Close a panel by its summary text.
*
* @param summary the summary text of the panel to close
*/
public void closePanel(String summary) {
getPanel(summary).setOpen(false);
}

/**
* Whether the panel with the given summary is open.
*
* @param summary the summary text of the panel
* @return {@code true} if the panel is open
*/
public boolean isPanelOpened(String summary) {
return getPanel(summary).isOpen();
}

/**
* Assert that the panel with the given summary is open.
*
* @param summary the summary text of the panel
*/
public void assertPanelOpened(String summary) {
getPanel(summary).assertOpened();
}

/**
* Assert that the panel with the given summary is closed.
*
* @param summary the summary text of the panel
*/
public void assertPanelClosed(String summary) {
getPanel(summary).assertClosed();
}

/**
* Get the currently opened panel.
*
* @return the currently opened {@code AccordionPanelElement}
*/
public AccordionPanelElement getOpenedPanel() {
return AccordionPanelElement.getOpenedAccordionPanel(getLocator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,77 @@
@PlaywrightElement(AccordionPanelElement.FIELD_TAG_NAME)
public class AccordionPanelElement extends VaadinElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-accordion-panel";
/** The HTML tag name for the accordion heading. */
public static final String FIELD_HEADING_TAG_NAME = "vaadin-accordion-heading";

/**
* Create a new {@code AccordionPanelElement}.
*
* @param locator the locator for the {@code <vaadin-accordion-panel>} element
*/
public AccordionPanelElement(Locator locator) {
super(locator);
}

/** Assert that the panel is opened. */
/**
* Assert that the panel is opened.
*/
public void assertOpened() {
assertThat(getLocator()).hasAttribute("opened", "");
}

/** Assert that the panel is closed. */
/**
* Assert that the panel is closed.
*/
public void assertClosed() {
assertThat(getLocator()).not().hasAttribute("opened", "");
}

/** Whether the panel is open. */
/**
* Whether the panel is open.
*
* @return {@code true} if the panel is open
*/
public boolean isOpen() {
return getLocator().getAttribute("opened") != null;
}

/** Set the open state by clicking the summary when needed. */
/**
* Set the open state by clicking the summary when needed.
*
* @param open {@code true} to open, {@code false} to close
*/
public void setOpen(boolean open) {
if (isOpen() != open) {
getSummaryLocator().click();
}
}

/** Locator pointing to the summary heading. */
/**
* Locator pointing to the summary heading.
*
* @return the summary locator
*/
public Locator getSummaryLocator() {
return getLocator().locator(FIELD_HEADING_TAG_NAME);
}

/** Text content of the summary heading. */
/**
* Text content of the summary heading.
*
* @return the summary text
*/
public String getSummaryText() {
return getSummaryLocator().textContent();
}

/** Locator pointing to the first non-slotted content element. */
/**
* Locator pointing to the first non-slotted content element.
*
* @return the content locator
*/
public Locator getContentLocator() {
return getLocator().locator("xpath=./*[not(@slot)][1]");
}
Expand All @@ -70,7 +98,13 @@ public void assertContentNotVisible() {
assertThat(getContentLocator()).not().isVisible();
}

/** Get an accordion panel by its summary text within a scope. */
/**
* Get an accordion panel by its summary text within a scope.
*
* @param locator the scope to search within
* @param summary the summary text to match
* @return the matching {@code AccordionPanelElement}
*/
public static AccordionPanelElement getAccordionPanelBySummary(Locator locator, String summary) {
return new AccordionPanelElement(locator.locator(FIELD_TAG_NAME).filter(
new Locator.FilterOptions().setHas(
Expand All @@ -79,7 +113,12 @@ public static AccordionPanelElement getAccordionPanelBySummary(Locator locator,
)));
}

/** Get the currently opened accordion panel within a scope. */
/**
* Get the currently opened accordion panel within a scope.
*
* @param locator the scope to search within
* @return the opened {@code AccordionPanelElement}
*/
public static AccordionPanelElement getOpenedAccordionPanel(Locator locator) {
return new AccordionPanelElement(locator.locator(FIELD_TAG_NAME).filter(
new Locator.FilterOptions().setHas(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class BigDecimalFieldElement extends VaadinElement
HasPrefixElement, HasSuffixElement, HasClearButtonElement, HasPlaceholderElement, HasAllowedCharPatternElement,
HasThemeElement, FocusableElement, HasAriaLabelElement, HasEnabledElement, HasTooltipElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-big-decimal-field";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class ButtonElement extends VaadinElement
implements FocusableElement, HasAriaLabelElement, HasEnabledElement,
HasPrefixElement, HasStyleElement, HasSuffixElement, HasThemeElement, HasTooltipElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-button";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@PlaywrightElement(CardElement.FIELD_TAG_NAME)
public class CardElement extends VaadinElement implements HasThemeElement, HasStyleElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-card";

/**
Expand Down Expand Up @@ -61,62 +62,80 @@ public static CardElement getByTitle(Locator locator, String title) {

/**
* Locator for the title slot.
*
* @return the title locator
*/
public Locator getTitleLocator() {
return getLocator().locator("> [slot='title']");
}

/**
* Locator for the subtitle slot.
*
* @return the subtitle locator
*/
public Locator getSubtitleLocator() {
return getLocator().locator("> [slot='subtitle']");
}

/**
* Locator for the header slot.
*
* @return the header locator
*/
public Locator getHeaderLocator() {
return getLocator().locator("> [slot='header']");
}

/**
* Locator for the header prefix slot.
*
* @return the header prefix locator
*/
public Locator getHeaderPrefixLocator() {
return getLocator().locator("> [slot='header-prefix']");
}

/**
* Locator for the header suffix slot.
*
* @return the header suffix locator
*/
public Locator getHeaderSuffixLocator() {
return getLocator().locator("> [slot='header-suffix']");
}

/**
* Locator for the media slot.
*
* @return the media locator
*/
public Locator getMediaLocator() {
return getLocator().locator("> [slot='media']");
}

/**
* Locator for the footer slot.
*
* @return the footer locator
*/
public Locator getFooterLocator() {
return getLocator().locator(" > [slot='footer']");
}

/**
* Locator for the default (content) slot.
*
* @return the content locator
*/
public Locator getContentLocator() {
return getLocator().locator("xpath=./*[not(@slot)][1]");
}

/**
* Assert the card title text, or absence when {@code null}.
*
* @param title the expected title text, or {@code null} to assert absence
*/
public void assertTitle(String title) {
if (title != null) {
Expand All @@ -128,6 +147,8 @@ public void assertTitle(String title) {

/**
* Assert the card subtitle text, or absence when {@code null}.
*
* @param subtitle the expected subtitle text, or {@code null} to assert absence
*/
public void assertSubtitle(String subtitle) {
if (subtitle != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class CheckboxElement extends VaadinElement
implements FocusableElement, HasAriaLabelElement, HasEnabledElement,
HasHelperElement, HasValueElement, HasStyleElement, HasLabelElement, HasValidationPropertiesElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-checkbox";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@
*/
public class ContextMenuElement extends VaadinElement implements HasStyleElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-context-menu";
/** The HTML tag name for the context menu list box. */
public static final String FIELD_LIST_BOX_TAG_NAME = "vaadin-context-menu-list-box";

/**
* Create a {@code ContextMenuElement} from the page overlay.
* Get the first opened context menu
* Gets the first opened context menu.
*
* @param page the Playwright page
*/
public ContextMenuElement(Page page) {
super(page.locator(FIELD_TAG_NAME + "[opened]"));
}

/**
* Create a {@code ContextMenuElement} from an existing locator.
*
* @param locator the locator for the context menu element
*/
public ContextMenuElement(Locator locator) {
super(locator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class DatePickerElement extends VaadinElement implements HasInputFieldEle
HasClearButtonElement, HasPlaceholderElement, HasThemeElement, FocusableElement, HasAriaLabelElement,
HasEnabledElement, HasTooltipElement, HasLabelElement, HasHelperElement {

/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-date-picker";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public class DateTimePickerElement extends VaadinElement implements HasInputFiel

private final DatePickerElement datePickerElement;
private final TimePickerElement timePickerElement;
/** The HTML tag name for this Vaadin component. */
public static final String FIELD_TAG_NAME = "vaadin-date-time-picker";
/** The date-time formatter for ISO local date-time format. */
public static final DateTimeFormatter ISO_LOCAL_DATE_TIME = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.append(ISO_LOCAL_DATE)
Expand Down Expand Up @@ -178,6 +180,8 @@ public static DateTimePickerElement getByLabel(Locator locator, String label) {

/**
* Set only the date part (string input) and dispatch change events.
*
* @param date the date value formatted as dd/mm/yyyy
*/
public void setDate(String date) {
datePickerElement.setValue(date);
Expand All @@ -187,6 +191,8 @@ public void setDate(String date) {

/**
* Set only the time part (string input) and dispatch change events.
*
* @param date the time value formatted as HH:mm
*/
public void setTime(String date) {
timePickerElement.setValue(date);
Expand All @@ -196,13 +202,17 @@ public void setTime(String date) {

/**
* Assert the date sub-field value equals the expected string.
*
* @param date the expected date value
*/
public void assertDateValue(String date) {
datePickerElement.assertValue(date);
}

/**
* Assert the time sub-field value equals the expected string.
*
* @param time the expected time value
*/
public void assertTimeValue(String time) {
timePickerElement.assertValue(time);
Expand Down
Loading
Loading