Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
How To Grade Your
Selenium Tests
http://se.tips/getting-started-talk
http://se.tips/selenium-tips
http://se.tips/selenium-book
Let’s talk about tests
What Makes a Bad Test?
• Fails For No Good Reason
• Changes in AUT, Need to Update Test(s)
• Slow
• Unreliable
• Hard to U...
What Makes a Good Test?
• Written for BDD or xUnit test framework
• Test one thing (atomic)
• Each test can be run indepen...
A Testing Rubric
(Each test starts with 100 points, deduct as necessary)
Item Belong in tests? Score
Selenium Commands No ...
Let’s talk about
Page Objects
http://martinfowler.com/bliki/PageObject.html
What Makes a Bad PO?
• Gigantic in size (e.g., hundreds or thousands of
lines in code)
• Over-reaching responsibility
• Co...
What Makes a Good PO?
• Contains State (e.g., locators)
• Contains Behavior (e.g., methods to interact with
the page)
• Re...
A Page Object Rubric
(Each Page Object starts with 100, deduct points as necessary)
Item Belong in POs? Score
> 200 lines ...
Let’s talk about locators
Locator Strategies
• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are:
• un...
Locator Strategies
• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are:
• un...
Locator Strategies
• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are:
• un...
Locator Strategies
• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are:
• un...
Which is better
CSS or XPath?
CSS vs. XPath
Benchmarks
http://se.tips/se-benchmarks
A Locator Rubric
(Each locator gets a grade)
Item Letter Grade E.g.,
Dynamic locators D-
User account specific
or tied to p...
So…
What’s your testing GPA?
Topic Weight
Tests 20%
Page Objects 30%
Locators 50%
Available in Java, JavaScript, Python, Ruby, and C#
25% OFF until Friday at midnight (Eastern)
https://seleniumguidebook.c...
How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar
How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar
How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar
How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar
How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Managers, Future Proof Your Automation
Next
Upcoming SlideShare
Managers, Future Proof Your Automation
Next
Download to read offline and view in fullscreen.

Share

How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar

Download to read offline

Join Dave Haeffner as he steps through the core tenets of good test and page object design, locators, and a repeatable and quantitative approach for assessing your test code. When you're done, you'll be able to see how your tests and page objects stack up, and what changes are needed to help them stand the test of time.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

How To Grade Your Selenium Tests by Dave Haeffner - Sauce Labs Webinar

  1. 1. How To Grade Your Selenium Tests
  2. 2. http://se.tips/getting-started-talk http://se.tips/selenium-tips http://se.tips/selenium-book
  3. 3. Let’s talk about tests
  4. 4. What Makes a Bad Test? • Fails For No Good Reason • Changes in AUT, Need to Update Test(s) • Slow • Unreliable • Hard to Understand and Maintain
  5. 5. What Makes a Good Test? • Written for BDD or xUnit test framework • Test one thing (atomic) • Each test can be run independently (autonomous) • Anyone can understand what it is doing • Group similar tests together • Centralized setup/teardown • Uses Page Objects
  6. 6. A Testing Rubric (Each test starts with 100 points, deduct as necessary) Item Belong in tests? Score Selenium Commands No -3 per (max of -9) Locators No -2 per (max of -8) Selenium setup/teardown* No -20 Hard-coded sleeps No -5 per (max of -20) Implicit wait calls No -10 Explicit Wait calls No -3 Conditionals No -5 (max of -20) Calls to Page Objects Yes N/A Assertion(s)* Yes N/A
  7. 7. Let’s talk about Page Objects
  8. 8. http://martinfowler.com/bliki/PageObject.html
  9. 9. What Makes a Bad PO? • Gigantic in size (e.g., hundreds or thousands of lines in code) • Over-reaching responsibility • Contain overly complicated logic • Return not enough or too much information to the test (leaky abstraction) • Assertions happening in the PO instead of the test
  10. 10. What Makes a Good PO? • Contains State (e.g., locators) • Contains Behavior (e.g., methods to interact with the page) • Returns some information about the page (e.g., new page object, text from the page, a boolean result for some check, etc. — never a WebElement) • Verifies page ready state as part of initialization with a found Element
  11. 11. A Page Object Rubric (Each Page Object starts with 100, deduct points as necessary) Item Belong in POs? Score > 200 lines of code No -5 per 50 lines over Assertions No* -5 per (max of -20) Hard-coded sleeps No -5 per (max of -20) Implicit wait calls No -10 Explicit waits Yes N/A Verify page ready state* Yes -8 if not verifying an element Locators* Yes N/A http://se.tips/se-waiting-jim-evans
  12. 12. Let’s talk about locators
  13. 13. Locator Strategies • Class • CSS selectors • ID • Link Text • Partial Link Text • Tag Name • XPath Good locators are: • unique • descriptive • unlikely to change That rules a few of these out
  14. 14. Locator Strategies • Class • CSS selectors • ID • Link Text • Partial Link Text • Tag Name • XPath Good locators are: • unique • descriptive • unlikely to change That rules a few of these out
  15. 15. Locator Strategies • Class • CSS selectors • ID • Link Text • Partial Link Text • Tag Name • XPath Good locators are: • unique • descriptive • unlikely to change That rules a few of these out Start with IDs and Classes
  16. 16. Locator Strategies • Class • CSS selectors • ID • Link Text • Partial Link Text • Tag Name • XPath Good locators are: • unique • descriptive • unlikely to change That rules a few of these out Start with IDs and Classes Use CSS or XPath (with care)
  17. 17. Which is better CSS or XPath?
  18. 18. CSS vs. XPath Benchmarks http://se.tips/se-benchmarks
  19. 19. A Locator Rubric (Each locator gets a grade) Item Letter Grade E.g., Dynamic locators D- User account specific or tied to page render Tied to page layout D XPath: / / / CSS: > > >, etc. Text on the page C Link text, page copy Reasonable traversal B Parent to child w/in an element node Using semantic name B+ Input labels (name='username') Semantic ID A Unique, descriptive, unlikely to change Non-unique locator? -2 full letter grades
  20. 20. So…
  21. 21. What’s your testing GPA? Topic Weight Tests 20% Page Objects 30% Locators 50%
  22. 22. Available in Java, JavaScript, Python, Ruby, and C# 25% OFF until Friday at midnight (Eastern) https://seleniumguidebook.com
  • WojciechSobasik

    Feb. 23, 2018
  • GeoloShin

    Jul. 25, 2017
  • escame1

    Mar. 25, 2017
  • MuhammadHammad70

    Jan. 9, 2017
  • qytera

    Dec. 9, 2016
  • TamaraMcAndrew

    Dec. 8, 2016
  • ctn2

    Dec. 8, 2016

Join Dave Haeffner as he steps through the core tenets of good test and page object design, locators, and a repeatable and quantitative approach for assessing your test code. When you're done, you'll be able to see how your tests and page objects stack up, and what changes are needed to help them stand the test of time.

Views

Total views

3,275

On Slideshare

0

From embeds

0

Number of embeds

376

Actions

Downloads

124

Shares

0

Comments

0

Likes

7

×