使用 xpath 定位器在 CSS 中未设置标签时选择单选按钮
Selecting radio button when labels are not set in CSS using xpath locator
无法使用 robotframework
中的 xpath
定位器为以下 HTML
标签使用 ride(机器人框架)select 单选按钮。
<Pre>
<div class="controls">
<input checked="checked" data-val="true" data-val-required="The isPdfFormat field is required." id="isPdfFormat" name="isPdfFormat" value="true" type="radio"></input> PDF
<input checked="checked" id="isPdfFormat" name="isPdfFormat" value="false" type="radio"></input> CSV
</div>
</Pre>
请检查以下 xpath:
//input[normalize-space(following-sibling::text())='CSV' and @id='isPdfFormat']
您可以将此 Xpath 用于select第一个单选按钮
(.//*[@class='controls']/input)[1]
如果你想select第二个使用这个
(.//*[@class='controls']/input)[2]
如果 class 不是唯一的并且匹配 class 的元素更多,请尝试使用 Id
(.//*[@id='isPdfFormat'])[1]
无法使用 robotframework
中的 xpath
定位器为以下 HTML
标签使用 ride(机器人框架)select 单选按钮。
<Pre>
<div class="controls">
<input checked="checked" data-val="true" data-val-required="The isPdfFormat field is required." id="isPdfFormat" name="isPdfFormat" value="true" type="radio"></input> PDF
<input checked="checked" id="isPdfFormat" name="isPdfFormat" value="false" type="radio"></input> CSV
</div>
</Pre>
请检查以下 xpath:
//input[normalize-space(following-sibling::text())='CSV' and @id='isPdfFormat']
您可以将此 Xpath 用于select第一个单选按钮
(.//*[@class='controls']/input)[1]
如果你想select第二个使用这个
(.//*[@class='controls']/input)[2]
如果 class 不是唯一的并且匹配 class 的元素更多,请尝试使用 Id
(.//*[@id='isPdfFormat'])[1]