为什么在 for 循环的第二次迭代中找不到 XPATH

我目前正在进行自动化检查圆环图并迭代甜甜圈上的每种颜色,有一个功能,如果您将鼠标悬停在另一种颜色上,所有其他颜色的不透明度将增加30%。因此,我使用嵌套的for循环对此进行检查。

见下文

http://img1.mukewang.com/62ea2fd2000156f102000206.jpg

我的问题是在 for 循环的第二次迭代中找不到 xpath。但是当我试图手动搜索时,它是trhere,xpath是正确的。


任何人都可以在我的代码中看到问题?提前感谢您。


这是实际的 HTML:


<div _ngcontent-c23="" class="col-xs-12 col-sm-6 col-md-6 col-lg-4 space-column ng-star-inserted" data-index="0">

        <cws-cardbox _ngcontent-c23="" _nghost-c29="" class="Mutual Funds0" ng-reflect-ng-class="Mutual Funds0" ng-reflect-status="B"><div _ngcontent-c29="" class="card-status overdue" ng-reflect-klass="card-status" ng-reflect-ng-class="[object Object]">

</div>

<div _ngcontent-c29="" class="card-box">

  

              <div _ngcontent-c23="" class="policy">

                <span _ngcontent-c23="" class="planType" style="display: block;">Mutual Funds</span>

                <span _ngcontent-c23="" class="product" style="display: block;">

                  Affluence Builder Gold

                </span>

                <div _ngcontent-c23="" class="policy-no">

                    <label _ngcontent-c23="" class="policy-label">

                      Account No.:

                    </label>

                    <span _ngcontent-c23="" class="policy-value">8000 0000 03</span>

                </div>

              </div>

              <div _ngcontent-c23="" class="divider"></div>

              

              <!--bindings={

  "ng-reflect-ng-if": "false"

}-->


月关宝盒
浏览 151回答 1
1回答

慕的地8271018

我试图更改对象属性,它现在工作。我使用cssValues而不是检查对象是否存在。以下是上一个的变化...圈。感谢大家研究这个问题。&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //WebElement hoveredPortion = DriverUtils.getDriver().findElement(By.xpath("(*//div[@data-index = '" + dataIndex + "']/descendant::div//*[contains(@class, 'mli-donut-chart')]//*[contains(@transform,'translate')]//*[contains(@style,'fill-opacity: 0.3')])["+ y +"]"));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String notHoveredPortion = DriverUtils.getDriver().findElement(By.xpath("*//div[@data-index = '"+ dataIndex +"']/descendant::div//*[contains(@class, 'mli-donut-chart')]//*[contains(@transform,'translate')]//*[contains(@style,'fill-opacity')]")).getCssValue("fill-opacity");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("value of fill-opacity: " +notHoveredPortion);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if(hoveredPortion!=null) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(notHoveredPortion.equals("0.3")) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Reporter.log("Passed: allocation #: " + b, MessageTypes.Pass);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Reporter.log("Failed", MessageTypes.Fail);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java