SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Test Data Preparation: Tips and Tricks
Sargis Sargsyan
Sr. Automation QA Engineer at Workfront
SQA Days 2017
2
TABLE OF CONTENTS - OUR AGENDA
What is Test Data?
Why is it
Important?
1
What is Test Data
Generation?
2
Why should test
data be created
before test
execution?
3
Object class
generation based
on JSON
4
Maintaining
responses of HTTP
requests using
Jackson library
5
How to store login
info in browser to
avoid logging in
from UI
6
Q&A
7
Test Data
Preparation via
HTTP requests
4
SQA Days 2017
3
WHAT IS TEST DATA?WHY IS IT IMPORTANT?
1. A single Selenium test should test one and only thing. A bug in another part of the application
that is not exactly related to the test should not cause the test to fail.
2. Every test should be independent. The test outcome should not affected by another test in the
suite.
3. Make a faster tests. As quicker test suite as much useful it is.
4. Every test should create and clean the data before and the after the test run.
5. We should not do the same action from the UI for every test case (e.g. login action)
When we are talking about best practice in Seleniumtest,
some of things often come up are:
SQA Days 2017
4
WHAT IS TEST DATA?WHY IS IT IMPORTANT?
Each test run does the following
Run the testTest initialize Test clean up
SQA Days 2017
5
WHAT IS TEST DATA GENERATION?
Test Data Generators based on their approaches are typically classified into
Random Test Data Generators
Goal OrientedGenerators Intelligent Test Data Generators
Pathwise Data Generators
TD
SQA Days 2017
6
WHY SHOULD TEST DATA BE CREATED BEFORE TEST EXECUTION?
!
!
Login 
Submissions 
 Pages	Navigation

TD
The reason for this is that
Selenium tests often involve
setups that may include
Only after doing those things
you are ready to assert
on some aspect of the website
 Actions
Sign	up   Interactions
Test Data Preparation via HTTP requests
SQA Days 2017
8
BASIC IDEA BEHIND COMBINING THESE TOOLS
These are thesteps how to get started with OKHttpand Test Data Preparation
FIRST STEP
We will be creating
instances of HTTP
for various methods
like GET,PUT,POST
etc. by mentioning
the request URL
SECOND STEP
We will be
composing the
request body as
JSON
THIRD STEP
Execute the desired
HTTP method when
headers etc are all
set
FOURTH STEP
Capture the
response and
convert it to a JSON
object.
FIFTH STEP
Desterialize JSON to
any Java Object
SQA Days 2017
9
OKHTTP - WILL DO REST FOR YOU
SQA Days 2017
10
POSTMAN - BEST FRIEND OF YOU
SQA Days 2017
11
OKHTTP - BASIC EXAMPLE FOR GET
SQA Days 2017
12
OKHTTP - BASIC EXAMPLE FOR POST
SQA Days 2017
13
GENERATE JAVA OBJECT CLASS BASED ON JSON
SQA Days 2017
14
GENERATE JAVA OBJECT CLASS BASED ON JSON
SQA Days 2017
15
JACKSON- CONVERT JAVA OBJECT TO / FROM JSON
15
Let’s see how to use Jackson 2.x to convert Java object to / from JSON.
Convert Java object to
JSON

Convert JSON to Java
object

SQA Days 2017
16
JACKSON - CONVERT JAVA OBJECT TO JSON
16

SQA Days 2017
17
JACKSON - JSON FROM STRING TO OBJECT
17

SQA Days 2017
18
JACKSON - RETRIEVE OBJECT VIA API
18
Skipping login fromUI
SQA Days 2017
20
AVOID CONSTANTLY TESTING LOGIN PAGE
These 3 steps to skip testing Login continuously
send an HTTP request to log
in
set the session cookie value
Navigate to a app specific
page

