Skip to content

Instantly share code, notes, and snippets.

@jarib
Created July 1, 2011 17:20
Show Gist options
  • Save jarib/1058999 to your computer and use it in GitHub Desktop.
Save jarib/1058999 to your computer and use it in GitHub Desktop.
require 'selenium-webdriver'
browser = Selenium::WebDriver.for :firefox
begin
browser.get "data:text/html;content-type=utf-8,#{URI.escape DATA.read}"
opts = browser.find_elements(:tag_name => "option")
opts[0].click
opts[1].click
p opts.map { |e| e.selected? } # prints [true, true, false]
ensure
browser.quit
end
__END__
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page Title</title>
</head>
<body>
<select id="select" multiple>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment