According to this link : https://docs.angularjs.org/api/ng/function/angular.element, the method "find()" allows to find an HTML element by tag name.
I tried this in my code :
element.find('button').click();
And my HTML code is :
<button ng-click="getMessage()">Request service as {{name}}</button>
But the button is never clicked. I don't want to use classes, ids, or weird selectors. I think I'm just missing something but I'm unable to find exchaustive docuementation (about "finders").
Thank you for your help,
You are confusing AngularJS's
angular.elementclass with Protractor's global functionelementof the same name.Protractor creates a few global functions such as
browser,element,byandprotractor.elementis a function and not an object. As such, they have no property methods likefind(..). Theelementfunction takes a selector object as an argument. To create a selector object you have to use the globalbyobject. This object contains a number of handy selector functions such asid,model,binding, etc.. etc..If you want to use jQuery/CSS selector syntax. You can use the
by.css()function.Example;
This will find the first
buttontag and click it. Useelement.all(...)to find all of them.You can also narrow this to only buttons that bind the scope variable
nameMore on locators:
https://github.com/angular/protractor/blob/master/docs/locators.md