Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'selenium-webdriver'
- browser = Selenium::WebDriver.for :firefox
- browser.get "http://localhost/page7"
- wait = Selenium::WebDriver::Wait.new(:timeout => 15)
- # Interact with the drop down box
- select_list = wait.until {
- element = browser.find_element(:name, "dropdown")
- element if element.displayed?
- }
- select_list.clear
- # Extract all options from the select box
- options=select_list.find_elements(:tag_name => "option")
- # Select the option "Volvo"
- options.each do |g|
- if g.text == "Volvo"
- g.click
- break
- end
- end
- # Select another option "Audi"
- options.each do |g|
- if g.text == "Audi"
- g.click
- break
- end
- end
- # Print currently selected options
- options.each do |g|
- if g.selected?
- puts g.text
- end
- end
- browser.quit
Advertisement
Add Comment
Please, Sign In to add comment