Skip to content

Instantly share code, notes, and snippets.

@Droogans
Created February 19, 2015 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Droogans/a46b8c8d53995e0d5f53 to your computer and use it in GitHub Desktop.
Save Droogans/a46b8c8d53995e0d5f53 to your computer and use it in GitHub Desktop.
rx-page-docs-rx-form

#Index

Modules

Namespaces

#encore.rxOptionFormTable Members

##encore.rxOptionFormTable.main Returns: rxOptionFormTable - Page object representing the first rxOptionFormTable object found on the page.
##encore.rxOptionFormTable.initialize(rxOptionFormTableElement) Params

  • rxOptionFormTableElement WebElement - Web element to become an rxOptionFormTable object.

Returns: rxOptionFormTable - Page object representing the rxOptionFormTable object.
#rxForm Members

##rxForm.currencyToPennies(currencyString) Transform currencyString (USD) to an integer representing pennies. Built to reverse Angular's 'currency' filter. If your currency string includes fractions of a penny, that precision will be lost!

Params

  • currencyString string - Raw text as output by Angular's currency filter.

Example

encore.rxForm.currencyToPennies('$0.01')      ==  1
encore.rxForm.currencyToPennies('$0.019')     ==  1
encore.rxForm.currencyToPennies('$100 CAN')   ==  10000
encore.rxForm.currencyToPennies('($100 AUS)') == -10000
encore.rxForm.currencyToPennies('($1.011)')   == -101
encore.rxForm.currencyToPennies('$1.10')      ==  110

##rxForm.slowClick(elem) Equivalent to browser.actions().mouseDown(elem).mouseUp().perform();. This function should be used when dealing with odd or unusual behavior while interacting with click events that don't seem to work right. Either the element does not appear to respond to a normal .click() call, or the element is responding to more than one click event. This typically happens more often in Firefox than in other browsers. See select for an example of a function that will slow click an element to achieve consistent behavior.

Params

  • elem WebElement - Web element to "slow click".

Returns: undefined
##rxForm.dropdown Members

###dropdown.options Returns: Array.<string> - The text of each option element in the dropdown.
###dropdown.selectedOption Returns: option - Page object representing the currently selected option.
###dropdown.optionCount() Returns: number - The number of options in the dropdown.
###dropdown.optionExists(optionText) Params

  • optionText string - The text to check for existence in the dropdown.

Returns: boolean - Whether or not the option exists.
###dropdown.select(optionText) Params

  • optionText string - Partial or total string matching the desired option to select.

Returns: undefined
Example

var dropdown = encore.rxForm.dropdown.initialize($('#country-select'));
dropdown.select('United States');

###dropdown.initialize(selectElement) Params

  • selectElement WebElement - Should be a <select> tag.

Returns: dropdown - Page object representing a dropdown.
###dropdown.option Params

  • optionText string - Partial or total string matching the desired option to select.

Returns: option - Page object representing an option.
Members

####option.text Returns: string - The text inside of the current option.
####option.value Returns: string - The "value" attribute from the option html tag.
####option.select() Selects the option from the dropdown.

Returns: undefined
####option.isSelected() Returns: Boolean - Whether or no the option is currently the selected option.
##rxForm.checkbox Members

###checkbox.initialize(checkboxElement) Params

  • checkboxElement WebElement - Should be an <input> tag.

Returns: checkbox - Page object representing a checkbox.
###checkbox.isSelected() Abstraction over checkboxObject.rootElement.isSelected() to keep things shorter.

Returns: boolean - Whether or not the checkbox is currently selected.
###checkbox.select() Selects the current checkbox.

Returns: undefined
###checkbox.unselect() Unselects the current checkbox.

Returns: undefined
##rxForm.radioButton Members

###radioButton.initialize(radioElement) Params

  • radioElement WebElement - Should be an <input> tag.

Returns: radioButton - Page object representing a radio button.
###radioButton.isSelected() Abstraction over radioObject.rootElement.isSelected() to keep things shorter.

Returns: boolean - Whether or not the radio button is currently selected.
###radioButton.select() Selects the current radio button.

Returns: undefined
##rxForm.form Members

###form.fill(reference, formData) Set value in formData to the page object's current method key. Aids in filling out form data via javascript objects. For an example of this in use, see encore-ui's end to end tests.

Params

  • reference Object - Context to evaluate under as this (typically, this).
  • formData Object - Key-value pairs of deeply-nested form items, and their values to fill.

Example

