【问题标题】:I am getting this xpath error in eclipse , i think xpath is correct(1 of 1) but why am getting error [closed]我在 eclipse 中收到此 xpath 错误,我认为 xpath 是正确的(1 of 1)但为什么会出现错误 [关闭]
【发布时间】:2020-11-26 16:50:27
【问题描述】:

<div class="u-grid">
<div class="u-truncate ng-binding ng-isolate-scope" ng-class="" ng-style="" tooltip="" tooltip-truncated="" ng-bind="$ctrl.parent.getProperty($ctrl.field, $ctrl.record)" xpath="1">24" Combination refrigerator w/ ice maker reversible door swing, Black</div>
</div>

xpath:

driver.findElement(By.xpath("//div[contains(text(),'24" 组合冰箱w/制冰机reversib')]")).click();

【问题讨论】:

  • 你遇到了什么错误?

标签: java testing selenium-webdriver automation automated-tests


【解决方案1】:

您需要将 24 之后的 " 转义,因为它的句柄类似于引号。 试试这个:

driver.findElement(By.xpath("//div[contains(text(),'24\" Combination refrigerator w/ ice maker reversib')]")).click();

【讨论】:

  • 谢谢trapzerapzerix问题解决了...!!!
猜你喜欢
  • 2015-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-13
  • 1970-01-01
  • 2018-06-22
  • 2016-01-01
相关资源
最近更新 更多