Login Succeed
SQA Days 2017
21
GENERATE SESSION ID VIA API
SQA Days 2017
22
GENERATE SESSION ID VIA API
SQA Days 2017
23
A SINGLE TEST WILL LOOK LIKE
SQA Days 2017
24
SINGLE TEST RUN
BestPracticevs. BadPractice
SQA Days 2017
26
BEST PRACTICE VS. BAD PRACTICE
Use PageObjects
pattern
"
SQA Days 2017
27
BEST PRACTICE VS. BAD PRACTICE
XPATH is the best
selector to use
#
Preferred selector order : id> name > css > xpath
SQA Days 2017
28
BEST PRACTICE VS. BAD PRACTICE
Automate
CAPTCHAS
#
CAPTCHAs canbebypassed using twostrategies:
• The firstidea isto disableCAPTCHAsinyour test environment.
• The second idea is toadd a hook to allowtests to bypassthe CAPTCHA.
SQA Days 2017
29
BEST PRACTICE VS. BAD PRACTICE
Create Specific
Application User per
Test
"
SQA Days 2017
30
BEST PRACTICE VS. BAD PRACTICE
Suite Retries
#"
SQA Days 2017
31
BEST PRACTICE VS. BAD PRACTICE
Gmail and Facbook
Logins
#
WebDriver is not the ideal choicetoautomate loginintowebsites likeGmail andFacebook,
firstlybecause it isagainsttheir policy and secondly because it isslow and unreliable.
The most appropriatechoicewould be to usethe API that these websites provide.
SQA Days 2017
32
BEST PRACTICE VS. BAD PRACTICE
Performance Testing
Using WebDriver
#
Using selenium WebDriver is not anideal choice for performance testing, not
because it can’tdoit but becauseit is not meant for thisjob ultimatelytester
might not get good results.
SQA Days 2017
33
BEST PRACTICE VS. BAD PRACTICE
Make Tests
Independent Of Each
Other
"
SQA Days 2017
34
BEST PRACTICE VS. BAD PRACTICE
Avoid Thread.sleep
prefer Wait or
FluentWait
"
QUESTIONS?
Go Ahead, Don’t Hesitate!
?
THANK YOU!
Have a Nice Day!


@sargisqa

/sargissargsyansargis.sargsyan@live.com

Más contenido relacionado

La actualidad más candente

W3C Web Performance - A detailed overview
W3C Web Performance - A detailed overviewW3C Web Performance - A detailed overview
W3C Web Performance - A detailed overview
Alois Reitbauer
 

La actualidad más candente (20)

Hugs instead of Bugs: Dreaming of Quality Tools for Devs and Testers
Hugs instead of Bugs: Dreaming of Quality Tools for Devs and TestersHugs instead of Bugs: Dreaming of Quality Tools for Devs and Testers
Hugs instead of Bugs: Dreaming of Quality Tools for Devs and Testers
 
Building Reactive, Realtime Apps Without Writing Javascript
Building Reactive, Realtime Apps Without Writing JavascriptBuilding Reactive, Realtime Apps Without Writing Javascript
Building Reactive, Realtime Apps Without Writing Javascript
 
Web and App Performance: Top Problems to avoid to keep you out of the News
Web and App Performance: Top Problems to avoid to keep you out of the NewsWeb and App Performance: Top Problems to avoid to keep you out of the News
Web and App Performance: Top Problems to avoid to keep you out of the News
 
BDD in Java using Cucumber
BDD in Java using CucumberBDD in Java using Cucumber
BDD in Java using Cucumber
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Four Practices to Fix Your Top .NET Performance Problems
Four Practices to Fix Your Top .NET Performance ProblemsFour Practices to Fix Your Top .NET Performance Problems
Four Practices to Fix Your Top .NET Performance Problems
 
Load testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerLoad testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew Siemer
 
W3C Web Performance - A detailed overview
W3C Web Performance - A detailed overviewW3C Web Performance - A detailed overview
W3C Web Performance - A detailed overview
 
Database DevOps Anti-patterns
Database DevOps Anti-patternsDatabase DevOps Anti-patterns
Database DevOps Anti-patterns
 
Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015
Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015
Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015
 
How to keep you out of the News: Web and End-to-End Performance Tips
How to keep you out of the News: Web and End-to-End Performance TipsHow to keep you out of the News: Web and End-to-End Performance Tips
How to keep you out of the News: Web and End-to-End Performance Tips
 
Testing Any Site With Cucumber and Selenium
Testing Any Site With Cucumber and SeleniumTesting Any Site With Cucumber and Selenium
Testing Any Site With Cucumber and Selenium
 
Getting CI right for SQL Server
Getting CI right for SQL ServerGetting CI right for SQL Server
Getting CI right for SQL Server
 
Discovering Hot Topics in the Blogosphere
Discovering Hot Topics in the BlogosphereDiscovering Hot Topics in the Blogosphere
Discovering Hot Topics in the Blogosphere
 
