SlideShare uma empresa Scribd logo
1 de 25
WRITING
WELL-ABSTRACTED
SELF-TESTING
AUTOMATION
ON TOP OF JELL-O®

DAN CUELLAR
LEAD SOFTWARE ENGINEER
ZOOSK - QA TEAM
TERMINOLOGY
Test or Automation Script
a series of steps and expected output


Hook or Element
a means of identifying a piece of UI (think the By class in
WebDriver)


Controller
a program which executes basic commands (think WebDriver or
SeleniumRC Server)
PHILOSOPHY
•   Selenium is a controller program, it exists to perform actions
    on a platform (web browsers)
     • Click a link
     • Read some text
•   Libraries exist to coordinate these small actions into larger
    logical actions on a particular platform
      • Sign In
      • Send A Message
      • Get All Error Messages
•   Interfaces exist to remove the platform from the context of
    libraries
•   Automation scripts should coordinate the highest level of
    abstraction whenever possible to maintain agility and
    robustness
A BIT ABOUT ZOOSK
•   Zoosk is a romantic social network with tens of millions of users that
    operates in 25 languages and in over 70 countries.
•   Products include:
     •   web site
     •   mobile web site
     •   Facebook app
     •   iPhone app
     •   iPad app
     •   Android app
     •   Adobe Air app

•   The development pace is rapid, features are churned out in around 2
    weeks time (including testing)
•   Product management is always running experiments and adjusting
    plans based on data from instrumentation
•   Developer to quality assurance ratio hovers somewhere around 10:1
SO WHAT DO YOU
MEAN BY JELL-O®
Jell-O [jel-oh]
Site wide A/B tests where ½ of users will see a complete site
redesign and the other ½ will use the site as it was before.
Facebook app users can also split between different A and B
designs at times.
Each A & B may have its own JS, CSS, and business logic to go
along with it.
Not to mention that different versions of the API were being used
by the web, Facebook app, and mobile apps.
All the while, different features were being enabled and disabled
for different subsets of the A/B test groups
WHAT CAN GO WRONG?
• General
   • Not enough information is retrieved to reproduce the failure
• Elements
   • The type can change (e.g. dropdown becomes a checkbox)
   • An element can change location
   • An element can have multiple ways of identifying itself depending
     on an A/B test
• Business Logic
    • Logic can change for one platform
    • Logic can change for some users and not others (A/B test)
    • Logic can change for all platforms
HOW DO WE COMBAT THESE
PROBLEMS?
• General
   • Not enough information is retrieved to reproduce the failure
         •   Separate test actions from controller code, add abundant
             logging, and unify the patterns by which common
             operations are accomplished (e.g. selecting from
             dropdown) Don’t access selenium directly in any scripts.
             Create a wrapper that logs everything and performs basic
             checks. (e.g. is the choice available on the dropdown)
         •   If libraries are used then you can log just about everything
             possible every time without having to re-paste all the
             logging code
HOW DO WE COMBAT THESE
PROBLEMS? (CONT.)
• Elements
   • The type can change
         •   Abstracting away all uses of the item into a library
   • An element can change location
         •   Centralize all hooks into the UI, you can change it once
             and it will be fixed for all
         •   Using reflection, you can verify that all of your hooks are
             functional
   • An element can have multiple ways of identifying itself
     depending on an A/B test
         •   ID’s are great, but you can also use an XPath Or
             expression in your centralized hook
HOW DO WE COMBAT THESE
PROBLEMS? (CONT.)
• Business Logic
   • Logic can change for one platform
        •   Update the library for that platform
   • Logic can change for some users and not others (A/B test)
        •   Detect the A/B test in the library
   • Logic can change for all platforms
        •   Generic Libraries or test scripts which coordinate platform
            specific libraries are a great place to address this
HOW DO YOU DEAL
WITH THAT AGAIN?
• Separate logical actions From calls to controller (in this case
  Selenium) code into libraries
• Centralize your site model and logic, so that all automation
  runs through one place. When you have to fix something, you
  can fix it once for everything.
