Package core.helpers

Class FormHelper


  • public class FormHelper
    extends Object
    • Constructor Detail

      • FormHelper

        public FormHelper()
    • Method Detail

      • clearAndSetField

        public void clearAndSetField​(EnhancedBy field,
                                     CharSequence... value)
        clears and set field
        Parameters:
        field -
        value -
      • clearAndSetField

        public void clearAndSetField​(EnhancedBy field,
                                     int index,
                                     CharSequence... value)
        clear and sets field
        Parameters:
        field -
        index -
        value -
      • setField

        public void setField​(EnhancedBy field,
                             CharSequence... value)
        sets field clears field before setting the value
        Parameters:
        field -
        value -
      • setField

        public void setField​(EnhancedBy field,
                             int index,
                             CharSequence... value)
        sets and clears field before setting the value
        Parameters:
        field -
        index -
      • setFieldByAction

        public void setFieldByAction​(EnhancedBy field,
                                     CharSequence... value)
        sets and clears field before setting the value by actions
        Parameters:
        field -
        index -
        value -
      • setFieldByAction

        public void setFieldByAction​(EnhancedBy field,
                                     int index,
                                     CharSequence... value)
        sets and clears field before setting the value by actions
        Parameters:
        field -
        index -
        value -
      • setFieldByJs

        public void setFieldByJs​(EnhancedBy field,
                                 CharSequence... value)
        set field through javascript
        Parameters:
        field -
        value -
      • setFieldByJs

        public void setFieldByJs​(EnhancedBy field,
                                 int index,
                                 CharSequence... value)
        set field through javascript
        Parameters:
        field -
        index -
        value -
      • clearField

        public void clearField​(EnhancedBy field,
                               int index)
        use multiple strategies to clear the filed 1. element.clear() 2. send escape key 3. press backspace to delete the value
        Parameters:
        field -
        index -
      • setField

        public void setField​(String value,
                             EnhancedBy field,
                             int index)
        sets field text value by index hides keyboard if on ios device
        Parameters:
        value -
        field -
        index -
      • setKeyChildField

        public void setKeyChildField​(EnhancedBy parent,
                                     int parentIndex,
                                     EnhancedBy child,
                                     int childIndex,
                                     CharSequence... value)
        sets key based on nested text field
        Parameters:
        parent -
        parentIndex -
        child -
        childIndex -
        value -
      • setFieldAndEnter

        public void setFieldAndEnter​(EnhancedBy field,
                                     CharSequence... value)
        sets field And presses the enter key
        Parameters:
        field -
        value -
      • setKey

        public void setKey​(org.openqa.selenium.Keys key,
                           EnhancedBy field)
        send
        Parameters:
        key -
        field -
      • pressEnterOnWeb

        public void pressEnterOnWeb​(EnhancedBy field)
      • formSubmit

        public void formSubmit​(EnhancedBy button,
                               EnhancedBy expected)
        select submit button and wait for expected element to load
        Parameters:
        button -
        expected -
      • formSubmitNoRetry

        public void formSubmitNoRetry​(EnhancedBy button,
                                      EnhancedBy expected)
        submit form with retrying selecting the element
        Parameters:
        button -
        expected -
      • formSubmitNoRetry

        public void formSubmitNoRetry​(EnhancedBy button,
                                      int index,
                                      EnhancedBy expected)
        submit form with retrying selecting the element
        Parameters:
        button -
        index -
        expected -
      • formSubmit

        public void formSubmit​(EnhancedBy button,
                               EnhancedBy expected,
                               EnhancedBy spinner)
        clicks submit button, wait for element to appear And loading spinner to be removed
        Parameters:
        button -
        expected -
        spinner -
      • selectDropDownWithDoubleClick

        public void selectDropDownWithDoubleClick​(String option,
                                                  EnhancedBy field,
                                                  EnhancedBy list)
        selects dropdown by double clicking on the field
        Parameters:
        option -
        field -
        list -
      • selectDropDownWithDoubleClick

        public void selectDropDownWithDoubleClick​(String option,
                                                  EnhancedBy field,
                                                  int index,
                                                  EnhancedBy list)
        selects dropdown by double clicking on the field
        Parameters:
        option -
        field -
        list -
      • selectDropDown

        public void selectDropDown​(EnhancedBy field,
                                   String... options)
        selects drop down
        Parameters:
        option - : list option we want to select
        field - : the drop down field
      • selectDropDown

        public void selectDropDown​(EnhancedBy field,
                                   int index)
        selects drop down
        Parameters:
        index - : index number for the option
        field - : the drop down field
      • selectDropDown

        public void selectDropDown​(EnhancedBy field,
                                   EnhancedBy list,
                                   String... options)
        selects drop down
        Parameters:
        option - : list option we want to select
        field - : the drop down field
        list - : the list items in the drop down list
      • selectDropDown

        @Deprecated
        public void selectDropDown​(String option,
                                   EnhancedBy field,
                                   EnhancedBy list)
        Deprecated.
        replaced by selectDropDown(field, list, options) selects drop down
        Parameters:
        option - : list option we want to select
        field - : the drop down field
        list - : the list items in the drop down list
      • selectDropDown

        public void selectDropDown​(String option,
                                   EnhancedBy field,
                                   String field_Identifier,
                                   EnhancedBy list)
        selects drop down from list defined by another list defined by text
        Parameters:
        option -
        field -
        field_Identifier -
        list -
      • selectDropDown

        public void selectDropDown​(int index,
                                   EnhancedBy field,
                                   EnhancedBy list)
        select drop down by index from the drop down list
        Parameters:
        index -
        field -
        list -
      • selectDropDown

        public void selectDropDown​(EnhancedBy field,
                                   int index,
                                   EnhancedBy list,
                                   int optionIndex)
        select drop down field based on index select option field based on index
        Parameters:
        field -
        index -
        list -
        optionIndex -
      • selectDropDown

        public void selectDropDown​(EnhancedBy field,
                                   int index,
                                   EnhancedBy list,
                                   String option)
        select drop down field based on index select option field based on text
        Parameters:
        field -
        index -
        list -
        text -
      • selectDropDown

        public void selectDropDown​(EnhancedBy field,
                                   EnhancedBy list)
        select drop down by index from the drop down list
        Parameters:
        index -
        field -
        list -
      • selectDropDown

        public void selectDropDown​(String option,
                                   EnhancedBy field,
                                   int index,
                                   EnhancedBy list)
        selects drop down based on index of the drop down field
        Parameters:
        option -
        field -
        index -
        list -
      • selectDropDown

        public void selectDropDown​(String option,
                                   EnhancedBy field,
                                   EnhancedBy list,
                                   int listIndex)
        select drop down based on index of the drop down list eg. used for date selection where each date value: day, month, year, is separate list send key is used to select the value from the list
        Parameters:
        option -
        field -
        list -
        listIndex -
      • selectDropDown

        public void selectDropDown​(String option,
                                   EnhancedBy field,
                                   int index,
                                   EnhancedBy list,
                                   int listIndex)
        select drop down based on index of the drop down list eg. used for date selection where each date value: day, month, year, is separate list send key is used to select the value from the list
        Parameters:
        option -
        field -
        index -
        list -
        listIndex -
      • selectRadioButton

        public void selectRadioButton​(String option,
                                      EnhancedBy buttons)
        selects radio button by radio button description
        Parameters:
        option -
        buttons -
      • selectCheckBox

        public void selectCheckBox​(EnhancedBy button,
                                   boolean isSelect)
        selects checkbox based on by value
        Parameters:
        button -
        isSelect -
      • selectRadioButton

        public void selectRadioButton​(EnhancedBy button)
        selects a button
        Parameters:
        button -
      • selectToggle

        public void selectToggle​(EnhancedBy on,
                                 EnhancedBy off,
                                 boolean isOn)
        select toggle button, on or off
      • selectMultipleCheckboxOptions

        public void selectMultipleCheckboxOptions​(List<String> selections,
                                                  EnhancedBy checkboxes)
        selects multiple checkbox options
        Parameters:
        selections -
        checkboxes -
      • uploadFile

        public void uploadFile​(String location,
                               EnhancedBy fileTypeElement)
        uploads file by specifying file location relative to main path
        Parameters:
        location -
        imageButton -
      • uploadImages

        public void uploadImages​(List<String> locations,
                                 EnhancedBy imageButton,
                                 EnhancedBy images)
        * sets the image based on list of image path
        Parameters:
        locations -
        imageButton -
        images -
      • uploadImage

        public void uploadImage​(String location,
                                EnhancedBy imageButton,
                                EnhancedBy images)
        sets the image based on image path
        Parameters:
        location -
        imageButton -
        images - : uploaded image
      • getTextValue

        public String getTextValue​(EnhancedBy element)
        gets the text value from an element
        Parameters:
        element -
        Returns:
      • getTextValue

        public String getTextValue​(EnhancedBy element,
                                   int index)
        gets the text value from an element
        Parameters:
        element -
        Returns:
      • isElementEditable

        public boolean isElementEditable​(EnhancedBy element)
        attempts to set text value on element, if not successful, then element is not editable
        Parameters:
        element -
        index -
        Returns:
      • isElementEditable

        public boolean isElementEditable​(EnhancedBy element,
                                         int index)
        attempts to set text value on element, if not successful, then element is not editable
        Parameters:
        element -
        index -
        Returns: