cheezy/page-object — Issue #51: select_list should return text instead of value?
Author: p0deje
Created: 2012-01-18 09:15:22+00:00
State: open

I'm not sure if this is really correct, but I've faced a problem when `select_list` method returns option instead of text. I know that's by design, but I thought that maybe returning text is better idea, as long as that's what user see?

Here is an example

```ruby
#
# Sample select list has the following code:
#
#
First option

#
#

class MyPage
select_list :sample_list, id: 'sample_list_id'
end

# That's how it works now
MyPage.new.sample_list
#=> 1

# That's how it should work with my idea
MyPage.new.sample_list
#=> First option
```

It is particularly useful in acceptance tests, where tester shouldn't operate with HTML code and check that selected value is actually selected.

I implemented this by changing `#select_list_for` (I use Watir-WebDriver as backend so it won't work for Selenium).

```ruby
value = @browser.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier).options.each { |option| return option.text if option.selected? }"
```

What do you think about it?