无法使用Watir(Ruby)选择下拉选项

时间:2013-04-01 21:39:55

标签: ruby salesforce watir

我无法让Watir从下拉列表中选择正确的选项。我试图从中选择:

<select id="j_id0:theForm:ruleTypeSelector" onkeypress="return suppressEnter(event);" size="1" name="j_id0:theForm:ruleTypeSelector">
    <option value="ExecutionOrder">Pricing Administration</option>
    <option value="AccountSpecific">Account Specific Pricing</option>
    <option value="AssociatedProduct">Associated Product Pricing</option>
    <option value="MaintenanceProduct">Maintenance Product Pricing</option>
    <option value="Tiered">Tiered Pricing</option>
    <option value="Volume">Volume Pricing</option>
</select>

我需要选择第二个选项AccountSpecific,但它不起作用。

我试过

option = browser.select_list(:id => /.*ruleTypeSelector.*/).select("AccountSpecific") 

option = browser.select_list(:id => /.*ruleTypeSelector.*/).option(:value => "AccountSpecific")
browser.select_list(:id => /.*ruleTypeSelector.*/)
option.wait_until_present
option.select
browser.button(:value => "Go").click

但两次都改为选择第一个选项ExecutionOrder。

为什么这不起作用?我还能尝试什么?

1 个答案:

答案 0 :(得分:1)

 browser.select_list(:id => /.*ruleTypeSelector.*/).option(:text =>"Account Specific Pricing").when_present.select