程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了获取 Angular 表格行数据大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决获取 Angular 表格行数据?@H_450_1@ 开发过程中遇到获取 Angular 表格行数据的问题如何解决?下面主要结合日常开发的经验,给出你关于获取 Angular 表格行数据的解决方法建议,希望对你解决获取 Angular 表格行数据有所启发或帮助;

我想获取 Angular 表格行数据。整页来源:https://pastebin.com/JszeSf8q(我不得不剪掉开头,因为它很大)。我有这张桌子:

<div class="ag-center-cols-container" ref="eCenterContainer" role="rowgroup" unSELEctable="on" style="wIDth: 700px; height: 50px;">
   <div role="row" row-index="0" aria-rowindex="2" row-ID="0" comp-ID="130" class="ag-row ag-row-no-focus ag-row-even ag-row-level-0 ag-row-position-absolute ag-row-first ag-row-last" aria-SELEcted="false" style="height: 50px; transform: translateY(0pX); " aria-label="Press SPACE to SELEct this row.">
      <div tabindex="-1" unSELEctable="on" role="grIDcell" aria-colindex="4" comp-ID="138" col-ID="accessorialExpectedUOMShortname" class="ag-cell ag-cell-not-inline-ediTing ag-cell-auto-height ag-cell-value" style="wIDth: 100px; left: 600px;  ">m</div>
      <div tabindex="-1" unSELEctable="on" role="grIDcell" aria-colindex="1" comp-ID="131" col-ID="operationCodename" class="ag-cell ag-cell-not-inline-ediTing ag-cell-auto-height ag-cell-value" style="wIDth: 300px; left: 0px;  ">Accessorial Charge</div>
      <div tabindex="-1" unSELEctable="on" role="grIDcell" aria-colindex="2" comp-ID="132" col-ID="accessorialExpectedamount" class="ag-cell ag-cell-not-inline-ediTing ag-cell-auto-height ag-cell-value" style="wIDth: 150px; left: 300px;  ">120.00000000</div>
      <div tabindex="-1" unSELEctable="on" role="grIDcell" aria-colindex="3" comp-ID="133" col-ID="accessorialActualamount" class="ag-cell ag-cell-not-inline-ediTing ag-cell-auto-height ag-cell-value" style="wIDth: 150px; left: 450px;  ">110.00000000</div>
   </div>
</div>

@R_450_9890@:

WebElement accessorialExpectedUOMShortnameWebElement = driver.findElement(By.xpath("//div[@col-ID='accessorialExpectedUOMShortname']"));
        assertEquals(accessorialExpectedUOMShortnameWebElement.getText(),"UOM");

        WebElement operationCodenameWebElement = driver.findElement(By.xpath("//div[@col-ID='operationCodename']"));
        assertEquals(operationCodenameWebElement.getText(),"Operation Code");

        WebElement accessorialExpectedamountWebElement = driver.findElement(By.xpath("//div[@col-ID='accessorialExpectedamount']"));
        assertEquals(accessorialExpectedamountWebElement.getText(),"Expected");

        WebElement accessorialActualamountWebElement = driver.findElement(By.xpath("//div[@col-ID='accessorialActualamount']"));
        assertEquals(accessorialActualamountWebElement.getText(),"Actual");

我得到了表格标签。你知道我如何获得表格行值吗?

解决方法@H_450_1@

看看是否有效


List<WebElement> tableRows = driver.findElements(By.xpath(".//div[@class='ag-center-cols-container']/div/div"));
    for (WebElement e : tableRows) {
        if (e.getAttribute("col-id").equalsIgnoreCase("accessorialExpectedamount")
                    || e.getAttribute("col-id").equalsIgnoreCase("accessorialActualamount")) 
                         System.out.println(e.getText());
            }
        }
         

大佬总结

以上是大佬教程为你收集整理的获取 Angular 表格行数据全部内容,希望文章能够帮你解决获取 Angular 表格行数据所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。