gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 22:39:39 26 4
gpt4 key购买 nike

我有一个网格,上面有 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>

最佳答案

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

如果您有分页,这会使计数变得更加棘手。您可以将上述调用包装在 .each loop 中。在循环内,您将转到下一页,等待其加载,然后计数。

关于javascript - 如何使用表格而不是使用 Protractor 的中继器获取网格上的寄存器数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38853514/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com