Class Inputs


  • public final class Inputs
    extends Object
    High-level API to define and interact with various input elements. High level API's are not optimized. A definition of an element may interact with the browser to understand the structure of the DOM.
    • Method Detail

      • inputForLabel

        public static Path inputForLabel​(InBrowser browser,
                                         String labelText)
        A lazy way to find an input based on the label. Mote that unlike It looks for a label element that has an ID. If it finds one, it returns a Path to an input with that ID. Otherwise it returns a Path to an input inside the label element.
        Parameters:
        browser - the browser
        labelText - the label to look for
        Returns:
        a Path to the input, on a best effort basis
      • genericFormInputAfterField

        public static Path genericFormInputAfterField​(String fieldName)
        A generic, reasonable guess of an input field in a form.
        Parameters:
        fieldName - - the field before the input
        Returns:
        a Path for the input field
      • genericFormInputBeforeField

        public static Path genericFormInputBeforeField​(String fieldName)
        A generic, reasonable guess of an input field in a form.
        Parameters:
        fieldName - - the field before the input
        Returns:
        a Path for the input field
      • inputFollowedByUnlabeledText

        public static Path inputFollowedByUnlabeledText​(String text)
        Input followed by text that does not have its on label element.
        Parameters:
        text - the text following the input
        Returns:
        a Path to the input element
      • checkboxType

        public static Path checkboxType​(Path inp)
        Takes an input element and returns such an input of type checkbox.
        Parameters:
        inp - the input element
        Returns:
        a Path to the input
      • radioType

        public static Path radioType​(Path inp)
        Takes an input element and returns such an input of type radio.
        Parameters:
        inp - the input element
        Returns:
        a Path to the input
      • clearInputNonStrict

        public static void clearInputNonStrict​(InBrowser browser,
                                               Path field)
                                        throws Operations.OperationFailedException
        Clear operation on an input element, but does not enforces a complete clear. In other words, it will try to clear as much as it can, and not fail if it can clear it completely.
        Parameters:
        browser - the browser
        field - the input element
        Throws:
        Operations.OperationFailedException
      • selectInFieldWithLabel

        public static Path selectInFieldWithLabel​(InBrowser browser,
                                                  String labelText,
                                                  String option)
        Perform a selection of an option in a select element. It expects to find the label element with the given text before the select element
        Parameters:
        browser - the browser
        labelText - The text of the select label
        option - The option text
        Returns:
        the Path of the select element
      • changeInputValueAssumingElementIsNotReplaced

        public static void changeInputValueAssumingElementIsNotReplaced​(InBrowser browser,
                                                                        Path field,
                                                                        String text)
                                                                 throws Operations.OperationFailedException
        Change input value: clear it and then enter another text in it. This assumes the input element is not replaced by another element, as with that assumption, it is supposed to be slightly faster.
        Parameters:
        browser - the browser
        field - Path to the input field
        text - the text to enter in the input field
        Throws:
        Operations.OperationFailedException - failed to perform the operation
      • changeInputValueWithQuickApproximateDeletion

        public static void changeInputValueWithQuickApproximateDeletion​(InBrowser browser,
                                                                        Path field,
                                                                        String text)
                                                                 throws Operations.OperationFailedException
        Change input value: Try to clear it first and then enter another text in it. Clearing the input focuses on speed and is not guaranteed.
        Parameters:
        browser - the browser
        field - Path to the input field
        text - the text to enter in the input field
        Throws:
        Operations.OperationFailedException - failed to perform the operation
      • changeInputValueNonStrictClearing

        public static void changeInputValueNonStrictClearing​(InBrowser browser,
                                                             Path field,
                                                             String text)
                                                      throws Operations.OperationFailedException
        Change input value: clear it and then enter another text in it. This variation does not ensure cleaning up the input, but tries to clean as much as it can.
        Parameters:
        browser - the browser
        field - Path to the input field
        text - the text to enter in the input field
        Throws:
        Operations.OperationFailedException - failed to perform the operation
      • changeInputValueWithApproximateDeletionWithEnter

        public static void changeInputValueWithApproximateDeletionWithEnter​(InBrowser browser,
                                                                            Path field,
                                                                            String text)
                                                                     throws Operations.OperationFailedException
        Similar to changeInputValue, but adds an ENTER after setting the value of the input
        Parameters:
        browser - the browser
        field - Path to the input field
        text - the text to enter in the input field
        Throws:
        Operations.OperationFailedException - failed to perform the operation
      • changeInputValueWithEnterNonStrictClearing

        public static void changeInputValueWithEnterNonStrictClearing​(InBrowser browser,
                                                                      Path field,
                                                                      String text)
                                                               throws Operations.OperationFailedException
        Similar to changeInputValueNonStrictClearing, but adds an ENTER after setting the value of the input
        Parameters:
        browser - the browser
        field - Path to the input field
        text - the text to enter in the input field
        Throws:
        Operations.OperationFailedException - failed to perform the operation
      • selectDropdownOption

        public static void selectDropdownOption​(InBrowser browser,
                                                Path dropdownContent,
                                                Path myOption)