我有以下HTML:
<div class="modal-content" uib-modal-transclude="">
<form class="ng-pristine ng-scope ng-invalid ng-invalid-required ng-valid-maxlength ng-valid-leftover-text" pb-submit="form.$valid && ctrl.submit()" name="form" novalidate="">
<div class="modal-header">
<div class="modal-body">
<!-- ngIf: authentication.user.isCustomer -->
<div class="form-group ng-pristine ng-invalid ng-invalid-required ng-valid-maxlength" ng-form="">
<div class="form-group ng-pristine ng-invalid ng-invalid-required" ng-form="">
<label class="control-label" for="pill">Pill</label>
<select id="pill" class="form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" required="" ng-disabled="ctrl.readOnly" ng-options="i.name as i.name for i in ctrl.pills" ng-model="ctrl.group.pill">
<option value="?" selected="selected"/>
<option label="Red Pill" value="Red Pill">Red Pill</option>
<option label="Blue Pill" value="string:Blue Pill">Blue Pill</option>
我正在使用Selenium WebDriver和Ruby以及一些宝石,包括Capybara。我试图通过下拉选择器选择红色药丸(显然)。到目前为止,我尝试了以下内容:
find('#pill').find(:xpath, "//*[@id='pill']/option[2]").select_option
find(:xpath, "//*[@id='pill']/option[2]").select_option
select_by(:value, 'string:Red Pill')
select('Red Pill', from: 'pill')
find('option', :text => 'Red Pill').click
find(:xpath, "//div[contains(text(), 'Red Pill')]/..").click
Ruby接受上述命令(即语法正常),甚至参与下拉列表(当我点击它时,显示所有选项),但它似乎不知道该做什么,只是继续前进进行下一步而不做任何选择或以其他方式失败。
我怀疑这是因为Angular 1,所以这在技术上不是下拉列表而是其他内容。有什么想法吗?
答案 0 :(得分:0)
首先(:选项,&#34; Red Pill&#34;)。select_option