问题
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]")
回答1:
You can combine attribute selectors like this:
$('input[ng-model="vm.ist.educationVsInternship"][ng-value="true"]')
来源:https://stackoverflow.com/questions/32318396/how-to-find-element-by-two-attributes