Select a value from a select List by value element

page-object-gem, ruby, watir

Solution

The page object gem already supports selecting by partial text:

page.planPurchase = /Basic/
puts page.planPurchase
#=> "Monthly Basic Plan - $27.99"

Selecting by value is also supported by using `select_value`:

page.planPurchase_element.select_value('5')
puts page.planPurchase
#=> "Monthly Basic Plan - $27.99"

The page object gem supports selecting options by index using `[]`. Note that you have to use `.click` as there is no `.select`. The index is 0-based.

page.planPurchase_element[2].click
puts page.planPurchase
#=> "Monthly Business Plan - $54.99"

Problem

recently I came upon an issue while using page object that I could not find an answer to. When using a select list to choose an option. I need to select by partial text or by attribute. here is an example: ``` <select id="custcol95" name="custcol95"> <option selected="" value="">- Select -</option> <option value="5">Monthly Basic Plan - $27.99</option> <option value="1">Monthly Business Plan - $54.99</option> </select> ``` I tried: ``` select_list(:planPurchase, :id => 'custcol95') ``` I can do this: ``` selectCloudPlan_element.option(:value, CLOUD_PLANS['PersonalMonthly']).select ``` but that is deprecated. I have yet to see a select by value option or by index anywhere on the web. Does one exist? Also if there was a search by partial text that would fix my issue. Thanks in advance.

Original source