SlideShare une entreprise Scribd logo
11th Meetup
18 July 2019
DBS, Singapore
Good practices for
debugging Selenium
and Appium tests
Abhijeet Vaikar
Senior Software Engineer Test @ Carousell
Co-organizer @ taqelah!
Testing web and mobile apps since 7 years
LinkedIn: https://www.linkedin.com/in/abhijeetvaikar/
Twitter: https://twitter.com/AbhijeetVaikar
Poll Time
Testing is a process of
Learning, Discovering, Exploring, Analysing a
system.
Automated testing, thus is
also a process of
Learning, Discovering, Exploring, Analysing a
system
where the system is:
● the AUT
● and your test code too!
Typical iteration of an automated UI test
Local Execution
● Running test locally
● Verifying it works fine
● Fix if it breaks
Continuous
Integration
● Run the test along with
other tests on a CI
server against an
in-house device farm
or a cloud provider
● Analyse test runs
Test Authoring and
Prototyping
● Acceptance Criteria
● Inspecting the UI
● Creating UI locators
● Writing the test code
● Adding assertions
Pass
Automated Test
Fail
What failed?
Why it failed?
Where it failed?
When it failed?
A tester’s reactions to each iteration
Authoring
Local Execution
CI execution
What
failed?
Where it
failed?
When it
failed?
Why it
failed? DEBUGGING!
Sources of debugging your Selenium/Appium code
● UI Inspectors and browser dev tools for debugging locators
● REPL tools for trying out Selenium/Appium client commands
● Debuggers in your IDE
● Test execution logs
● Selenium/Appium server logs
● Javascript console logs in browser
● Logs produced by native mobile apps
● Network logs
UI Inspectors and browser dev tools for
debugging locators
Appium Desktop for UI inspection
What can you do with Appium desktop?
● Inspect the UI hierarchy interactively
● Design and try out locators with different strategies
● Swipe by coordinates
● Tap by coordinates
● Record actions and convert them to script in the language of your choice
(Javascript, Java-JUnit, Ruby, Python, Robot framework) along with boiler
plate code
● Copy the XML UI hierarchy source which you can then inspect
● (New) Actions tab to execute device and session based actions
Macaca Inspector
https://macacajs.github.io/app-inspector/
Web based UI
inspector for both
iOS and Android
platforms
Android specific: UiAutomator Viewer
iOS specific: XCode’s Accessibility inspector
Want more?
Chrome dev tools
● Ctrl + F and paste your locator to evaluate
● Hit $x(“//*your-xpath-here”) in the console to evaluate a xpath
● Hit $(“your-css-selector”) in the console to evaluate a css selector
● Cheat sheets are your best friends (preferably avoid browser plugins that generate xpath/css selectors for
you):
https://www.red-gate.com/simple-talk/development/dotnet-development/xpath-css-dom-and-selenium-the-r
osetta-stone/
REPL tools for debugging
Selenium/Appium client commands
JShell - The REPL for Java (Since Java 9)
https://www.linkedin.com/pulse/test-automation-selenium-webdriver-java-cli-via-jshell-nir-tal/
You can also use the
evaluate expression
feature in IDEs like
Eclipse/IntelliJ
WebDriverIO REPL (Javascript) - for both Selenium and Appium
https://webdriver.io/docs/repl.html
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/'
)
Python shell - REPL for Python
Python being an interpreter, you can run each line of code separately in
Python shell
https://pypi.org/project/selenium/
Ruby
Build your own REPL for Selenium/Appium:
http://elementalselenium.com/tips/11-build-an-interactive-prompt
ARC (Appium Ruby Console):
https://github.com/appium/ruby_console
NodeJS
Appium REPL:
https://www.npmjs.com/package/appium-repl
Debuggers in your IDE
What do you prefer?
System.out.println("I'm here");
System.out.println("Inside the function");
System.out.println("Outside the loop");
Imagine debugging across
multiple classes by adding print
statements!
How to use a debugger - 101
1. Add a breakpoint against the
line of code you want to start
debugging from
2. Execute your test runner in
Debug mode
SAGE MODE ACTIVATED
● Step Over
● Step Into
● Force Step Into
● Step Out
● Evaluate Expression
● Resume normal execution
● Inspect all variables/objects
https://naruto.fandom.com/wiki/Sage_Mode
Test execution logs
Use Logging libraries instead of:
● System.out.println() - Java
● Console.log() - Javascript/NodeJS
● print() - Python
● Puts - Ruby
Test execution logs as a source for debugging test runs:
● Useful to understand what happened in your test
● Logs can be used for generating test reports
Why use a logging framework for your tests?
● Customized output - Easy formatting
● Logging levels (INFO, WARN, ERROR, DEBUG, TRACE)
● Can easily switch it on or off based on requirement
● Ability to persist log output on various storage
mechanisms (file, database)
● System.out.println() is an I/O operation
Examples
LOG.info("Initialising WebDriver on cloud provider: {}" ,
configuration. getCloudProvider ().toUpperCase());
LOG.info("TEST PASSED");
catch (WebDriverException e) {
LOG.error("Error creating web driver" , e);
System.exit(1);
}
LOG.warn("API call failed. Retrying again" );
LOG.warn("Unable to write the report json file : {}" ,
e);
Info - Logging important information
Error - Something went very wrong
Warn - Unstable but can be recovered
LOG.debug("Dismissing alert {}" , alert)
Debug - Information only meant for debugging purpose
Selenium/Appium server logs
Selenium WebDriver logs
System.setProperty("webdriver.chrome.logfile" , "D:chromedriver.log" );
System.setProperty("webdriver.chrome.verboseLogging" , "true");
System.setProperty(FirefoxDriver. SystemProperty .DRIVER_USE_MARIONETTE ,"true");
System.setProperty(FirefoxDriver. SystemProperty .BROWSER_LOGFILE ,"C:templogs.t
xt");
Appium server logs
--log /path/to/appium.log
Server argument (When you start appium server)
LogEntries logEntries =
driver.manage().logs().get("server”);
Programmatically
Javascript console logs in browser
How to keep Chrome dev tools open while you are
debugging your Selenium test locally
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions" );
options.addArguments("--auto-open-devtools-for-tabs" );
driver = new ChromeDriver(options);
How to fetch browser console logs (including errors)
programmtically
LogEntries logEntries =
driver.manage().logs().get(LogType.BROWSER);
Logs produced by native mobile apps
Fetching ADB logs for Android device for debugging
List<LogEntry> logEntries =
driver.manage().logs().get("logcat").getAll();
Fetching iOS device logs
● idevicesyslog tool from the command line for real iOS Device
● Console app on MacOS to read console log from simulator
Network Logs
MITMProxy - free and open source HTTPS
proxy
MITMProxy Java - A java wrapper for MITM
Proxy
Fiddler for Windows and MacOS
What techniques or practices do
you follow to debug your
automation scripts?
Please share!
Thank you!

Contenu connexe

Tendances

Logistics Business Proposal PowerPoint Presentation Slides
Logistics Business Proposal PowerPoint Presentation SlidesLogistics Business Proposal PowerPoint Presentation Slides
Logistics Business Proposal PowerPoint Presentation Slides
SlideTeam
 
car accessories marketing project BBA 3 sem
 car accessories marketing project BBA 3 sem  car accessories marketing project BBA 3 sem
car accessories marketing project BBA 3 sem
Rahul Cts
 
Zolo stays
Zolo stays Zolo stays
Zolo stays
mehtaaman184
 
Ola presentation
Ola presentationOla presentation
Ola presentation
AnandKapur3
 
Firm_Profile_SRKN_ASSOCIATES 07032016
Firm_Profile_SRKN_ASSOCIATES 07032016Firm_Profile_SRKN_ASSOCIATES 07032016
Firm_Profile_SRKN_ASSOCIATES 07032016
SRKN ASSOCIATES
 
e-Invoicing for Manufacturers
e-Invoicing for Manufacturerse-Invoicing for Manufacturers
e-Invoicing for Manufacturers
Mark Morley, MBA
 
Augmented Reality in Tourism
Augmented Reality in TourismAugmented Reality in Tourism
Augmented Reality in Tourism
banholzer76
 
Mc carthy proposal
Mc carthy proposalMc carthy proposal
Mc carthy proposal
Gloveries
 
Basic of Air Ticketing & IATA Geography
Basic of Air Ticketing & IATA GeographyBasic of Air Ticketing & IATA Geography
Basic of Air Ticketing & IATA Geography
Md Shaifullar Rabbi
 
Travel api integration provider
Travel api integration providerTravel api integration provider
Travel api integration provider
HenryRoss10
 
Heurion Consulting Company Profile
Heurion Consulting Company ProfileHeurion Consulting Company Profile
Heurion Consulting Company Profile
heurionconsulting
 

Tendances (11)

Logistics Business Proposal PowerPoint Presentation Slides
Logistics Business Proposal PowerPoint Presentation SlidesLogistics Business Proposal PowerPoint Presentation Slides
Logistics Business Proposal PowerPoint Presentation Slides
 
car accessories marketing project BBA 3 sem
 car accessories marketing project BBA 3 sem  car accessories marketing project BBA 3 sem
car accessories marketing project BBA 3 sem
 
Zolo stays
Zolo stays Zolo stays
Zolo stays
 
Ola presentation
Ola presentationOla presentation
Ola presentation
 
Firm_Profile_SRKN_ASSOCIATES 07032016
Firm_Profile_SRKN_ASSOCIATES 07032016Firm_Profile_SRKN_ASSOCIATES 07032016
Firm_Profile_SRKN_ASSOCIATES 07032016
 
e-Invoicing for Manufacturers
e-Invoicing for Manufacturerse-Invoicing for Manufacturers
e-Invoicing for Manufacturers
 
Augmented Reality in Tourism
Augmented Reality in TourismAugmented Reality in Tourism
Augmented Reality in Tourism
 
Mc carthy proposal
Mc carthy proposalMc carthy proposal
Mc carthy proposal
 
Basic of Air Ticketing & IATA Geography
Basic of Air Ticketing & IATA GeographyBasic of Air Ticketing & IATA Geography
Basic of Air Ticketing & IATA Geography
 
Travel api integration provider
Travel api integration providerTravel api integration provider
Travel api integration provider
 
Heurion Consulting Company Profile
Heurion Consulting Company ProfileHeurion Consulting Company Profile
Heurion Consulting Company Profile
 

Similaire à Good practices for debugging Selenium and Appium tests

Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
Luke Maung
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
Javan Rasokat
 
automation framework
automation frameworkautomation framework
automation framework
ANSHU GOYAL
 
Java Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and MobileJava Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and Mobile
Elias Nogueira
 
Slides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testingSlides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testing
SwapnilNarayan
 
Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests
🌱 Dale Spoonemore
 
Selenium
SeleniumSelenium
How to kill test flake in appium
How to kill test flake in appiumHow to kill test flake in appium
How to kill test flake in appium
Gaurav Singh
 
jDriver Presentation
jDriver PresentationjDriver Presentation
jDriver Presentation
freelancer_testautomation
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Selenium
SeleniumSelenium
Selenium
Sun Technlogies
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.com
testingbot
 
Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScript
Simon Guest
 
Testing Ajax Web Applications
Testing Ajax Web ApplicationsTesting Ajax Web Applications
Testing Ajax Web Applications
Ted Husted
 
Continuous Integration, Deploy, Test From Beginning To End 2014
Continuous Integration, Deploy, Test From Beginning To End 2014Continuous Integration, Deploy, Test From Beginning To End 2014
Continuous Integration, Deploy, Test From Beginning To End 2014
Clever Moe
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
coreyjack
 
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QAFest
 
Amit (Automation Testing)
Amit (Automation Testing)Amit (Automation Testing)
Amit (Automation Testing)
AMIT SINGH
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
Vijayan Reddy
 

Similaire à Good practices for debugging Selenium and Appium tests (20)

Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
automation framework
automation frameworkautomation framework
automation framework
 
Java Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and MobileJava Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and Mobile
 
Slides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testingSlides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testing
 
Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests
 
Selenium
SeleniumSelenium
Selenium
 
How to kill test flake in appium
How to kill test flake in appiumHow to kill test flake in appium
How to kill test flake in appium
 
jDriver Presentation
jDriver PresentationjDriver Presentation
jDriver Presentation
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Selenium
SeleniumSelenium
Selenium
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.com
 
Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScript
 
Testing Ajax Web Applications
Testing Ajax Web ApplicationsTesting Ajax Web Applications
Testing Ajax Web Applications
 
Continuous Integration, Deploy, Test From Beginning To End 2014
Continuous Integration, Deploy, Test From Beginning To End 2014Continuous Integration, Deploy, Test From Beginning To End 2014
Continuous Integration, Deploy, Test From Beginning To End 2014
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
 
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
 
Amit (Automation Testing)
Amit (Automation Testing)Amit (Automation Testing)
Amit (Automation Testing)
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 

Plus de Abhijeet Vaikar

Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
Abhijeet Vaikar
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
Abhijeet Vaikar
 
Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...
Abhijeet Vaikar
 
Upgrading Mobile Tester's Weapons with Advanced Debugging
Upgrading Mobile Tester's Weapons with Advanced DebuggingUpgrading Mobile Tester's Weapons with Advanced Debugging
Upgrading Mobile Tester's Weapons with Advanced Debugging
Abhijeet Vaikar
 
Mongo DB 102
Mongo DB 102Mongo DB 102
Mongo DB 102
Abhijeet Vaikar
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
Abhijeet Vaikar
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
Abhijeet Vaikar
 

Plus de Abhijeet Vaikar (7)

Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
 
Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...
 
Upgrading Mobile Tester's Weapons with Advanced Debugging
Upgrading Mobile Tester's Weapons with Advanced DebuggingUpgrading Mobile Tester's Weapons with Advanced Debugging
Upgrading Mobile Tester's Weapons with Advanced Debugging
 
Mongo DB 102
Mongo DB 102Mongo DB 102
Mongo DB 102
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
 

Dernier

zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
ssuserad3af4
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 

Dernier (20)

zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 

Good practices for debugging Selenium and Appium tests

  • 1. 11th Meetup 18 July 2019 DBS, Singapore Good practices for debugging Selenium and Appium tests
  • 2. Abhijeet Vaikar Senior Software Engineer Test @ Carousell Co-organizer @ taqelah! Testing web and mobile apps since 7 years LinkedIn: https://www.linkedin.com/in/abhijeetvaikar/ Twitter: https://twitter.com/AbhijeetVaikar
  • 4. Testing is a process of Learning, Discovering, Exploring, Analysing a system.
  • 5. Automated testing, thus is also a process of Learning, Discovering, Exploring, Analysing a system where the system is: ● the AUT ● and your test code too!
  • 6. Typical iteration of an automated UI test Local Execution ● Running test locally ● Verifying it works fine ● Fix if it breaks Continuous Integration ● Run the test along with other tests on a CI server against an in-house device farm or a cloud provider ● Analyse test runs Test Authoring and Prototyping ● Acceptance Criteria ● Inspecting the UI ● Creating UI locators ● Writing the test code ● Adding assertions
  • 7. Pass Automated Test Fail What failed? Why it failed? Where it failed? When it failed? A tester’s reactions to each iteration Authoring Local Execution CI execution
  • 9.
  • 10. Sources of debugging your Selenium/Appium code ● UI Inspectors and browser dev tools for debugging locators ● REPL tools for trying out Selenium/Appium client commands ● Debuggers in your IDE ● Test execution logs ● Selenium/Appium server logs ● Javascript console logs in browser ● Logs produced by native mobile apps ● Network logs
  • 11. UI Inspectors and browser dev tools for debugging locators
  • 12. Appium Desktop for UI inspection
  • 13. What can you do with Appium desktop? ● Inspect the UI hierarchy interactively ● Design and try out locators with different strategies ● Swipe by coordinates ● Tap by coordinates ● Record actions and convert them to script in the language of your choice (Javascript, Java-JUnit, Ruby, Python, Robot framework) along with boiler plate code ● Copy the XML UI hierarchy source which you can then inspect ● (New) Actions tab to execute device and session based actions
  • 14. Macaca Inspector https://macacajs.github.io/app-inspector/ Web based UI inspector for both iOS and Android platforms
  • 15. Android specific: UiAutomator Viewer iOS specific: XCode’s Accessibility inspector Want more?
  • 16. Chrome dev tools ● Ctrl + F and paste your locator to evaluate ● Hit $x(“//*your-xpath-here”) in the console to evaluate a xpath ● Hit $(“your-css-selector”) in the console to evaluate a css selector ● Cheat sheets are your best friends (preferably avoid browser plugins that generate xpath/css selectors for you): https://www.red-gate.com/simple-talk/development/dotnet-development/xpath-css-dom-and-selenium-the-r osetta-stone/
  • 17. REPL tools for debugging Selenium/Appium client commands
  • 18. JShell - The REPL for Java (Since Java 9) https://www.linkedin.com/pulse/test-automation-selenium-webdriver-java-cli-via-jshell-nir-tal/
  • 19. You can also use the evaluate expression feature in IDEs like Eclipse/IntelliJ
  • 20. WebDriverIO REPL (Javascript) - for both Selenium and Appium https://webdriver.io/docs/repl.html
  • 21. from selenium import webdriver browser = webdriver.Firefox() browser.get('http://seleniumhq.org/' ) Python shell - REPL for Python Python being an interpreter, you can run each line of code separately in Python shell https://pypi.org/project/selenium/
  • 22. Ruby Build your own REPL for Selenium/Appium: http://elementalselenium.com/tips/11-build-an-interactive-prompt ARC (Appium Ruby Console): https://github.com/appium/ruby_console NodeJS Appium REPL: https://www.npmjs.com/package/appium-repl
  • 24. What do you prefer?
  • 25. System.out.println("I'm here"); System.out.println("Inside the function"); System.out.println("Outside the loop"); Imagine debugging across multiple classes by adding print statements!
  • 26. How to use a debugger - 101 1. Add a breakpoint against the line of code you want to start debugging from 2. Execute your test runner in Debug mode
  • 27. SAGE MODE ACTIVATED ● Step Over ● Step Into ● Force Step Into ● Step Out ● Evaluate Expression ● Resume normal execution ● Inspect all variables/objects https://naruto.fandom.com/wiki/Sage_Mode
  • 29. Use Logging libraries instead of: ● System.out.println() - Java ● Console.log() - Javascript/NodeJS ● print() - Python ● Puts - Ruby Test execution logs as a source for debugging test runs: ● Useful to understand what happened in your test ● Logs can be used for generating test reports
  • 30. Why use a logging framework for your tests? ● Customized output - Easy formatting ● Logging levels (INFO, WARN, ERROR, DEBUG, TRACE) ● Can easily switch it on or off based on requirement ● Ability to persist log output on various storage mechanisms (file, database) ● System.out.println() is an I/O operation
  • 31. Examples LOG.info("Initialising WebDriver on cloud provider: {}" , configuration. getCloudProvider ().toUpperCase()); LOG.info("TEST PASSED"); catch (WebDriverException e) { LOG.error("Error creating web driver" , e); System.exit(1); } LOG.warn("API call failed. Retrying again" ); LOG.warn("Unable to write the report json file : {}" , e); Info - Logging important information Error - Something went very wrong Warn - Unstable but can be recovered LOG.debug("Dismissing alert {}" , alert) Debug - Information only meant for debugging purpose
  • 33. Selenium WebDriver logs System.setProperty("webdriver.chrome.logfile" , "D:chromedriver.log" ); System.setProperty("webdriver.chrome.verboseLogging" , "true"); System.setProperty(FirefoxDriver. SystemProperty .DRIVER_USE_MARIONETTE ,"true"); System.setProperty(FirefoxDriver. SystemProperty .BROWSER_LOGFILE ,"C:templogs.t xt");
  • 34. Appium server logs --log /path/to/appium.log Server argument (When you start appium server) LogEntries logEntries = driver.manage().logs().get("server”); Programmatically
  • 36. How to keep Chrome dev tools open while you are debugging your Selenium test locally ChromeOptions options = new ChromeOptions(); options.addArguments("--disable-extensions" ); options.addArguments("--auto-open-devtools-for-tabs" ); driver = new ChromeDriver(options); How to fetch browser console logs (including errors) programmtically LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
  • 37. Logs produced by native mobile apps
  • 38. Fetching ADB logs for Android device for debugging List<LogEntry> logEntries = driver.manage().logs().get("logcat").getAll(); Fetching iOS device logs ● idevicesyslog tool from the command line for real iOS Device ● Console app on MacOS to read console log from simulator
  • 40. MITMProxy - free and open source HTTPS proxy MITMProxy Java - A java wrapper for MITM Proxy Fiddler for Windows and MacOS
  • 41. What techniques or practices do you follow to debug your automation scripts? Please share!