DevOps 101 for data professionals
DevOps 101 for data professionalsDevOps 101 for data professionals
DevOps 101 for data professionals
 
Deploy Faster Without Failing Faster - Metrics-Driven - Dynatrace User Groups...
Deploy Faster Without Failing Faster - Metrics-Driven - Dynatrace User Groups...Deploy Faster Without Failing Faster - Metrics-Driven - Dynatrace User Groups...
Deploy Faster Without Failing Faster - Metrics-Driven - Dynatrace User Groups...
 
HSPS 2015 - SharePoint Performance Santiy Checks
HSPS 2015 - SharePoint Performance Santiy ChecksHSPS 2015 - SharePoint Performance Santiy Checks
HSPS 2015 - SharePoint Performance Santiy Checks
 
Lets cook cucumber !!
Lets cook cucumber !!Lets cook cucumber !!
Lets cook cucumber !!
 
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond AgileEngineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
 
Going Offline with Salesforce1 Mobile SDK
Going Offline with Salesforce1 Mobile SDKGoing Offline with Salesforce1 Mobile SDK
Going Offline with Salesforce1 Mobile SDK
 

Similar a Test Data Preparation: Tips and Tricks - SQA Days 22 - Saint Petersburg

So Your Boss Wants You to Performance Test Blackboard
So Your Boss Wants You to Performance Test BlackboardSo Your Boss Wants You to Performance Test Blackboard
So Your Boss Wants You to Performance Test Blackboard
Steve Feldman
 

Similar a Test Data Preparation: Tips and Tricks - SQA Days 22 - Saint Petersburg (20)

Optimizing React at Postmates
Optimizing React at PostmatesOptimizing React at Postmates
Optimizing React at Postmates
 
qTest 7.4: New Features
qTest 7.4: New FeaturesqTest 7.4: New Features
qTest 7.4: New Features
 
Content migration for sitecore
Content migration for sitecoreContent migration for sitecore
Content migration for sitecore
 
Accelerating Your Test Execution Pipeline
Accelerating Your Test Execution PipelineAccelerating Your Test Execution Pipeline
Accelerating Your Test Execution Pipeline
 
So Your Boss Wants You to Performance Test Blackboard
So Your Boss Wants You to Performance Test BlackboardSo Your Boss Wants You to Performance Test Blackboard
So Your Boss Wants You to Performance Test Blackboard
 
Make Your Selenium Suite Faster and Reliable: Test Setup with REST APIs - SQA...
Make Your Selenium Suite Faster and Reliable: Test Setup with REST APIs - SQA...Make Your Selenium Suite Faster and Reliable: Test Setup with REST APIs - SQA...
Make Your Selenium Suite Faster and Reliable: Test Setup with REST APIs - SQA...
 
ASP.NET 5 & Unit Testing
ASP.NET 5 & Unit TestingASP.NET 5 & Unit Testing
ASP.NET 5 & Unit Testing
 
ATAGTR2017 CDC Tests - Integration Tests cant be made simpler than this!
ATAGTR2017 CDC Tests - Integration Tests cant be made simpler than this!ATAGTR2017 CDC Tests - Integration Tests cant be made simpler than this!
ATAGTR2017 CDC Tests - Integration Tests cant be made simpler than this!
 
Job portal
Job portalJob portal
Job portal
 
Test Framework for Acne Selenium+Sahi
Test Framework for Acne Selenium+SahiTest Framework for Acne Selenium+Sahi
Test Framework for Acne Selenium+Sahi
 
Developer Night Opticon 2017
Developer Night Opticon 2017Developer Night Opticon 2017
Developer Night Opticon 2017
 
Atlassian's Mystique CLI, Minimizing the Experiment Development Cycle
Atlassian's Mystique CLI, Minimizing the Experiment Development CycleAtlassian's Mystique CLI, Minimizing the Experiment Development Cycle
Atlassian's Mystique CLI, Minimizing the Experiment Development Cycle
 
Job portal at jiit 2013-14
Job portal at jiit 2013-14Job portal at jiit 2013-14
Job portal at jiit 2013-14
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 
Helpful Automation Techniques - Selenium Camp 2014
Helpful Automation Techniques - Selenium Camp 2014Helpful Automation Techniques - Selenium Camp 2014
Helpful Automation Techniques - Selenium Camp 2014
 
