en utilisant xpath, comment sélectionnez-vous la n-ième option?xpath: comment sélectionner la nième option?
<select>
<option></option>
<option></option>
</select>
/html/corps/select option/
en utilisant xpath, comment sélectionnez-vous la n-ième option?xpath: comment sélectionner la nième option?
<select>
<option></option>
<option></option>
</select>
/html/corps/select option/
ce que vous avez est correct [?]:
pour la 2ème option, utilisez:
/html/body/select/option[2]
ou
/html/body/select/option[position()=2]
Voir http://www.w3.org/TR/xpath#location-paths
Modifier
Notez que la suppose que vous ci-dessus ont une structure comme:
<html>
<body>
<select>
<option></option>
<option></option>
</select>
</body>
</html>
Si votre sélection est à l'intérieur d'un parent autre que le corps, alors soit vous voulez utiliser quelque chose comme:
/html/body/div[@class='header']/select/option[2]
ou
//select/option[2]
Bien sûr, puisque votre sélection a probablement un attribut de nom, vous pouvez l'utiliser, par ex.
//select[@name='myselect']/option[2]