<div class="btm0">Question 1
</div><span class="small"></span>
<span id="form2">
<span id="form2:j_idt4598" style="display: none;"></span><ul id="form2:radioButton" class="controls full-width">
<li>
<input class=" firepath-matching-node" name="form2:radioButton" id="form2:radioButton:0" type="radio"><label for="form2:radioButton:0"> Yes</label></li>
<li>
<input class=" firepath-matching-node" name="form2:radioButton" id="form2:radioButton:1" type="radio"><label for="form2:radioButton:1"> No</label></li>
</ul>
<span id="form2:errMessage"></span>
</span>
<div class="btm0">Question 2
</div><span class="small"></span>
<span id="form1">
<span id="form1:j_idt4617" style="display: none;"></span><ul id="form1:radioButton" class="controls full-width">
<li>
<input class=" firepath-matching-node" name="form1:radioButton" id="form1:radioButton:0" type="radio"><label for="form1:radioButton:0"> Yes</label></li>
<li>
<input class=" firepath-matching-node" name="form1:radioButton" id="form1:radioButton:1" type="radio"><label for="form1:radioButton:1"> No</label>
これはラベルとオプションボタンを持つ上記の単純なページです。XPathを使用してラジオボタンを選択してください
XPathを使用して「質問1 - はい」を選択します。
固有のXPathを作成する簡単な方法がありますが、正しい「はい」オプション(質問1または質問2)を選択しますか?私はXPathをハードコードしたくありません。
私は部分的な解決策を試してみたが、私は唯一の2番目の「YES」オプションを選択します:
//*[contains(text(),'Question 1')]/following::label[contains(text(),'Yes')]
Thanks Markus、これは私の問題の解決策です。 – Vikram