1

I try to check is selected option realy selected in drop down list (select):

expect(page.sltMembers_element.options).to eql('John Doe')

But I get an error that expected: 'John Doe' and got: list of all options from drop down list.

Den Silver
  • 199
  • 16
  • have you seen this? http://stackoverflow.com/questions/11498575/get-select-value-of-dropdown-for-capybara-testing. Looks like find_field('restrictions__rating_movies').find('option[selected]').text should do – CoupDeMistral Jun 30 '15 at 21:45
  • @CoupDeMistral, `find_field` and `find` are Capybara gem methods. This question is about using the Page-Object gem with Watir-Webdriver. – Justin Ko Jun 30 '15 at 22:47

1 Answers1

2

Assuming that the sltMembers_element method is the one generated by the select_list accessor, then the page-object will have 5 methods:

  1. sltMembers returns the currently selected item text.
  2. sltMembers= selects an item.
  3. sltMembers_element returns the page-object element.
  4. sltMembers? checks if the element is present.
  5. sltMembers_options gets an array of all available options.

As you want to check the selected option, you want to call the page's sltMembers method:

expect(page.sltMembers).to eql('John Doe')
Justin Ko
  • 46,526
  • 5
  • 91
  • 101