<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
Я хочу выбрать «Вопрос 1 - Да», используя XPath.
Есть ли простой способ создать уникальный XPath, который выберет правильный вариант «ДА» (который может быть вопросом 1 или вопросом 2)? Я не хочу жестко кодировать XPath.
Я опробовал частичное решение, но я только получить вариант второго «ДА» выбран:
//*[contains(text(),'Question 1')]/following::label[contains(text(),'Yes')]
Thanks Markus, Это лучшее решение для моей проблемы. – Vikram