1.1.2 • Published 10 years ago
protractor-linkuisref-locator v1.1.2
protractor-linkuisref-locator
Adds a locator to a protractor instance that finds anchor
elements by their ui-sref
attribute.
Need a general (not just anchors) ui-sref
locator? See protractor-uisref-locator.
Installation
$ npm install protractor-linkuisref-locator
Usage
onPrepare: function () {
// Your other stuff.
require('protractor-linkuisref-locator')(protractor);
}
The locator will be available in your specs as by.linkUiSref(toState, [parentElement])
.
toState
is a String
that represents a ui-router state. Also supports data-
prefix.
parentElement
represents an HTML element
. It is optional and defaults to the document
element.
The locator returns:
null
if no anchor is found.- An
anchor
element if only one is found. - An
Array
of anchor elements if more than one is found.
Example Calls
by.linkUiSref('users.show({id: 42})', element(by.css('.users')));
by.linkUiSref('users.index.page({page: 2})');
Tests
You will run each command on a separate terminal window.
$ npm run start
$ npm run webdriver
$ npm run test