我一直在测试使用量角器,除了通过css之外没有办法引用元素,因为它只提供了class属性.问题是有超过7个元素具有此类名称.因此我使用语法
element.all(by.css('h4.ng-binding')).first();
Run Code Online (Sandbox Code Playgroud)
对于第一个,它工作正常,但对其他人,它不起作用!我使用的逻辑也与第一个逻辑相同.这是我的代码片段,供其他人找到它们.
element.all(by.css('h4.ng-binding')).second();
element.all(by.css('h4.ng-binding')).third();
element.all(by.css('h4.ng-binding')).fourth();
element.all(by.css('h4.ng-binding')).fifth();
element.all(by.css('h4.ng-binding')).sixth();
element.all(by.css('h4.ng-binding')).seventh();
element.all(by.css('h4.ng-binding')).eighth();
Run Code Online (Sandbox Code Playgroud)