Selenium Basics

3,120 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,120
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
53
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Selenium Basics

  1. 1. Intro * I’m Dave Haeffner Show of hands * I’ve been doing QA and automated new to Selenium? web testing for 4 years some experience with? * Most of that time was spent at experienced? The Motley Fool * More recently I started my own new to programming? consulting company and work with some experience with? soft ware development shops to help experienced? them with QA strategy and not sure how to answer? implementing automated web testing SELENIUM BASICS brought to you by the QA LoungeTuesday, September 25, 12
  2. 2. “WHAT IS SELENIUM? TELL ME LIKE I’M 5.” Selenium is a soft ware robot sent from the future to test our soft ware.Tuesday, September 25, 12
  3. 3. PREFACE There are many ways to implement Selenium & a framework I will show you one that has worked for me There will be code involved (and opinions!) These examples do not reflect a comprehensive QA strategy But it’s a good startTuesday, September 25, 12
  4. 4. SELENIUM IDE I debated showing you the IDE since it’s the unloved child of the Selenium community. But it is responsible for the wide spread success of Selenium. I consider it to be less of an unloved orphan and more of a gateway drugTuesday, September 25, 12
  5. 5. SELENIUM IDIOMS • Verify vs. Assert • Location, location, location! • ClickAndWait, and wait, and wait...Tuesday, September 25, 12
  6. 6. LET ME EXPLAIN • Ruby is approachable -- it can read like English • There’s also that “standing on the shoulder of giants thing” • RSpec is an open-source testing tool built in Ruby for Ruby • It’s kind of a big deal • Loads of functionality out of the box • Quite customizableTuesday, September 25, 12
  7. 7. “SHUT UP AND SHOW ME THE CODE!”Tuesday, September 25, 12
  8. 8. COMMON ACTIONS Name Action Sub-Action get fetch a page navigate same as get to, forward, back (:id, “idtext”) (:class, “classtext”) (:tag_name, “tagtext”) find_element (:name, “nametext”) click, text (a.k.a. “by” strategies) (:link, “linktext”) (:partial_link_text, “”) (:css, “csstext”)Tuesday, September 25, 12
  9. 9. HONORABLE MENTION • Moving between windows and frames • Pop-up dialogs • Drag and Drop • Cookies • Changing the User AgentTuesday, September 25, 12
  10. 10. ASSERTIONS THRU RSPEC Thing Action Sub-Action include(“text”) start_with(“text”) end_with(“text”) equal(expected) should be(expected) object should_not be > expected be >= expected be <= expected be < expected match(/expression/)Tuesday, September 25, 12
  11. 11. “NO REALLY, SHUT UP AND SHOW ME THE CODE!”Tuesday, September 25, 12
  12. 12. PAGE OBJECT PATTERN Create a class Pass the session to it Store and use it through an instance variable Assertions done outside of the class • Relieves many test maintenance woes • Keeps things DRY rather than WET • Create an object that represents a page (or component of a page) and test against that • If the UI changes, you change just the object, not the tests • Also helps you make things more readableTuesday, September 25, 12
  13. 13. “IS THAT IT?”Tuesday, September 25, 12
  14. 14. robot/ DIY FRAMEWORK .rspec Rakefile Gemfile art/ results.html brains/ config.rb page_objects/ google_search.rb guts/Tuesday, September 25, 12
  15. 15. FRAMEWORK CONT’D rake robot:run Code available at github.com/tourdedave/diy_frameworkTuesday, September 25, 12
  16. 16. RECAP • Selenium IDE is cool in theory... • WebDriver is cool. • The Page Object Pattern will make you happy and successful • Rolling your own framework is within your grasp • And it positions you for automation success!Tuesday, September 25, 12
  17. 17. SOME RESOURCES • Selenium HQ (SeleniumHQ.com/docs/03_webdriver.html) • Official Selenium Blog (SeleniumHQ.Wordpress.com) • Ruby Selenium Bindings (http://bit.ly/seruby) • RSpec (http://github.com/rspec) • Why Everyone Should Be Code Literate (http://bit.ly/sauceio) •A book to get you started (http://bit.ly/se2book) •A self-proclaimed great resource* (QA-Lounge.com)Tuesday, September 25, 12
  18. 18. Q&A @TourDeDave QA-Lounge.comTuesday, September 25, 12

×