【发布时间】:2017-11-12 10:08:33
【问题描述】:
谁能帮帮我?
实际上,单选按钮始终在 DOM 中,但它们基于 ADDRESS 字段在页面上可见,因此您可以在下面看到 Pickup 和 Delivery 时区相同,然后单选按钮在页面上不可见:
但如果它们(取货和送货时区)不同,则 RADIO BUTTONS 可见,如下所示: 。
现在在我的脚本中,我尝试将所有单选按钮设置为 NO,因此当我运行它时,脚本通过但实际上单选按钮保持不变。结果是PASS如下图
这是我为等待和单击单选按钮编写的脚本:
`wait until element is enabled id=exportclearance_1
page should contain radio button id=exportclearance_1
click element id=exportclearance_1
click element id=transitclearance_1
click element id=importclearance_1
click element id=insurance_1`
这是页面的 HTML:
`<div class="form-group">
<label class="col-sm-4 control-label" for="">
<div class="col-sm-6">
<input id="exportclearance_0" name="export_clearance" value="True" autocomplete="off" type="radio"/>
<label class="control-label control-label-light clearance" for="exportclearance_0">Yes</label>
<input id="exportclearance_1" name="export_clearance" value="False" autocomplete="off" type="radio"/>
<label class="control-label control-label-light clearance" for="exportclearance_1">No</label>
<br/>
</div>
</div>
<div id="exportclearance-textarea" style="display:none">
<div class="row col-sm-6 col-sm-offset-4">
<textarea id="field-exportclearance" class="form-control customs-field" cols="40" name="export_clearance_instructions" placeholder="Instructions for export clearance (E.g. Broker details, Customs number, etc.)" rows="2"/>
</div>
</div>
<div class="form-group">
<div id="transitclearance-textarea" style="display:none">
<div class="form-group">
<div id="importclearance-textarea" style="display:none">
</div>
<div class="form-group">
<div id="id_attachment_formset_parent">
<div class="form-group">
<di
`
【问题讨论】:
-
您可以尝试点击标签是/否。它可能有效。
-
如?我已经按照代码中的 id 点击了元素,所以
id=exportclearance_1表示我尝试点击“否”进行出口清关单选按钮。 @Murthi -
您正在点击输入标签,但我要求尝试使用标签标签。
-
“无法点击”是什么意思?看来您确实可以单击它们,因为您的脚本没有引发任何错误。您是否尝试过使用 Select Radio Button 关键字?
-
是的,我确实尝试过
select radio button export_clearance True,但这也没有用。 “无法单击”意味着尽管脚本没有抛出任何错误,但它没有单击提到的单选按钮(尽管我不确定为什么)。可能是脚本太快或其他原因,但我也尝试过 sleep 并等待元素,但没有运气。 @BryanOakley
标签: selenium xpath selenium-webdriver radio-button robotframework