簡體   English   中英

如何使用 selenium 中的字段集中的圖例定位單選按鈕

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM