...">

How can I get the parameter value in xpath and not the displayed value?

Consider this example

<select>
<option value="http://www.test1.com"> 1 </option>
<option value="http://www.test2.com"> 2 </option>
<option value="http://www.test3.com"> 3 </option>
</select>

How do I get the xpath parameter value, not the mapping? Meaning, I want to get the value of the option element - http://www.test1.com , and not 1, 2, or 3.

+3
source share
2 answers

By position:

/select/option[1]/@value

By content:

/select/option[.=1]/@value

or

/select/option[normalize-space()='1']/@value
+5
source

If you need a set of all values, just use

/select/option/@value
+2
source

Source: https://habr.com/ru/post/1775229/


All Articles