• Write code that can test the test automation. Investigating test
  script failures can be costly, but if you test code can test itself
  you will be able to pick out certain kinds of problems easily.
• Write platform-agnostic test scripts when possible. This leaves
  you with one copy of site-logic and test-logic for all platforms.
  When things change, you’ll be happy its in one place.
SEPARATION OF CONTROL
FROM SCRIPTING
• An extra layer is great to log information and perform additional
  actions that Selenium can’t assume it needs to do
• We use a layer between that wraps logging, error
  handling, and some other things on top of most WebDriver
  commands
          Test Script   •IsSignedIn()




                                         •Log(“Retrieving Cookie Auth”);
                        Action           •var authCookie = GetCookie(auth);
                                         •Log(authCookie);
                        Library          •return authCookie != null;



                                                         •Log (“Getting Cookies”);
                                                         •var c = Driver.Manage.().Cookies;
                                        WebDriver        •Log(c);
                                                         •var a = Driver.Manage().Cookies[“auth”];
                                        Wrapper          •Log(“Cookie value: “ + a.ToString());
                                                          return a;
CENTRALIZING YOUR SITE
MODEL FOR SELF -TESTING
•   All hooks (means by which we retrieve WebElements) are stored
    in a single class, namespace, or something similar
•   Elements are stored lazily; the means to retrieve them are
    stored, but the actual WebElement is not retrieved until run-time.
    We use classes that wrap calls to By or methods which will return
    a WebElements
•   Hooks are grouped relevantly and each group has private self-test
    setup methods which will navigate the client (e.g. selenium) to
    where the hooks exist
•   Reflection is used to iterate through all of these groups and run
    the private self-test setup methods and then validate the
    functionality of the elements
