Awesome Test Automation Made Simple w/ Dave Haeffner

35
Awesome Test Automation Made Simple by Dave Haeffner

Transcript of Awesome Test Automation Made Simple w/ Dave Haeffner

Page 1: Awesome Test Automation Made Simple w/ Dave Haeffner

Awesome Test Automation

Made Simpleby Dave Haeffner

Page 2: Awesome Test Automation Made Simple w/ Dave Haeffner

Agenda

1. Getting Started with Powerful Tests

2. Running Your Tests on any Browser

3. Automating Your Test Runs with CI

4. Q&A

Page 3: Awesome Test Automation Made Simple w/ Dave Haeffner

Act I Getting Started

+

Page 4: Awesome Test Automation Made Simple w/ Dave Haeffner

Selenium• Open-source browser automation tool

• Every major browser, OS, and programming language

• Mimics human action

• Uses a few common actions

• Works with “locators”

Locators tell Selenium which HTML element a command refers to

Page 5: Awesome Test Automation Made Simple w/ Dave Haeffner

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

Page 6: Awesome Test Automation Made Simple w/ Dave Haeffner

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

Page 7: Awesome Test Automation Made Simple w/ Dave Haeffner

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

Page 8: Awesome Test Automation Made Simple w/ Dave Haeffner

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 sanely

Page 9: Awesome Test Automation Made Simple w/ Dave Haeffner

Locator Strategies• Class

• CSS selectors

• ID

• Link Text

• Partial Link Text

• Tag Name

• XPath

CSS vs XPath http://bit.ly/seleniumbenchmarks http://bit.ly/cssxpathexamples

Page 10: Awesome Test Automation Made Simple w/ Dave Haeffner

Finding Quality Locators

• Inspect the page

• Verify your selection

• e.g., FirePath or FireFinder

• http://bit.ly/verifyinglocators

Page 11: Awesome Test Automation Made Simple w/ Dave Haeffner

Common Selenium actions• find_element

• click

• clear

• send_keys

• text

• displayed?

Look up your language’s bindings http://bit.ly/seleniumwiki

Page 12: Awesome Test Automation Made Simple w/ Dave Haeffner

A Login Example

1. Visit the login page

2. Find the login form’s username field and input text

3. Find the login form’s password field and input text

4. Find the submit button and click it

Page 13: Awesome Test Automation Made Simple w/ Dave Haeffner

http://the-internet.herokuapp.com/login

Page 14: Awesome Test Automation Made Simple w/ Dave Haeffner

An Example (with Ruby & RSpec)

Page 15: Awesome Test Automation Made Simple w/ Dave Haeffner
Page 16: Awesome Test Automation Made Simple w/ Dave Haeffner
Page 17: Awesome Test Automation Made Simple w/ Dave Haeffner
Page 18: Awesome Test Automation Made Simple w/ Dave Haeffner

Recap• Assertions are the crux of an automated test

• Automated visual testing gives you hundreds of assertions in just a few lines of code

• Automates something that used to be done manually

• Over 16 open-source solutions available

• Visual testing has limitations (e.g., false postives). Applitools handles them in stride

http://bit.ly/se-visual-1

Page 19: Awesome Test Automation Made Simple w/ Dave Haeffner

Act 2 Any Browser

with

+

Page 20: Awesome Test Automation Made Simple w/ Dave Haeffner

An Example

Page 21: Awesome Test Automation Made Simple w/ Dave Haeffner
Page 22: Awesome Test Automation Made Simple w/ Dave Haeffner

Recap

• Run Your Tests on any browser & operating system combination you need

• Few lines of code

• Great reporting (e.g., video recording)

http://se.tips/cloud-testing

Page 23: Awesome Test Automation Made Simple w/ Dave Haeffner

Act 3 Automated Test Runs

with and

+

Page 24: Awesome Test Automation Made Simple w/ Dave Haeffner
Page 25: Awesome Test Automation Made Simple w/ Dave Haeffner

Continuous Integration

• Feedback loops

• Code promotion

Page 26: Awesome Test Automation Made Simple w/ Dave Haeffner

Feedback loops• The goal: Find failures early and often

• Notifications

• Email, chat, SMS

• In-person (audio & visual)

Page 27: Awesome Test Automation Made Simple w/ Dave Haeffner

Code Committed

Integration (pass?)

Deploy to autom. test

server (success?)

Run automated

tests (pass?)

Deploy to manual test

server (manual)

(success?)

yes

yes

yes

Notify team if no

Code Promotion

Bonus points: stop the line

Page 28: Awesome Test Automation Made Simple w/ Dave Haeffner

Simple Jenkins configuration1. Create a Job

2. Pull In Your Test Code

3. Set up Build Triggers

4. Configure Build steps

5. Configure Test Reports

6. Set up Notifications

7. Run Tests & View The Results

Page 29: Awesome Test Automation Made Simple w/ Dave Haeffner

An Example

Page 30: Awesome Test Automation Made Simple w/ Dave Haeffner

Recap• Automate Your Test Runs without infrastructure

overhead

• Plug into the development workflow you’re a part of

• Enable notifications to fit your team’s context

• Automatically link to high bandwidth information (e.g., Sauce Labs & Applitools job dashboards) to make everything sing

http://se.tips/ci-walkthrough

Page 31: Awesome Test Automation Made Simple w/ Dave Haeffner

Awesome Test Automation has been Achieved!

Page 32: Awesome Test Automation Made Simple w/ Dave Haeffner

Q&A Panel

Page 33: Awesome Test Automation Made Simple w/ Dave Haeffner

Adam Carmi Co-founder & VP of R&D

Abhijit Pendyal Solutions Engineer, Sauce Labs

Brian Dawson DevOps Evangelist, CloudBees

Page 34: Awesome Test Automation Made Simple w/ Dave Haeffner

Free Stuff!

Page 35: Awesome Test Automation Made Simple w/ Dave Haeffner

Automated Visual Testing e-Book: Step-by-Step Guide & Best Practices - by Dave Haeffner

Send an email to [email protected] with EBOOK in the subject line

14 days FREE with killer features 8 VMs, 90 browser hours, unlimited manual sessions

https://saucelabs.com/signup/trial

Are you looking to transition from CI to CD? Download the e-book: "Making the Shift: From Continuous Integration to Continuous Delivery"

http://bit.ly/cloudbees-ebook