QA Fes 2016. Jacek Okrojek. Website performance from user perspective
QA Fes 2016. Jacek Okrojek. Website performance from user perspectiveQA Fes 2016. Jacek Okrojek. Website performance from user perspective
QA Fes 2016. Jacek Okrojek. Website performance from user perspective
 
QTP ONLINE TRAINING
QTP ONLINE TRAININGQTP ONLINE TRAINING
QTP ONLINE TRAINING
 
Ashish Baraiya
Ashish BaraiyaAshish Baraiya
Ashish Baraiya
 
Shuvam dutta | Performance testing & engineering
Shuvam dutta | Performance testing & engineeringShuvam dutta | Performance testing & engineering
Shuvam dutta | Performance testing & engineering
 
Continuous Testing
Continuous TestingContinuous Testing
Continuous Testing
 

Más de Sargis Sargsyan

Más de Sargis Sargsyan (13)

Let’s Talk About Quality Engineering
Let’s Talk About Quality EngineeringLet’s Talk About Quality Engineering
Let’s Talk About Quality Engineering
 
Your Road to Quality Assurance
Your Road to Quality AssuranceYour Road to Quality Assurance
Your Road to Quality Assurance
 
Appium Dockerization: from Scratch to Advanced Implementation - HUSTEF 2019
Appium Dockerization: from Scratch to Advanced Implementation - HUSTEF 2019Appium Dockerization: from Scratch to Advanced Implementation - HUSTEF 2019
Appium Dockerization: from Scratch to Advanced Implementation - HUSTEF 2019
 
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
 
Run your Appium tests using Docker Android - AppiumConf 2019
Run your Appium tests using Docker Android - AppiumConf 2019Run your Appium tests using Docker Android - AppiumConf 2019
Run your Appium tests using Docker Android - AppiumConf 2019
 
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
 
Easy Setup for Parallel Test Execution with Selenium Docker
Easy Setup for Parallel Test Execution with Selenium DockerEasy Setup for Parallel Test Execution with Selenium Docker
Easy Setup for Parallel Test Execution with Selenium Docker
 
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
 
Agile Testing
Agile TestingAgile Testing
Agile Testing
 
Selenium Testing on Chrome - Google DevFest Armenia 2015
Selenium Testing on Chrome - Google DevFest Armenia 2015Selenium Testing on Chrome - Google DevFest Armenia 2015
Selenium Testing on Chrome - Google DevFest Armenia 2015
 
Web Application Testing with Selenium
Web Application Testing with Selenium Web Application Testing with Selenium
Web Application Testing with Selenium
 
QA MeetUp Yerevan - Aug 25
QA MeetUp Yerevan - Aug 25QA MeetUp Yerevan - Aug 25
QA MeetUp Yerevan - Aug 25
 

Último

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 

