Skip to content

Instantly share code, notes, and snippets.

@ivaravko
Forked from jarib/test.rb
Created July 1, 2011 08:27
Show Gist options
  • Select an option

  • Save ivaravko/1058093 to your computer and use it in GitHub Desktop.

Select an option

Save ivaravko/1058093 to your computer and use it in GitHub Desktop.
require 'selenium-webdriver'
wait = Selenium::WebDriver::Wait.new
driver = Selenium::WebDriver.for :firefox
driver.get "http://www.google.no/?as_qdr=all"
driver.find_element(:name => "q").send_keys("selenium")
suggestions = nil
wait.until {
suggestions = driver.find_elements(:class => "gsq_a").select { |e| e.displayed? }
suggestions.any?
}
suggestions.last.click
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment