Skip to content

Instantly share code, notes, and snippets.

@ssmiech
Created May 26, 2013 11:33
Show Gist options
  • Save ssmiech/5652534 to your computer and use it in GitHub Desktop.
Save ssmiech/5652534 to your computer and use it in GitHub Desktop.
d = Selenium::WebDriver.for :chrome
d.get "http://www.flipkart.com/"
select = Selenium::WebDriver::Support::Select.new(d.first(:id, "fk-search-select"))
#What's selected now
select.selected_options[0].text
#Change selection by index:
select.select_by(:index, 2)
select.selected_options[0].text
#Change selection by text:
select.select_by(:text, "eBooks")
select.selected_options[0].text
#Is multiple selection possible
select.multiple?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment