我无法使用Robot Framework点击radiobuttons。(和selenium2Library)

时间:2017-06-10 13:35:43

标签: selenium xpath selenium-webdriver radio-button robotframework

有人可以帮帮我吗?

实际上,单选按钮总是位于DOM 中,但它们在基于 ADDRESS 字段的页面上可见,因此如下所示 Pickup < / em>和 Delivery 时区相同,然后在页面上看不到radiobuttons: here

但如果它们(提货和交货时区)不同,则 RADIO BUTTONS 可见,如下所示:  here

现在在我的脚本中我尝试将所有单选按钮设置为NO,所以当我运行它时脚本会通过,但实际上无线电按钮保持不变。结果是PASS,如下所示 here

脚本运行后

和Chrome浏览器如下所示: here

这是我为等待和点击radiobuttons而编写的脚本:

`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

`

1 个答案:

答案 0 :(得分:0)

JavaScript执行程序为我工作,如下所示。

execute javascript document.getElementById('insurance_1').click()