Skip to content

Latest commit

 

History

History
85 lines (72 loc) · 4.47 KB

angularJS-selector.md

File metadata and controls

85 lines (72 loc) · 4.47 KB

AngularJS selector extentions

AngularJSSelector contains a set of static methods to search for an HTML element by the specified binding (byModel, byBinding and etc.).

Usage

import { AngularJSSelector } from 'testcafe-angular-selectors';
import { Selector } from 'testcafe';

fixture `TestFixture`
    .page('http://todomvc.com/examples/angularjs/');

test('add new item', async t => {
    await t
        .typeText(AngularJSSelector.byModel('newTodo'), 'new item')
        .pressKey('enter')
        .expect(Selector('#todo-list').visible).ok();
});

See more examples here.

API

byBinding

Find elements by text binding. Does a partial match, so any elements bound to variables containing the input string will be returned.

AngularJSSelector.byBinding(bindingDescriptor, parentSelector)
Parameter Description
bindingDescriptor The JavaScript expression to which the element's textContent is bound.
parentSelector (optional) A TestCafe selector. If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.

We don't support deprecated syntax AngularJSSelector.byBinding('{{person.name}}')

byExactBinding

Find elements by exact binding.

AngularJSSelector.byExactBinding(bindingDescriptor, parentSelector)
Parameter Description
bindingDescriptor The JavaScript expression to which the element's textContent is bound.
parentSelector (optional) A TestCafe selector. If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.

byModel

Find elements by 'ng-model' expression

AngularJSSelector.byModel(model, parentSelector)
Parameter Description
model The JavaScript expression used to bind a property on the scope to an input, select, textarea (or a custom form control).
parentSelector (optional) A TestCafe selector. If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.

byOptions

Find elements by 'ng-options' expression.

AngularJSSelector.byOptions(optionsDescriptor, parentSelector)
Parameter Description
optionsDescriptor The JavaScript expression used to generate a list of elements for the element.
parentSelector (optional) A TestCafe selector. If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.

byRepeater

Find elements by repeater. Does a partial match, so any elements bound to variables containing the input string will be returned.

AngularJSSelector.byRepeater(repeatDescriptor, parentSelector)
Parameter Description
repeatDescriptor The JavaScript expression used to instantiate a template.
parentSelector (optional) A TestCafe selector. If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.

byExactRepeat

Find elements by exact repeater.

AngularJSSelector.byExactRepeater(repeatDescriptor, parentSelector)
Parameter Description
repeatDescriptor The JavaScript expression used to instantiate a template.
parentSelector (optional) A TestCafe selector. If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.