protractor-uisref-locator

Adds a locator to a protractor instance that finds elements by their ui-sref attribute.

Usage no npm install needed!

<script type="module">
  import protractorUisrefLocator from 'https://cdn.skypack.dev/protractor-uisref-locator';
</script>

README

protractor-uisref-locator

Adds a locator to a protractor instance that finds elements by their ui-sref attribute.

Installation

$ npm install protractor-uisref-locator

Usage

onPrepare: function () {
  // Your other stuff.
  require('protractor-uisref-locator')(protractor);
}

The locator will be available in your specs as by.uiSref(toState).

toState is a String that represents a ui-router state.

Examples

element(by.uiSref('users.show({id: 42})'));

element.all(by.uiSref('users.index')).then(function (elems) {
  // elems contains all the elements found that match the given ui-sref.
});

// Get elements that match the given ui-sref and that are within the element with id='users'.
element(by.css('#users')).element(by.uiSref('users.index'))

Tests

Run each command on a separate terminal window.

$ npm run start

$ npm run webdriver

$ npm run test