Test Data Preparation: Tips and Tricks - SQA Days 22 - Saint Petersburg

  • 1. Test Data Preparation: Tips and Tricks Sargis Sargsyan Sr. Automation QA Engineer at Workfront
  • 2. SQA Days 2017 2 TABLE OF CONTENTS - OUR AGENDA What is Test Data? Why is it Important? 1 What is Test Data Generation? 2 Why should test data be created before test execution? 3 Object class generation based on JSON 4 Maintaining responses of HTTP requests using Jackson library 5 How to store login info in browser to avoid logging in from UI 6 Q&A 7 Test Data Preparation via HTTP requests 4
  • 3. SQA Days 2017 3 WHAT IS TEST DATA?WHY IS IT IMPORTANT? 1. A single Selenium test should test one and only thing. A bug in another part of the application that is not exactly related to the test should not cause the test to fail. 2. Every test should be independent. The test outcome should not affected by another test in the suite. 3. Make a faster tests. As quicker test suite as much useful it is. 4. Every test should create and clean the data before and the after the test run. 5. We should not do the same action from the UI for every test case (e.g. login action) When we are talking about best practice in Seleniumtest, some of things often come up are:
  • 4. SQA Days 2017 4 WHAT IS TEST DATA?WHY IS IT IMPORTANT? Each test run does the following Run the testTest initialize Test clean up
  • 5. SQA Days 2017 5 WHAT IS TEST DATA GENERATION? Test Data Generators based on their approaches are typically classified into Random Test Data Generators Goal OrientedGenerators Intelligent Test Data Generators Pathwise Data Generators TD
  • 6. SQA Days 2017 6 WHY SHOULD TEST DATA BE CREATED BEFORE TEST EXECUTION? ! ! Login  Submissions   Pages Navigation  TD The reason for this is that Selenium tests often involve setups that may include Only after doing those things you are ready to assert on some aspect of the website  Actions Sign up   Interactions
  • 7. Test Data Preparation via HTTP requests
  • 8. SQA Days 2017 8 BASIC IDEA BEHIND COMBINING THESE TOOLS These are thesteps how to get started with OKHttpand Test Data Preparation FIRST STEP We will be creating instances of HTTP for various methods like GET,PUT,POST etc. by mentioning the request URL SECOND STEP We will be composing the request body as JSON THIRD STEP Execute the desired HTTP method when headers etc are all set FOURTH STEP Capture the response and convert it to a JSON object. FIFTH STEP Desterialize JSON to any Java Object
  • 9. SQA Days 2017 9 OKHTTP - WILL DO REST FOR YOU
  • 10. SQA Days 2017 10 POSTMAN - BEST FRIEND OF YOU
  • 11. SQA Days 2017 11 OKHTTP - BASIC EXAMPLE FOR GET
  • 12. SQA Days 2017 12 OKHTTP - BASIC EXAMPLE FOR POST
  • 13. SQA Days 2017 13 GENERATE JAVA OBJECT CLASS BASED ON JSON
  • 14. SQA Days 2017 14 GENERATE JAVA OBJECT CLASS BASED ON JSON
  • 15. SQA Days 2017 15 JACKSON- CONVERT JAVA OBJECT TO / FROM JSON 15 Let’s see how to use Jackson 2.x to convert Java object to / from JSON. Convert Java object to JSON  Convert JSON to Java object 
  • 16. SQA Days 2017 16 JACKSON - CONVERT JAVA OBJECT TO JSON 16 
  • 17. SQA Days 2017 17 JACKSON - JSON FROM STRING TO OBJECT 17 
  • 18. SQA Days 2017 18 JACKSON - RETRIEVE OBJECT VIA API 18
  • 20. SQA Days 2017 20 AVOID CONSTANTLY TESTING LOGIN PAGE These 3 steps to skip testing Login continuously send an HTTP request to log in set the session cookie value Navigate to a app specific page  Login Succeed
  • 21. SQA Days 2017 21 GENERATE SESSION ID VIA API
  • 22. SQA Days 2017 22 GENERATE SESSION ID VIA API
  • 23. SQA Days 2017 23 A SINGLE TEST WILL LOOK LIKE
  • 26. SQA Days 2017 26 BEST PRACTICE VS. BAD PRACTICE Use PageObjects pattern "
  • 27. SQA Days 2017 27 BEST PRACTICE VS. BAD PRACTICE XPATH is the best selector to use # Preferred selector order : id> name > css > xpath
  • 28. SQA Days 2017 28 BEST PRACTICE VS. BAD PRACTICE Automate CAPTCHAS # CAPTCHAs canbebypassed using twostrategies: • The firstidea isto disableCAPTCHAsinyour test environment. • The second idea is toadd a hook to allowtests to bypassthe CAPTCHA.
  • 29. SQA Days 2017 29 BEST PRACTICE VS. BAD PRACTICE Create Specific Application User per Test "
  • 30. SQA Days 2017 30 BEST PRACTICE VS. BAD PRACTICE Suite Retries #"
  • 31. SQA Days 2017 31 BEST PRACTICE VS. BAD PRACTICE Gmail and Facbook Logins # WebDriver is not the ideal choicetoautomate loginintowebsites likeGmail andFacebook, firstlybecause it isagainsttheir policy and secondly because it isslow and unreliable. The most appropriatechoicewould be to usethe API that these websites provide.
  • 32. SQA Days 2017 32 BEST PRACTICE VS. BAD PRACTICE Performance Testing Using WebDriver # Using selenium WebDriver is not anideal choice for performance testing, not because it can’tdoit but becauseit is not meant for thisjob ultimatelytester might not get good results.
  • 33. SQA Days 2017 33 BEST PRACTICE VS. BAD PRACTICE Make Tests Independent Of Each Other "
  • 34. SQA Days 2017 34 BEST PRACTICE VS. BAD PRACTICE Avoid Thread.sleep prefer Wait or FluentWait "
  • 36. THANK YOU! Have a Nice Day!   @sargisqa  /sargissargsyansargis.sargsyan@live.com