我正在尝试从选择字段中选择一个值:
<select class="form-control select required chosen-select" name="shopping_cart[kind]" id="shopping_cart_kind" style="display: none;">
<option value="">Selecione</option>
<option value="pdc">PDC</option>
<option value="normal">Cotação Normal</option>
<option value="emergency">Cotação Emergencial</option>
<option value="contract">Cotação para Contrato</option>
<option value="price_research">Pesquisa de Preço</option>
<option value="legal_purchase">Compra Judicial</option>
<option value="bidding_exemption">Dispensa de Licitação</option>
<option value="scheduled_delivery">Cotação para entrega programada</option></select>
在我的代码中,我试图设置第二个选项:
@type = @browser.select_list(id: "shopping_cart_kind")
@type.select 'PDC'
我收到此错误:
timed out after 30 seconds, waiting for {:id=>"shopping_cart_kind", :tag_name=>"select"} to become present (Watir::Wait::TimeoutError)
我尝试了以下替代方法,但它们不起作用:
通过javascript点击元素:
@ browser.execute_script(“ return arguments [0] .click();”,browser.link(:id =>'shopping_cart_kind')
按索引选择:
@ browser.select_list(id:“ shopping_cart_kind”,索引:1).select(“ PDC”) @ browser.select_list(id:“ shopping_cart_kind”)。option [1] .select
没有任何效果!
答案 0 :(得分:0)
您能尝试一下此代码,让我知道它是否有效吗?
@type = @browser.select_list(id: "shopping_cart_kind")
@type.option(text: 'PDC').select