Skip to main content

DateTimePickerElement

Playwright element wrapper for <vaadin-date-time-picker>. Composes a DatePickerElement and TimePickerElement and exposes helpers to interact using LocalDateTime.

Component Tag

vaadin-date-time-picker

Implements

  • HasInputFieldElement
  • HasValidationPropertiesElement
  • HasClearButtonElement
  • HasPlaceholderElement
  • HasThemeElement
  • FocusableElement
  • HasAriaLabelElement
  • HasEnabledElement
  • HasTooltipElement
  • HasLabelElement
  • HasHelperElement

Factory Methods

getByLabel (Page)

Get the DateTimePickerElement by its label. Uses ARIA role COMBOBOX.
Page
required
The Playwright page
String
required
The accessible label of the field
Returns: The matching DateTimePickerElement

getByLabel (Locator)

Get the DateTimePickerElement by its label within a given scope.
Locator
required
The locator to search within
String
required
The accessible label of the field
Returns: The matching DateTimePickerElement

Constructor

DateTimePickerElement

Create a new DateTimePickerElement. Internally composes DatePickerElement and TimePickerElement.
Locator
required
The locator for the <vaadin-date-time-picker> element

Methods

setValue (LocalDateTime)

Set the value using a LocalDateTime.
LocalDateTime
required
The date-time to set

setValue (String)

Set the value of the input.
String
required
Value formatted as in the view (dd/mm/yyyy hh:mm)

getValueAsLocalDateTime

Get the current value as a LocalDateTime. Returns: The parsed value or null when empty

setDate

Set only the date part (string input) and dispatch change events.
String
required
The date string to set

setTime

Set only the time part (string input) and dispatch change events.
String
required
The time string to set

assertValue (String)

Assert that the input value equals the provided string.
String
required
Expected value formatted as in the view (dd/mm/yyyy hh:mm)

assertValue (LocalDateTime)

Assert that the value equals the provided date-time.
LocalDateTime
Expected LocalDateTime or null for empty

assertDateValue

Assert the date sub-field value equals the expected string.
String
required
Expected date string

assertTimeValue

Assert the time sub-field value equals the expected string.
String
required
Expected time string

getAriaLabel

Get the ARIA label from the date picker sub-field. Returns: The ARIA label or null if not set

assertAriaLabel

Assert the ARIA label on both date and time sub-fields.
String
required
Expected ARIA label

getFocusLocator

Get the locator to use for focus operations. Returns: The date picker input locator

isEnabled

Check whether both date and time pickers are enabled. Returns: true when both are enabled

assertEnabled

Assert that both date and time pickers are enabled.

assertDisabled

Assert that both date and time pickers are disabled.

Usage Examples

Basic DateTime Selection

Setting Date and Time Separately

Validation on Incomplete Input

Min/Max Validation

Theme

Focus

ARIA Label

Enabled/Disabled

Tooltip