3

I am trying to get list of items by checking multiple condition, example want to get file count

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

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

But I want count of Release 1.4 only 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 
--------------
1
  • Your query looks valid, though I'd suggest that you write element(by.cssContainingText(...)).all(...) and check that element(by.cssContainingText(...)) really finds what you need using protractor --elementExplorer Commented May 11, 2015 at 8:43

1 Answer 1

1

I would get everything by repeater and use filter()+evaluate() to filter out results for release 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 an example, I'm assuming release.number variable in scope is a release version number - check what variable in the scope is responsible for keeping the release version number.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.