•   Annotations (Java) or Attributes (C#) are used to exclude
    elements from the tests
ABOUT INTROSPECTION
& REFLECTION

Introspection (Java) and Reflection (C#) is the process by which a
computer program can observe, do type introspection, and modify
its own structure and behavior at runtime.
In the example to follow we store information about how to use
various hooks (references to pieces of user interface) in the code
so that later at runtime we can use the information to determine
how to test our library of hooks.
CENTRALIZED HOOKS
[C#]
namespace Automation.Hooks.Web
{
  public static class LoginPage
  {
    public static WebHook EmailField = By.Id(“email”);
    public static WebHook PasswordField = By.Id(“password”);
    public static WebHook SubmitButton = By.Id(“submit”);
        [OmitFromSelfTest]
        public static WebHook Spinner = By.Xpath(“//div[@class=’wait’]”);
        private static void _StartSelfTest()
        {
          _SelfTestSeleniumInterface.Open(“http://www.zoosk.com”)
        }
    }
}
SIMPLE SELF-TEST
[PseudoCode]

// iterate in depth-first-search order
foreach(class c in Automation.Hooks.Web)
{
    if c.hasMethod(“StartSelfTest”)
       c.executeMethod(“StartSelfTest”);
    foreach(WebHook h in c)
       Log.Verify(IsElementPresent(h));

    if c.hasMethod(“StopSelfTest”)
       c.executeMethod(“StopSelfTest”);
}
MORE ADVANCED
TECHNIQUES
• Subclass WebHook to things like TextBoxHook and have the
  test check for reading and writing from the text field using
  Selenium
• Do the same for Links, Images, etc. and write custom test
  methods
• Randomize the order of which elements are tested to check for
  robustness
• Add random data to the tests, e.g. type a random string into
  the text box.
• Write custom test methods for structures that require it
CONSOLIDATING AND ABSTRACTING
PRODUCT LEVEL ACTIONS
• Product Level Actions (e.g. Sign In To The Site) are stored in
  libraries, so that there exists one good copy that everyone can
  use
• The libraries implement generic interfaces so the platform can
  be abstracted away (i.e. the native iPhone app and the website
  both have libraries with a signup function that conforms to an
  interface that can be used in any test script)
• If the process changes for a particular platform, you can
  update it in a single place
• If the process change across all platforms, you can use
  platform agnostic (generic) libraries and update the logic in a
  single place
ABSTRACT LIBRARIES
[C#]
namespace Automation.Libraries
{
  public SeleniumActionLibrary WebSignUpLib : ISignUpLib
  {
    public void SignIn(string email, string password)
    {
      if (IsSignedIn())
         return;
            if (!Driver.Url.contains(“login.php”);
Driver.Navigate().GoToUrl(“https://www.zoosk.com/login.php”);
            Hooks.Web.LoginPage.EmailField.type(email);
            Hooks.Web.LoginPage.PasswordField.type(password);
            Hooks.Web.LoginPage.SubmitButton.click();
            WaitForElementToNotExist(Hooks.Web.LoginPage.Spinner);
        }
    }
}
LIBRARY INTERFACE
[C#]
namespace Automation.Libraries
{
  interface ISignUpLib
  {
     void SignIn(string email, string password);
     bool IsSignedIn(string email, string password);
     void SignOut();
  }
}
PLATFORM AGNOSTIC
AUTOMATION SCRIPTS
• Many tests that need to be run are logically identical
  across all platforms.
   • Deactivate an account, attempt to sign in, expect failure
   • Send a message, verify it shows up in sent items
   • Take down some web service, verify an error is produced
• Implemented these tests at an abstract level allows you to
  have one test for all platforms
   • When the logic changes, the logic only exists one place in
     your automation code
AN ABSTRACTED
TEST
[C#]
namespace Automation.Tests
{
    public static class SignInWithDeactivatedAccountTest: Test
    {
        public static void Run()
        {
            AutomationClient [] clients = new AutomationClient[] {
                new WebClient(), new iPhoneClient() }
            var account = APIUtility.Accounts.CreateTestAccount();
            APIUtility.Accounts.Deactivate(account);
            foreach(AutomationClient client in clients)
            {
                client.SignUpInterface.SignIn(account.email, acount.password);
                Log.VerifyFalse(!client.IsSignedIn());
            }}}}
CONCLUSION
Developers and Designers frequently have to be able to adapt to
rapidly changing code, automation writers can be just as nimble.


If you design and abstract your code well, you can build
smaller, more robust and agile automation scripts.


If anyone is interested in taking up work on bringing iOS support
to Selenium… Call Me.
MORE INFO
Dan Cuellar
Lead Software Engineer – QA Team
danc@zoosk.com
(Email me to retrieve related source code available for sharing)


See Also
Self-Generating Test Artifacts for Selenium WebDriver
Tue 12:20PM – Track B – Marcus Merrell
Building Quality on Foundations of Mud
Tue 2:40PM – Track A – Kristian Rosenwold
The Restless Are Going Native
Wed 2:20PM – Track A – Dante Briones

Mais conteúdo relacionado

Mais procurados

How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?Dmitry Buzdin
 
SoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSmartBear
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolSperasoft
 
Selenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSelenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSauce Labs
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationSauce Labs
 
Introduction to SoapUI day 2
Introduction to SoapUI day 2Introduction to SoapUI day 2
Introduction to SoapUI day 2Qualitest
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsMikalai Alimenkou
 
SOAPUI Test Design & Utilities
SOAPUI Test Design & UtilitiesSOAPUI Test Design & Utilities
SOAPUI Test Design & UtilitiesAkshay Sharma
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Applitools
 
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave HaeffnerPractical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave HaeffnerApplitools
 
Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016Steinn 'Stan' Jónsson
 
Integration Testing with Selenium
Integration Testing with SeleniumIntegration Testing with Selenium
Integration Testing with SeleniumAll Things Open
 

Mais procurados (20)

How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
SoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPlugins
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
 
Jbehave selenium
Jbehave seleniumJbehave selenium
Jbehave selenium
 
Selenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSelenium Best Practices with Jason Huggins
Selenium Best Practices with Jason Huggins
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
 
Introduction to SoapUI day 2
Introduction to SoapUI day 2Introduction to SoapUI day 2
Introduction to SoapUI day 2
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test Automation
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional tests
 
SOAPUI Test Design & Utilities
SOAPUI Test Design & UtilitiesSOAPUI Test Design & Utilities
SOAPUI Test Design & Utilities
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
PhpUnit & web driver
PhpUnit & web driverPhpUnit & web driver
PhpUnit & web driver
 
Selenium and The Grinder
Selenium and The GrinderSelenium and The Grinder
Selenium and The Grinder
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
 
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave HaeffnerPractical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
 
Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016
 
Integration Testing with Selenium
Integration Testing with SeleniumIntegration Testing with Selenium
Integration Testing with Selenium
 
Easy automation.py
Easy automation.pyEasy automation.py
Easy automation.py
 

Destaque

Automated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from ModelsAutomated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from ModelsDharmalingam Ganesan
 
Introducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test DevelopmentIntroducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test Developmentseleniumconf
 
Automatic Test Case Generation
Automatic Test Case GenerationAutomatic Test Case Generation
Automatic Test Case GenerationAdnan Causevic
 
Building Quality with Foundations of Mud
Building Quality with Foundations of MudBuilding Quality with Foundations of Mud
Building Quality with Foundations of Mudseleniumconf
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
TMPA-2017: A Survey on Model-Based Testing Tools for Test Case Generation
TMPA-2017: A Survey on Model-Based Testing Tools for Test Case GenerationTMPA-2017: A Survey on Model-Based Testing Tools for Test Case Generation
TMPA-2017: A Survey on Model-Based Testing Tools for Test Case GenerationIosif Itkin
 

Destaque (7)

Automated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from ModelsAutomated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from Models
 
Introducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test DevelopmentIntroducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test Development
 
Automatic Test Case Generation
Automatic Test Case GenerationAutomatic Test Case Generation
Automatic Test Case Generation
 
Building Quality with Foundations of Mud
Building Quality with Foundations of MudBuilding Quality with Foundations of Mud
Building Quality with Foundations of Mud
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
TMPA-2017: A Survey on Model-Based Testing Tools for Test Case Generation
TMPA-2017: A Survey on Model-Based Testing Tools for Test Case GenerationTMPA-2017: A Survey on Model-Based Testing Tools for Test Case Generation
TMPA-2017: A Survey on Model-Based Testing Tools for Test Case Generation
 
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
 

Semelhante a Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selenium Infrastructure

Writing Well Abstracted Automation on Foundations of Jello
Writing Well Abstracted Automation on Foundations of JelloWriting Well Abstracted Automation on Foundations of Jello
Writing Well Abstracted Automation on Foundations of JelloDan Cuellar
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React AppAll Things Open
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)CIVEL Benoit
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1CIVEL Benoit
 
Create an architecture for web test automation
Create an architecture for web test automationCreate an architecture for web test automation
Create an architecture for web test automationElias Nogueira
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testingrdekleijn
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspecjeffrey1ross
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaAgile Testing Alliance
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptTroy Miles
 
Test automation lesson
Test automation lessonTest automation lesson
Test automation lessonSadaaki Emura
 
JLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersJLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersGrace Jansen
 
Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)Ford Prior
 
Introduction to react native with redux
Introduction to react native with reduxIntroduction to react native with redux
Introduction to react native with reduxMike Melusky
 

Semelhante a Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selenium Infrastructure (20)

Writing Well Abstracted Automation on Foundations of Jello
Writing Well Abstracted Automation on Foundations of JelloWriting Well Abstracted Automation on Foundations of Jello
Writing Well Abstracted Automation on Foundations of Jello
 
Protractor survival guide
Protractor survival guideProtractor survival guide
Protractor survival guide
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React App
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
 
Selenium Concepts
Selenium ConceptsSelenium Concepts
Selenium Concepts
 
Create an architecture for web test automation
Create an architecture for web test automationCreate an architecture for web test automation
Create an architecture for web test automation
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspec
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Test automation lesson
Test automation lessonTest automation lesson
Test automation lesson
 
JLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersJLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containers
 
Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)
 
Introduction to react native with redux
Introduction to react native with reduxIntroduction to react native with redux
Introduction to react native with redux
 

Mais de seleniumconf

More Than Automation - How Good Acceptance Tests Can Make Your Team Happier
More Than Automation - How Good Acceptance Tests Can Make Your Team HappierMore Than Automation - How Good Acceptance Tests Can Make Your Team Happier
More Than Automation - How Good Acceptance Tests Can Make Your Team Happierseleniumconf
 
Building a Selenium Community One Meetup at a Time
Building a Selenium Community One Meetup at a TimeBuilding a Selenium Community One Meetup at a Time
Building a Selenium Community One Meetup at a Timeseleniumconf
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshopseleniumconf
 
Automated Security Testing
Automated Security TestingAutomated Security Testing
Automated Security Testingseleniumconf
 
Selenium: State of the Union
Selenium: State of the UnionSelenium: State of the Union
Selenium: State of the Unionseleniumconf
 
Automated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriverAutomated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriverseleniumconf
 
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer DriverBuilding a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer Driverseleniumconf
 
Massively Continuous Integration: From 3 days to 30 minutes
Massively Continuous Integration: From 3 days to 30 minutesMassively Continuous Integration: From 3 days to 30 minutes
Massively Continuous Integration: From 3 days to 30 minutesseleniumconf
 

Mais de seleniumconf (8)

More Than Automation - How Good Acceptance Tests Can Make Your Team Happier
More Than Automation - How Good Acceptance Tests Can Make Your Team HappierMore Than Automation - How Good Acceptance Tests Can Make Your Team Happier
More Than Automation - How Good Acceptance Tests Can Make Your Team Happier
 
Building a Selenium Community One Meetup at a Time
Building a Selenium Community One Meetup at a TimeBuilding a Selenium Community One Meetup at a Time
Building a Selenium Community One Meetup at a Time
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
 
Automated Security Testing
Automated Security TestingAutomated Security Testing
Automated Security Testing
 
Selenium: State of the Union
Selenium: State of the UnionSelenium: State of the Union
Selenium: State of the Union
 
Automated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriverAutomated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriver
 
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer DriverBuilding a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
 
Massively Continuous Integration: From 3 days to 30 minutes
Massively Continuous Integration: From 3 days to 30 minutesMassively Continuous Integration: From 3 days to 30 minutes
Massively Continuous Integration: From 3 days to 30 minutes
 

Último

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Último (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selenium Infrastructure

  • 1. WRITING WELL-ABSTRACTED SELF-TESTING AUTOMATION ON TOP OF JELL-O® DAN CUELLAR LEAD SOFTWARE ENGINEER ZOOSK - QA TEAM
  • 2. TERMINOLOGY Test or Automation Script a series of steps and expected output Hook or Element a means of identifying a piece of UI (think the By class in WebDriver) Controller a program which executes basic commands (think WebDriver or SeleniumRC Server)
  • 3. PHILOSOPHY • Selenium is a controller program, it exists to perform actions on a platform (web browsers) • Click a link • Read some text • Libraries exist to coordinate these small actions into larger logical actions on a particular platform • Sign In • Send A Message • Get All Error Messages • Interfaces exist to remove the platform from the context of libraries • Automation scripts should coordinate the highest level of abstraction whenever possible to maintain agility and robustness
  • 4. A BIT ABOUT ZOOSK • Zoosk is a romantic social network with tens of millions of users that operates in 25 languages and in over 70 countries. • Products include: • web site • mobile web site • Facebook app • iPhone app • iPad app • Android app • Adobe Air app • The development pace is rapid, features are churned out in around 2 weeks time (including testing) • Product management is always running experiments and adjusting plans based on data from instrumentation • Developer to quality assurance ratio hovers somewhere around 10:1
  • 5. SO WHAT DO YOU MEAN BY JELL-O® Jell-O [jel-oh] Site wide A/B tests where ½ of users will see a complete site redesign and the other ½ will use the site as it was before. Facebook app users can also split between different A and B designs at times. Each A & B may have its own JS, CSS, and business logic to go along with it. Not to mention that different versions of the API were being used by the web, Facebook app, and mobile apps. All the while, different features were being enabled and disabled for different subsets of the A/B test groups
  • 6.
  • 7.
  • 8. WHAT CAN GO WRONG? • General • Not enough information is retrieved to reproduce the failure • Elements • The type can change (e.g. dropdown becomes a checkbox) • An element can change location • An element can have multiple ways of identifying itself depending on an A/B test • Business Logic • Logic can change for one platform • Logic can change for some users and not others (A/B test) • Logic can change for all platforms
  • 9. HOW DO WE COMBAT THESE PROBLEMS? • General • Not enough information is retrieved to reproduce the failure • Separate test actions from controller code, add abundant logging, and unify the patterns by which common operations are accomplished (e.g. selecting from dropdown) Don’t access selenium directly in any scripts. Create a wrapper that logs everything and performs basic checks. (e.g. is the choice available on the dropdown) • If libraries are used then you can log just about everything possible every time without having to re-paste all the logging code
  • 10. HOW DO WE COMBAT THESE PROBLEMS? (CONT.) • Elements • The type can change • Abstracting away all uses of the item into a library • An element can change location • Centralize all hooks into the UI, you can change it once and it will be fixed for all • Using reflection, you can verify that all of your hooks are functional • An element can have multiple ways of identifying itself depending on an A/B test • ID’s are great, but you can also use an XPath Or expression in your centralized hook
  • 11. HOW DO WE COMBAT THESE PROBLEMS? (CONT.) • Business Logic • Logic can change for one platform • Update the library for that platform • Logic can change for some users and not others (A/B test) • Detect the A/B test in the library • Logic can change for all platforms • Generic Libraries or test scripts which coordinate platform specific libraries are a great place to address this
  • 12. HOW DO YOU DEAL WITH THAT AGAIN? • Separate logical actions From calls to controller (in this case Selenium) code into libraries • Centralize your site model and logic, so that all automation runs through one place. When you have to fix something, you can fix it once for everything. • Write code that can test the test automation. Investigating test script failures can be costly, but if you test code can test itself you will be able to pick out certain kinds of problems easily. • Write platform-agnostic test scripts when possible. This leaves you with one copy of site-logic and test-logic for all platforms. When things change, you’ll be happy its in one place.
  • 13. SEPARATION OF CONTROL FROM SCRIPTING • An extra layer is great to log information and perform additional actions that Selenium can’t assume it needs to do • We use a layer between that wraps logging, error handling, and some other things on top of most WebDriver commands Test Script •IsSignedIn() •Log(“Retrieving Cookie Auth”); Action •var authCookie = GetCookie(auth); •Log(authCookie); Library •return authCookie != null; •Log (“Getting Cookies”); •var c = Driver.Manage.().Cookies; WebDriver •Log(c); •var a = Driver.Manage().Cookies[“auth”]; Wrapper •Log(“Cookie value: “ + a.ToString()); return a;
  • 14. CENTRALIZING YOUR SITE MODEL FOR SELF -TESTING • All hooks (means by which we retrieve WebElements) are stored in a single class, namespace, or something similar • Elements are stored lazily; the means to retrieve them are stored, but the actual WebElement is not retrieved until run-time. We use classes that wrap calls to By or methods which will return a WebElements • Hooks are grouped relevantly and each group has private self-test setup methods which will navigate the client (e.g. selenium) to where the hooks exist • Reflection is used to iterate through all of these groups and run the private self-test setup methods and then validate the functionality of the elements • Annotations (Java) or Attributes (C#) are used to exclude elements from the tests
  • 15. ABOUT INTROSPECTION & REFLECTION Introspection (Java) and Reflection (C#) is the process by which a computer program can observe, do type introspection, and modify its own structure and behavior at runtime. In the example to follow we store information about how to use various hooks (references to pieces of user interface) in the code so that later at runtime we can use the information to determine how to test our library of hooks.
  • 16. CENTRALIZED HOOKS [C#] namespace Automation.Hooks.Web { public static class LoginPage { public static WebHook EmailField = By.Id(“email”); public static WebHook PasswordField = By.Id(“password”); public static WebHook SubmitButton = By.Id(“submit”); [OmitFromSelfTest] public static WebHook Spinner = By.Xpath(“//div[@class=’wait’]”); private static void _StartSelfTest() { _SelfTestSeleniumInterface.Open(“http://www.zoosk.com”) } } }
  • 17. SIMPLE SELF-TEST [PseudoCode] // iterate in depth-first-search order foreach(class c in Automation.Hooks.Web) { if c.hasMethod(“StartSelfTest”) c.executeMethod(“StartSelfTest”); foreach(WebHook h in c) Log.Verify(IsElementPresent(h)); if c.hasMethod(“StopSelfTest”) c.executeMethod(“StopSelfTest”); }
  • 18. MORE ADVANCED TECHNIQUES • Subclass WebHook to things like TextBoxHook and have the test check for reading and writing from the text field using Selenium • Do the same for Links, Images, etc. and write custom test methods • Randomize the order of which elements are tested to check for robustness • Add random data to the tests, e.g. type a random string into the text box. • Write custom test methods for structures that require it
  • 19. CONSOLIDATING AND ABSTRACTING PRODUCT LEVEL ACTIONS • Product Level Actions (e.g. Sign In To The Site) are stored in libraries, so that there exists one good copy that everyone can use • The libraries implement generic interfaces so the platform can be abstracted away (i.e. the native iPhone app and the website both have libraries with a signup function that conforms to an interface that can be used in any test script) • If the process changes for a particular platform, you can update it in a single place • If the process change across all platforms, you can use platform agnostic (generic) libraries and update the logic in a single place
  • 20. ABSTRACT LIBRARIES [C#] namespace Automation.Libraries { public SeleniumActionLibrary WebSignUpLib : ISignUpLib { public void SignIn(string email, string password) { if (IsSignedIn()) return; if (!Driver.Url.contains(“login.php”); Driver.Navigate().GoToUrl(“https://www.zoosk.com/login.php”); Hooks.Web.LoginPage.EmailField.type(email); Hooks.Web.LoginPage.PasswordField.type(password); Hooks.Web.LoginPage.SubmitButton.click(); WaitForElementToNotExist(Hooks.Web.LoginPage.Spinner); } } }
  • 21. LIBRARY INTERFACE [C#] namespace Automation.Libraries { interface ISignUpLib { void SignIn(string email, string password); bool IsSignedIn(string email, string password); void SignOut(); } }
  • 22. PLATFORM AGNOSTIC AUTOMATION SCRIPTS • Many tests that need to be run are logically identical across all platforms. • Deactivate an account, attempt to sign in, expect failure • Send a message, verify it shows up in sent items • Take down some web service, verify an error is produced • Implemented these tests at an abstract level allows you to have one test for all platforms • When the logic changes, the logic only exists one place in your automation code
  • 23. AN ABSTRACTED TEST [C#] namespace Automation.Tests { public static class SignInWithDeactivatedAccountTest: Test { public static void Run() { AutomationClient [] clients = new AutomationClient[] { new WebClient(), new iPhoneClient() } var account = APIUtility.Accounts.CreateTestAccount(); APIUtility.Accounts.Deactivate(account); foreach(AutomationClient client in clients) { client.SignUpInterface.SignIn(account.email, acount.password); Log.VerifyFalse(!client.IsSignedIn()); }}}}
  • 24. CONCLUSION Developers and Designers frequently have to be able to adapt to rapidly changing code, automation writers can be just as nimble. If you design and abstract your code well, you can build smaller, more robust and agile automation scripts. If anyone is interested in taking up work on bringing iOS support to Selenium… Call Me.
  • 25. MORE INFO Dan Cuellar Lead Software Engineer – QA Team danc@zoosk.com (Email me to retrieve related source code available for sharing) See Also Self-Generating Test Artifacts for Selenium WebDriver Tue 12:20PM – Track B – Marcus Merrell Building Quality on Foundations of Mud Tue 2:40PM – Track A – Kristian Rosenwold The Restless Are Going Native Wed 2:20PM – Track A – Dante Briones