Created
July 1, 2011 17:20
-
-
Save jarib/1058999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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