AngularJSSelector
contains a set of static methods to search for an HTML element by the specified binding (byModel
, byBinding
and etc.).
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.
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}}')
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. |
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. |
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. |
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. |
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. |