gpt4 book ai didi

angularjs - 如何使用 Protractor 从无限滚动的 ng-grid 中的所有行和列中获取文本?

转载 作者:行者123 更新时间:2023-12-02 03:15:07 24 4
gpt4 key购买 nike

我正在尝试编写一个函数,该函数返回数组中的完整网格内容。我们的 ng-grid 可以无限滚动行,也可以滚动列。

我在这里找到了滚动的答案 Protractor: Scrolling a table and testing for infinite scroll

但我希望完全滚动网格并获取数据,以便在将过滤器应用于网格时验证数据。

非常感谢您对此的任何帮助,谢谢

行的示例 HTML 代码

<div class="ag-body" style="padding-top: 25px; padding-bottom: 30px;">
<div class="ag-pinned-left-cols-viewport" style="display: inline; height: 245px;">
<div class="ag-pinned-left-cols-container" style="width: 480px; height: 1830px; top: 0px;">
<div class="ag-row ag-row-no-focus ag-row-even ag-row-level-0 ag-row-id-111 ag-row-index-10" style=" top: 300px; height: 30px;" row-id="111" row="10" v_element_id="19490">
<div class="ag-cell ag-cell-no-focus ag-cell-value" style=" left: 0px; width: 35px;" colid="id" v_element_id="19491">
<div class="ag-cell ag-cell-no-focus ag-cell-value" style=" left: 35px; width: 245px;" colid="title" v_element_id="19492">June12-AA-3</div>
<div class="ag-cell ag-cell-no-focus ag-cell-value" style=" left: 280px; width: 200px;" colid="operation_status_enum" v_element_id="19493">INVALID</div>
</div>
<div class="ag-row ag-row-no-focus ag-row-odd ag-row-level-0 ag-row-id-110 ag-row-index-9" style=" top: 270px; height: 30px;" row-id="110" row="9" v_element_id="20136">
<div class="ag-row ag-row-no-focus ag-row-even ag-row-level-0 ag-row-id-109 ag-row-index-8" style=" top: 240px; height: 30px;" row-id="109" row="8" v_element_id="20153">
<div class="ag-row ag-row-no-focus ag-row-even ag-row-level-0 ag-row-id-107 ag-row-index-6" style=" top: 180px; height: 30px;" row-id="107" row="6" v_element_id="20170">
<div class="ag-row ag-row-no-focus ag-row-odd ag-row-level-0 ag-row-id-108 ag-row-index-7" style=" top: 210px; height: 30px;" row-id="108" row="7" v_element_id="20187">
<div class="ag-row ag-row-no-focus ag-row-even ag-row-level-0 ag-row-id-105 ag-row-index-4" style=" top: 120px; height: 30px;" row-id="105" row="4" v_element_id="20204">
<div class="ag-row ag-row-no-focus ag-row-odd ag-row-level-0 ag-row-id-106 ag-row-index-5" style=" top: 150px; height: 30px;" row-id="106" row="5" v_element_id="20221">
<div class="ag-row ag-row-no-focus ag-row-odd ag-row-level-0 ag-row-id-104 ag-row-index-3" style=" top: 90px; height: 30px;" row-id="104" row="3" v_element_id="20238">
<div class="ag-row ag-row-no-focus ag-row-odd ag-row-level-0 ag-row-id-102 ag-row-index-1" style=" top: 30px; height: 30px;" row-id="102" row="1" v_element_id="20255">
<div class="ag-row ag-row-no-focus ag-row-even ag-row-level-0 ag-row-id-103 ag-row-index-2" style=" top: 60px; height: 30px;" row-id="102" row="1" v_element_id="20258">

最佳答案

您需要从 dom 中找到最后一行并使用 scrollintoview javascript 函数。请在下面找到示例。

var last_row=element.all(by.css(".ag-row")).last() //this will give you the last row from the grid
browser.executeScript("arguments[0].scrollIntoView();",last_row.getWebElement());

这将滚动整个网格。现在你可以从行中获取所有文本
element.all(by.css(".ag-row")).getText().then(function(RowValueArray) { 
//do whatever you want to do with the values.
})

希望对你有帮助!

关于angularjs - 如何使用 Protractor 从无限滚动的 ng-grid 中的所有行和列中获取文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37468198/

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