Search code examples
angularjsprotractorangularjs-e2e

How to find element by two attributes


I have radio buttons like, how can I get the second one clicked finding first by ng-model then ng-value:

<input type="radio" ng-model="vm.ist.educationVsInternship" ng-value=false />

<input type="radio" ng-model="vm.ist.educationVsInternship" ng-value=true />

I tried something like

element(by.model('vm.ist.educationVsInternship')).all(by.css('[ng-value=true]')).click();

says and does not click any of them

more than one element found for locator by.model("vm.ist.educationVsInternship") - the first result will be used

and this:

element(by.model('vm.ist.educationVsInternship')).element(by.css('[ng-value=true]')).click();

which gives me the following error message:

Failed: No element found using locator: By.cssSelector("[ng-value=true]")


Solution

  • You can combine attribute selectors like this:

    $('input[ng-model="vm.ist.educationVsInternship"][ng-value="true"]')