开发者

Get XPATH expression with 2 spans in a div

开发者 https://www.devze.com 2023-03-21 00:04 出处:网络
<div class=\"grid_12\"> <span class=\"gwt-InlineLabel\">What ever</span> &nbsp; (
<div class="grid_12">
<span class="gwt-InlineLabel">What ever</span>
 &nbsp;
(
<span class="gwt-InlineLabel">Endorsement</span> 
&nbsp;-&nbsp;
<span class="gwt-InlineLabel">Draft</span>)
</d开发者_运维问答iv>

I need an dynamic XPATH expression to assert the text " What ever Endorsement Draft"


You can use //div[@class='grid_12']//text(), but if you know the depth of the div, you can avoid using the first //.


Answer of Daniel Haley suggests to use //div[@class='grid_12']//text() but it will match &nbsp; too.

A better idea is to returns texts of spans only:

//div[@class='grid_12']/span/text()

(that will return ["what ever", "Endorsement", "Draft"]) and then concat them.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号