Linking all operators to the protractor

My first question is ....

I try to bind all the statements into a protractor, but I get an error.

TypeError: Object [object Object] has no method 'all' 

I am looking at the API code on the next page

http://angular.imtqy.com/protractor/#/api?view=ElementArrayFinder.prototype.all

Which means you can use element.all (locator) .all (locator)

he gives it as an example

 var foo = element.all(by.css('.parent')).all(by.css('.foo')) 

my code seems very similar and I am confused why I am getting this error. I tried to structure the code in the same way as in the API example. I also tried doing element.all (locator) .element.all (locator).

My goal here is to take the Ng replay of AREFS; find one that has text equal to r_string (which is the string generated earlier and added to the page; expect the item to exist; click this item;

Some attempts:

  var parent = element.all(by.repeater('labgroup in LabGroupService.allLabGroups')); var child = parent.all(by.xpath('//option[text() = \'' + r_string + '\']')); expect(child.count()).toBe('1'); 

and

  var elem = element.all(by.repeater('labgroup in LabGroupService.allLabGroups')).all(by.xpath('//option[text() = \'' + r_string + '\']')); expect(elem.count()).toBe('1'); 

Finally, this is the HTML snippet I'm working with.

  <a ui-sref="root.user-management.labgroup({labgroupID: labgroup.id})" class="ng-binding" href="#/management/labgroup/43">1kvub4wgCvY9QfA</a> </dd><!-- end ngRepeat: labgroup in LabGroupService.allLabGroups --><dd ng-repeat="labgroup in LabGroupService.allLabGroups" class="ng-scope"> <a ui-sref="root.user-management.labgroup({labgroupID: labgroup.id})" class="ng-binding" href="#/management/labgroup/47">3PNsny8lUMlMwBw</a> </dd><!-- end ngRepeat: labgroup in LabGroupService.allLabGroups --><dd ng-repeat="labgroup in LabGroupService.allLabGroups" class="ng-scope"> <a ui-sref="root.user-management.labgroup({labgroupID: labgroup.id})" class="ng-binding" href="#/management/labgroup/42">c3NOI7Z3933ui3a</a> </dd><!-- end ngRepeat: labgroup in LabGroupService.allLabGroups --><dd ng-repeat="labgroup in LabGroupService.allLabGroups" class="ng-scope"> 

Edit ------------------------------------------- ------ ---------------------------------------

I'm starting to wonder if this is a version error or possibly a protractor error. In a debugging attempt, I literally included the source code from the API page.

  <div id='id1' class="parent"> <ul> <li class="foo">1a</li> <li class="baz">1b</li> </ul> </div> <div id='id2' class="parent"> <ul> <li class="foo">2a</li> <li class="bar">2b</li> </ul> </div> 

and an example from the original page.

 var foo = element.all(by.css('.parent')).all(by.css('.foo')) expect(foo.getText()).toEqual(['1a', '2a']) 

I am still getting the same error.

 TypeError: Object [object Object] has no method 'all' 

Edit 2 ------------------------------------------ ------ -------------------------------

I managed to solve this problem by adding "data-class = labgroup-link" to the actual html code and using this protractor code.

  element.all(by.css('[data-class="labgroup-link"]')).filter(function(elem, index) { return elem.getText().then(function(text) { return text === r_string; }); }).then(function(filteredElements) { expect(filteredElements[0].isPresent()).toBe(true); filteredElements[0].click(); ptor.sleep(100); }); 

Decision ----------------------------------------

I had to update the protractor to get the latest API.

+5
source share
1 answer

Transport> = 1.3.0

Should work: https://github.com/angular/protractor/blob/f7c3c370a239218f6143a/lib/protractor.js#L177

 var foo = element.all(by.css('.parent')).all(by.css('.foo')); 

Conveyor <1.3.0

ElementArrayFinder does not have an all method: https://github.com/angular/protractor/blob/master/docs/api.md#api-elementarrayfinder-prototype-get , therefore:

TypeError: Object [object Object] does not have a 'all' method

Maybe you want

 var foo = element(by.css('.parent')).all(by.css('.foo')); // or shorter var foo = $('.parent').$$('.foo'); 

Case insert

 var foo = element.all(by.css('.parent')).all(by.css('.foo')); 
+6
source

Source: https://habr.com/ru/post/1203505/


All Articles