量角器在AngularJS中查找具有多个div条件的元素

时间:2022-10-04 01:21:42

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:

例如,如果我运行下面的代码,我得到结果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:

但我只想要1.4版本,我尝试了下面的代码,它返回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:

这是我的div结构:

------------
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 个解决方案

#1


I would get everything by repeater and use filter()+evaluate() to filter out results for release 1.4 only:

我会通过repeater获取所有内容并使用filter()+ evaluate()来过滤掉1.4版的结果:

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.

请注意,为了举例,我假设范围中的release.number变量是发布版本号 - 检查作用域中的哪个变量负责保留发行版本号。

#1


I would get everything by repeater and use filter()+evaluate() to filter out results for release 1.4 only:

我会通过repeater获取所有内容并使用filter()+ evaluate()来过滤掉1.4版的结果:

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.

请注意,为了举例,我假设范围中的release.number变量是发布版本号 - 检查作用域中的哪个变量负责保留发行版本号。