Class Control

All Implemented Interfaces:
CapybaraPortingLayer

public class Control extends CapybaraPortingLayerImpl
Wraps a specific form element in PageAreaImpl to provide operations.

Control is like a WebElement, but with the following key differences:

  • Control is late binding, and the underlying WebElement is resolved only when an interaction with control happens. This allows Controls to be instantiated earlier (typically when a PageObject subtype is instantiated.)
  • Control offers richer methods to interact with a form element, making the right code easier to write.

See PageAreaImpl subtypes for typical usage.

Author:
Kohsuke Kawaguchi
See Also:
  • Constructor Details

    • Control

      public Control(PageAreaImpl parent, String... relativePaths)
    • Control

      public Control(PageObject parent, String... paths)
      Creates a control by giving their full path in the page
    • Control

      public Control(com.google.inject.Injector injector, org.openqa.selenium.By selector)
  • Method Details

    • resolve

      public org.openqa.selenium.WebElement resolve()
    • sendKeys

      public void sendKeys(String t)
    • uncheck

      public void uncheck()
    • check

      public void check()
    • check

      public void check(boolean state)
    • click

      public void click()
      sends a click on the underlying element. You should not use this on any page where the click will cause another page to be loaded as it will not gaurantee that the new page has been loaded.
      See Also:
      • clickAndWaitToBecomeStale()
      • clickAndWaitToBecomeStale(Duration)
    • setAtOnce

      public void setAtOnce(String text)
      The existing set(String) method has shortcomings regarding large strings because it utilizes the sendKeys mechanism to enter the string which takes a significant amount of time, i.e. the browser may consider the script to be unresponsive.

      This method method shall provide a high throughput mechanism which puts the whole string at once into the text field instead of char by char.

      This is a solution / workaround published for Selenium Issue 4496: #4496

      Parameters:
      text - the large string to be entered
    • get

      public String get()
      Returns the value of the input field.
      Returns:
      the value of the input field.
    • set

      public void set(@Nullable String text)
      Sets the value of the input field to the specified text.

      Any existing value gets cleared.

    • set

      public void set(Object text)
    • selectDropdownMenu

      public void selectDropdownMenu(Class<?> type)
      Clicks a menu button, and selects the matching item from the drop down. TODO using a class name as the Describable.value() does not seem to work.
      Parameters:
      type - Class with Describable annotation.
    • selectDropdownMenu

      public void selectDropdownMenu(String displayName)
    • selectDropdownMenuAlt

      public void selectDropdownMenuAlt(Class<?> type)
      For alternative use when the 'yui-menu-button' doesn't exist.
    • select

      public void select(String option)
      Select an option.
    • select

      public void select(Class<?> describable)
    • choose

      public void choose(Class<?> describable)
    • upload

      public void upload(Resource res)
    • text

      public String text()
    • getFormValidation

      public FormValidation getFormValidation()
    • getSilentFormValidation

      public FormValidation getSilentFormValidation()
    • exists

      public boolean exists()
      Determines whether an object is existing on the current page
      Returns:
      TRUE if it exists