Skip to main content

Overview

The NumberFieldElement class is a Playwright wrapper for the <vaadin-number-field> component. It provides methods to interact with numeric input fields, including min/max/step constraints and step controls.

Component Tag

<vaadin-number-field>

Extends

  • AbstractNumberFieldElement

Inherited Interfaces

  • HasValidationPropertiesElement - Validation state and error messages
  • HasInputFieldElement - Value, label, helper text, and styling
  • HasPrefixElement - Prefix slot content
  • HasSuffixElement - Suffix slot content
  • HasClearButtonElement - Clear button functionality
  • HasPlaceholderElement - Placeholder text
  • HasAllowedCharPatternElement - Character input restrictions
  • HasThemeElement - Theme variants
  • FocusableElement - Focus and blur operations
  • HasAriaLabelElement - ARIA label support
  • HasEnabledElement - Enabled/disabled state
  • HasTooltipElement - Tooltip text

Constructor

Locator
required
The Playwright locator for the <vaadin-number-field> element

Factory Methods

getByLabel (Page)

Get a number field by its accessible label. Uses ARIA role spinbutton.
Page
required
The Playwright page
String
required
The accessible label of the number field

Example

getByLabel (Locator)

Get a number field by its accessible label within a scope.
Locator
required
The locator to search within
String
required
The accessible label of the number field

Methods

getStep

Get the current step value.
Returns: The step as a Double, or null if not set

setStep

Set the step value.
double
required
The step to apply

assertStep

Assert the step attribute matches the expected value.
Double
The expected step, or null to assert no explicit step is set

getMin

Get the current minimum value.
Returns: The minimum as a Double, or null if not set

setMin

Set the minimum value.
double
required
The minimum to apply

assertMin

Assert the min attribute matches the expected value.
Double
The expected minimum, or null to assert no explicit minimum is set

getMax

Get the current maximum value.
Returns: The maximum as a Double, or null if not set

setMax

Set the maximum value.
double
required
The maximum to apply

assertMax

Assert the max attribute matches the expected value.
Double
The expected maximum, or null to assert no explicit maximum is set

Inherited Methods

From AbstractNumberFieldElement:
  • getHasControls() - Check if step controls are visible
  • assertHasControls(boolean hasControls) - Assert step controls visibility
  • clickIncreaseButton() - Click the increase button
  • clickDecreaseButton() - Click the decrease button
From HasValueElement:
  • getValue() - Get current value
  • setValue(String value) - Set field value
  • clear() - Clear the value
  • assertValue(String value) - Assert value matches
From HasValidationPropertiesElement:
  • assertValid() - Assert field is valid
  • assertInvalid() - Assert field is invalid
  • assertErrorMessage(String message) - Assert error message text
  • getErrorMessageLocator() - Get error message locator
From FocusableElement:
  • focus() - Focus the field
  • blur() - Blur the field
  • getTabIndex() - Get tab index
  • assertIsFocused() - Assert field has focus
  • assertIsNotFocused() - Assert field does not have focus

Complete Example