Attractor search element with multiple state div in AngularJS

I am trying to get a list of items by checking multiple conditions, for example I want to get the number of files

Example, if I run the code below I get result 6:

element.all(by.repeater('releasenotefile in release.releasenotefiles')).count().then(function(count) {
      console.log(count);
});

      

But I only want the Release 1.4 count and I tried the code below and it returns 0:

element.all(by.cssContainingText('.list_subhead',"1.04 Release Title")).all(by.repeater('releasenotefile in release.releasenotefiles')).count().then(function(count) {
                  console.log(count);
});

      

Here is my div structure:

------------
Release 1.4 <div class="accordion-section panel clearfix ng-scope" ng-repeat="release in app.releases" ng-class="{active: $first}">

Release note <div class="vz_list_container_01">

    File 1 <li class="bp ng-scope" ng-repeat="releasenotefile in release.releasenotefiles">
    File 2 
--------------

------------
Release 1.3

Release note

    File 3

--------------

------------
Release 1.2

Release note
    File 4 
    File 5
    File 6 
--------------

      

+3


source to share


1 answer


I would get the whole relay and use filter()

+ evaluate()

to filter the results for version 1.4 only:

element.all(by.repeater('releasenotefile in release.releasenotefiles')).filter(function (elm) {
    return elm.evaluate("release").then(function (release) {
        return release.number === "1.4";
    });
});

      



Note that for the sake of example I'm assuming the release.number

in-scope variable is the release version number - check which in-scope variable is responsible for storing the release version number.

+1


source







All Articles