[英]How to locate and click Radio Button through the Label using Selenium and Java
[英]How to locate radio buttons using the legend within the fieldset in 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')]/ //label[contains(.,'None')]/input");
但是,我不太確定如何使用單選值將兩者鏈接到單選按鈕。
有任何想法嗎?
先感謝您:)
試試這個:
//legend[.='Legend example 1']/following-sibling::ul//label[.='None']/input
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.