Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Best Practices for Automated Regression Testing

Best Practices for Automated Regression Testing

So you wrote a bunch of great unit tests but your site is still broken? Maybe it’s time to start investing in a suite of end-to-end regression tests. In this talk you’ll learn best practices for incorporating Selenium into your QA process while avoiding some common pitfalls.

This talk was given at Beer City Code in Grand Rapids, MI.

Jace Browning

June 23, 2018
Tweet

More Decks by Jace Browning

Other Decks in Programming

Transcript

  1. Language Bindings from selenium import webdriver driver = webdriver.Firefox() driver.get("http://zapier.com/app/team-account-setup/billing")

    assert "Start Your 14-Day Free Trial" in driver.html element = driver.find_element_by_name("cardNumber") element.send_keys("4242424242424242") element = driver.find_element_by_link_text("Start Trial") element.click() assert "Invite Your Teammates" in driver.html
  2. Abstraction Layers from splinter import Browser browser = Browser("firefox") browser.visit("http://zapier.com/app/team-account-setup/billing")

    assert "Start Your 14-Day Free Trial" in browser.html browser.fill("cardNumber", "4242424242424242") browser.find_by_text("Start Trial").click() assert "Invite Your Teammates" in browser.html
  3. Page Object Model class TeamSetupBilling: URL = "http://zapier.com/app/team-account-setup/billing" def __init__(self):

    self.browser = Browser("firefox") self.browser.visit(self.URL) def __contains__(self, value): return value in self.browser.html def fill_credit_card_number(self, value): self.browser.fill("cardNumber", value) def click_start_trial(self): self.browser.find_by_text("Start Trial").click()
  4. Page Object Model page = TeamSetupBilling() assert "Start Your 14-Day

    Free Trial" in page page.fill_credit_card_number("4242424242424242") page.click_start_trial() assert "Invite Your Teammates" in page
  5. Helper Functions def create_team(team_name, team=None, credit_card=None): if team is None:

    team = get_team(team_name) if credit_card is None: credit_card = get_credit_card() page = views.TeamSetup() return page.complete_wizard(team, credit_card)
  6. Helper Functions helpers.create_team(team_name="Beer City") page = TeamSettings() assert "Beer City"

    in page page.fill_team_members("[email protected]") page.click_invite() assert "Pending Invite" in page
  7. Roadmap 1. Sign up / Log in 2. Run after

    every deploy 3. Low-coverge, High-impact 4. Business critical 5. Postmortems / Retrospectives