Get XPATH expression with 2 spans in a div
<div class="grid_12">
<span class="gwt-InlineLabel">What ever</span>
(
<span class="gwt-InlineLabel">Endorsement</span>
-
<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
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.
精彩评论