如何使用表格而不是使用量角器的中继器获取网格上的寄存器数量?

时间:2016-08-09 14:26:45

标签: javascript protractor

我有一个网格,上面有5个元素。我有旅行的感情。我需要在我的网格中获取项目的总数,但它使用对象。我该怎么办?

我不懂HTML,它是否使用对象? 我不知道怎么做。

**部分HTML:**

<div class="ui-datatable-tablewrapper">
                <table>
                    <thead>
                        <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><tr class="ui-state-default">
                            <!--template bindings={
  "ng-reflect-ng-for-of": "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
}--><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Tipo de Norma</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Número</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Ano</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Descrição</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Status</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Data de Publicação</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="ui-state-default ui-unselectable-text" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title">Ativo</span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th><th ng-reflect-raw-class="[object Object]" class="kebab-column ui-state-default ui-unselectable-text" ng-reflect-initial-classes="kebab-column" draggable="false" style="display: table-cell;">
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-column-title"></span>
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                            </th>
                        </tr>
                        <!--template bindings={
  "ng-reflect-ng-for-of": null
}-->
                    </thead>
                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                    <tbody class="ui-datatable-data ui-widget-content">
                        <!--template bindings={
  "ng-reflect-ng-for-of": "[object Object],[object Object],[object Object],[object Object],[object Object]"
}-->
                            <tr class="ui-widget-content ui-datatable-even" ng-reflect-raw-class="[object Object]" ng-reflect-initial-classes="ui-widget-content">
                                <!--template bindings={
  "ng-reflect-ng-for-of": "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
}--><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">Lei</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">1800</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">1800</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">Teste para ver se norma esta desativada</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">Revogado</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">01/08/2016</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">Inativo</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" class="kebab-column" ng-reflect-initial-classes="kebab-column" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "[object Object]"
}--><span class="ui-cell-data">
                                        <p-columntemplateloader ng-reflect-column="[object Object]" ng-reflect-row-data="[object Object]" ng-reflect-row-index="0"></p-columntemplateloader>

        <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><button class="btn btn-flat btn-no-text btn-kebab-view">
          <i class="zmdi zmdi-more-vert"></i>
        </button>

        <!--template bindings={
  "ng-reflect-ng-if": null
}-->


                                    </span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td>
                            </tr>
                            <!--template bindings={
  "ng-reflect-ng-if": null
}-->

                            <tr class="ui-widget-content ui-datatable-odd" ng-reflect-raw-class="[object Object]" ng-reflect-initial-classes="ui-widget-content">
                                <!--template bindings={
  "ng-reflect-ng-for-of": "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
}--><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">Resolução</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">333</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">2011</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">teste</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                </td><td ng-reflect-raw-class="[object Object]" style="display: table-cell;">
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><span class="ui-cell-data">Revogado</span>
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->
                                    <!--template bindings={
  "ng-reflect-ng-if": "false"
}-->

。 。

            </div>

1 个答案:

答案 0 :(得分:1)

Protractor只是Selenium的一个有用的包装器,你不应该访问任何JavaScript Object来计算某些东西。为了计算表格的行,请使用element.all(by.css('table td'))

如果你有分页,这会使计数变得有点棘手。您可以将上述呼叫包含在.each loop中。在循环内你进入下一页,等到它加载然后计数。