I am getting this xpath error in eclipse , i think xpath is correct(1 of 1) but why am getting error

huangapple go评论76阅读模式
英文:

I am getting this xpath error in eclipse , i think xpath is correct(1 of 1) but why am getting error

问题

<!-- 开始代码片段: 不隐藏 JS 控制台: 是 使用 Babel: 否 -->

<!-- 语言: HTML -->

<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\" Combination refrigerator w/ ice maker reversib')]")).click();
英文:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

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

<!-- end snippet -->

xpath:

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

答案1

得分: 1

试试这个:

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

英文:

You need to escape the " after 24 because it is handle like a quotation mark.
Try this:

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

huangapple
  • 本文由 发表于 2020年8月6日 20:10:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63283337.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定