anahorn

Selenium WebDriver Ruby: Part 10 (Frames) 2

Jun 4th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.06 KB | None | 0 0
  1. require 'rubygems'
  2. require 'selenium-webdriver'
  3.  
  4. browser = Selenium::WebDriver.for :firefox
  5. browser.get "http://localhost/page10"
  6.  
  7. wait = Selenium::WebDriver::Wait.new(:timeout => 15)
  8.  
  9. # Switch to the 1st frame
  10. browser.switch_to.frame("frame1")
  11.  
  12. # Find text in the 1st frame by regexp
  13. puts "Test Passed: Frame 1 Validated" if wait.until {
  14.     /An operating system is the set of basic programs and utilities that make
  15. your computer run/.match(browser.page_source)
  16. }
  17.  
  18. # Switch to parent page
  19. browser.switch_to.default_content
  20.  
  21. # Switch to the 2nd frame
  22. browser.switch_to.frame("frame2")
  23.  
  24. # Find text in the 2nd frame by regexp
  25. puts "Test Passed: Frame 2 Validated" if wait.until {
  26.     /Welcome to the Linux Kernel Archives/.match(browser.page_source)
  27. }
  28.  
  29. # Switch to parent page
  30. browser.switch_to.default_content
  31.  
  32. # Switch to the 3rd frame
  33. browser.switch_to.frame("frame3")
  34.  
  35. # Find text in the 3rd frame by regexp
  36. puts "Test Passed: Frame 3 Validated" if wait.until {
  37.     /Ubuntu is, and always will be, absolutely free/.match(browser.page_source)
  38. }
  39.  
  40. browser.quit
Advertisement
Add Comment
Please, Sign In to add comment