yourPage.fill({
    aTextbox: 'My Name',
    aRadioButton: 'Second Option'
    aSelectDropdown: 'My Choice'
    aModule: {
        hasMethods: 'Can Accept Input Too',
        deepNesting: {
            might: 'be overkill at this level'
        }
    }
});

#rxOptionFormTable Members

##rxOptionFormTable.emptyMessage Returns: string | null - The currently displayed empty message label text, or null if not present.
##rxOptionFormTable.selectedRow Will default to the first selected row if many are selected. Be certain you have a selected row before calling this, or a NoSuchElementError will be thrown.

Returns: row - Page object representing a row.
##rxOptionFormTable.columnNames Returns: Array.<string> - Every column heading's text, as an array.
##rxOptionFormTable.selections Return a list of row indexes that are currently selected. Get the row yourself if you need more information about the row's contents.

Returns: Array.<number> - All selected rows' indexes from the rxOptionFormTable.
##rxOptionFormTable.isEmpty() Returns: boolean - Whether or not the table's the empty message label is currently present.
##rxOptionFormTable.columnData(columnName, [customFn]) Return the value of the cells found under columnName, using getText by default. For more control, pass in a customFn.

Params

  • columnName string - Column name containing the cell elements to be retrieved.
  • [customFn=getText()] function - Special work to be done on the column's cell elements.

Returns: * | Array.<string> - Array of return values specified in customFn, or an array of strings from getText()
Example

// three rows, with ['$0.00', '$1.00', '$2.00'] in their cells, respectively.
var penniesData = [0, 100, 200];
var penniesFn = function (cellElements) {
    return cellElements.map(function (cellElement) {
        return cellElement.getText().then(rxForm.currencyToPennies);
    });
};

// without the second argument, each cell will have `.getText()` called on it
expect(optionTable.columnData('Surcharge', penniesFn)).to.eventually.eql(penniesData);

##rxOptionFormTable.unselectAll() Unselects every row in the rxOptionFormTable.

Returns: undefined
##rxOptionFormTable.unselectByColumnText(columnName, columnText) Unselect a row by the columnName that contains columnText. This function uses cssContainingText, be certain your column name and text is unique.

Params

  • columnName string - Name of the column that contains the cell to select.
  • columnText string - Cell text that uniquely identifies the selection.

Returns: undefined
##rxOptionFormTable.unselectMany(selections) Unselect options where each { columnName: columnText } in selections is passed to unselectByColumnText.

Params

  • selections Array.<Object> - Array of single key-value pairs to unselect.

Returns: undefined
Example

unselectMany([{ 'Name': 'Item 1' },
              { 'Name': 'Item 2' }]);

##rxOptionFormTable.selectByColumnText(columnName, columnText) Select a row by the columnName that contains columnText. This function uses cssContainingText, be certain your column name and text is unique.

Params

  • columnName string - Name of the column that contains the cell to select.
  • columnText string - Cell text that uniquely identifies the selection.

Returns: undefined
##rxOptionFormTable.selectMany(selections) Select options where each { columnName: columnText } in selections is passed to selectByColumnText.

Params

  • selections Array.<Object> - Array of single key-value pairs to select.

Returns: undefined
Example

selectMany([{ 'Name': 'Item 1' },
            { 'Name': 'Item 2' }]);

##rxOptionFormTable.row Params

  • rowIndex number - Index of the row in the table.

Returns: row - Page object representing a row.
Members

###row.selectInput Since checkboxes are a superset of radio input elements, a checkbox is used.

Returns: checkbox - Page object representing a checkbox.
###row.isSelected() Returns: boolean - Whether or not the row is currently selected.
###row.isCurrent() Returns: boolean - Whether or not the row is visually marked as "current".
###row.cell(columnName, [customFn]) Return the value of the cell by columnName, using getText by default. For more control, pass in a customFn. The reason columnName is used, as opposed to by binding, is due to some complexity contained within the getContent function in the rxOptionFormTable directive. Link to the getContent function. There are columns that may contain static data (or expressions to be evaluated against $scope) for every row, and those data items are never bound to $scope. Although the column.keys that are passed into $scope.getContent that contain angular expressions can be located by binding, there are cases when plain text or HTML gets passed in. These never get bound to $scope. They can, however, be located by querying the column name via CSS selector, so that's used instead.

Params

  • columnName string - Column name to grab the current row's cell under.
  • [customFn=getText()] function - Special work to be done to the resulting cellElement.

###row.select() Selects the current row.

Returns: undefined
###row.unselect() Unselects the current row.

Returns: undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment