Class SwitchTester<T extends com.vaadin.flow.component.checkbox.Switch>

java.lang.Object
com.vaadin.browserless.ComponentTester<T>
com.vaadin.flow.component.checkbox.SwitchTester<T>
Type Parameters:
T - component type
All Implemented Interfaces:
Clickable<T>

public class SwitchTester<T extends com.vaadin.flow.component.checkbox.Switch> extends ComponentTester<T>
Tester for Switch components.
Since:
25.3
  • Constructor Details

    • SwitchTester

      public SwitchTester(T component)
      Wrap given component for testing.
      Parameters:
      component - target component
  • Method Details

    • isOn

      public boolean isOn()
      Checks whether the switch is currently on.
      Returns:
      true if the switch is on, false otherwise
    • switchOn

      public void switchOn()
      Switches the switch on by clicking it, as a user would.

      Does nothing if the switch is already on, since a user would not click it in that case. The switch must be usable either way.

    • switchOff

      public void switchOff()
      Switches the switch off by clicking it, as a user would.

      Does nothing if the switch is already off, since a user would not click it in that case. The switch must be usable either way.

    • isUsable

      public boolean isUsable()
      Description copied from class: ComponentTester
      Validate that component can be interacted with and should be visible in the UI. Subclasses overriding this method should also override ComponentTester.notUsableReasons(Consumer) to provide additional details to the potential exception thrown by ComponentTester.ensureComponentIsUsable().
      Overrides:
      isUsable in class ComponentTester<T extends com.vaadin.flow.component.checkbox.Switch>
      Returns:
      true if component can be interacted with by the user
      See Also:
    • notUsableReasons

      protected void notUsableReasons(Consumer<String> collector)
      Description copied from class: ComponentTester
      Provides messages explaining why the component is actually not usable. Subclasses overriding ComponentTester.isUsable() should also override this method to provide additional details to the potential exception throw by ComponentTester.ensureComponentIsUsable().
      Overrides:
      notUsableReasons in class ComponentTester<T extends com.vaadin.flow.component.checkbox.Switch>
      Parameters:
      collector - receives the components the tester walks over
      See Also:
    • click

      public void click(int button, MetaKeys metaKeys)
      Description copied from interface: Clickable
      Performs a click with the specified button and meta keys.
      Parameters:
      button - the mouse button (0=left, 1=middle, 2=right)
      metaKeys - the meta keys pressed during click