anahorn

Selenium WebDriver Ruby: Part 1

Jun 4th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.40 KB | None | 0 0
  1. require 'rubygems'
  2. require 'selenium-webdriver'
  3.  
  4. browser = Selenium::WebDriver.for :firefox
  5. browser.get "http://localhost/page1"
  6.  
  7. # Timeout = 15 sec
  8. wait = Selenium::WebDriver::Wait.new(:timeout => 15)
  9.  
  10. # Find text on the page by regexp
  11. puts "Test Passed: Page 1 Validated" if wait.until {
  12.     /Testing Web Applications with Ruby and Selenium WebDriver/.match(browser.page_source)
  13. }
  14.  
  15. browser.quit
Advertisement
Add Comment
Please, Sign In to add comment