如何使用selenium中字段集中的图例定位单选按钮



试图找到一种方法来定位特定字段集图例下的单选按钮。该网页有18个字段集,唯一的区别是图例

<fieldset class="radio-group radio-standard">
<legend>Legend example 1</legend>
<ul class="rg-list">
<li class="rg-item"><label class="radio-button"><input class="rb-input" type="radio" name="feature-12-0" value="none" checked=""><span aria-hidden="true" class="rb-design"></span><span class="rb-label">None</span></label></li>
<li class="rg-item"><label class="radio-button"><input class="rb-input" type="radio" name="feature-12-0" value="RO"><span aria-hidden="true" class="rb-design"></span><span class="rb-label">Read Only</span></label></li>
<li class="rg-item"><label class="radio-button"><input class="rb-input" type="radio" name="feature-12-0" value="RW"><span aria-hidden="true" class="rb-design"></span><span class="rb-label">Read/Write</span></label></li>
</ul>
</fieldset>

我可以使用以下xpath定位图例:("//legend[contains(.,'Legend example 1')]

定位";无";使用此xpath的单选按钮://label[contains(.,'None')]/input");

然而,我不太确定如何使用单选值将两者链接到单选按钮。

有什么想法吗?

提前感谢:(

试试这个:

//legend[.='Legend example 1']/following-sibling::ul//label[.='None']/input

最新更新