SlideShare a Scribd company logo
Tutorial
Debugging Selenium Scripts with Logs
• Here, we have included advanced ideas that would
benefit from optimizing the Testing Automation
framework and produces more clarity to the users.
• We would consider the logging feature and it's possible,
debugging capabilities etc.
• Benefits of Logging in Selenium Scripts:
Introduction
Offers an
understanding of
test suites
execution
Log messages can
be saved in
external files for
post-execution
scrutiny
Logs are an
outstanding assistant
in debugging the
software execution
problems and
breakdowns
Logs can also be
examined to
determine the
application's position
Log4j
Log4j – A Java-based Logging Utility
• Let's Discuss the technical aspects of logging.
• Log4j was a decision of collaborative endeavors of
people at Secure Electronic Marketplace for Europe to
produce a utility.
• Log4j is an open source tool and licensed under IBM
Public License.
• It would support us generating logs and hence the log4j
came into consideration in the year 1996.
• There are three main elements that form the
implementation of log4j:
1. Loggers
Logger Class: It is a java based utility/API that has grown
all the generic methods already done so that users can
enable to use Log4j.
Log Levels: Log levels are commonly identified as to
printing methods. These are utilized for printing log
messages.
5 Types of Log Levels:
1. error()
2. warn()
3. info()
4. debug()
5. log()
We have to only call any of the above printing methods
over the logger instance.
2. Appenders
Now where we can get to view the logs?
Answer is "Appenders“
Appenders are generally applied to define the data
source/medium where the logs should be created.
3. Layouts
Layouts are a utility that enables the user to choose the
wanted set up in which the logs would be performed.
Appenders and Layout have a tight coupling between
them.
Make a note that the user is leveraged to determine
various appenders, each map with a different layout.
Installation
Here we learnt about the basics of log4j and its parts,
now let's implement these phenomena for Debugging
Selenium Scripts with Logs
Logging using log4j can be performed and configured in
particularly two ways:
• Using Script via Programmatically
• Configuration files via Manually
Above both suggested configuration ways have merit as
well as demerits.
Here we will configure log4j manually using Configuration
files as its comfort and simplicity.
Continue
To create a log4j.xml file. You can use below code in
configuration file:
The output of the above code is:
01-07-2014 12:56:32 INFO [GmailLogin]: Sample log message
Here,
• First is Execution Date
• Second is Time in which the test step was
performed
• Third is one of the log level
• Fourth is name of the test class
• Fifth is Log message
Put the log4j.XML file into the project’s root folder/base
directory now.
Continue
Continue
Now parse the log4j.xml file
Continue
Now we have to generate a test class “GmailLogin.java”
under the project.
Then import the logger class to be able to perform the
log statements.
Syntax:
import org.apache.log4j.Logger;
Now instantiate the object of the Logger class
Syntax: //object initialization for log
static Logger log = Logger.getLogger(Demo.class.getName());
This logger will be used over the complete test class to
create the log statements.
Conclusion
Here we used log4j use to perform logging.
We explained the essential parts that form log4j from a
usability view.
With the Appenders and layouts, you can leverage to
determine the wanted logging form/model and the data
reference/position.
References:
Debugging Selenium Scripts with Logs (Log4j Tutorial)
Debugging Selenium Scripts with Logs
Contact Us
Web: www.nexsoftsys.com
Email: info@nexsoftsys.com
Call: +1-646-971-0799

More Related Content

Similar to Log4j with selenium tutorial: How to Setup log4j logging in selenium automation framework

Log4e
Log4eLog4e
Selenium Training in Chennai
Selenium Training in ChennaiSelenium Training in Chennai
Selenium Training in Chennai
Thecreating Experts
 
Logback
LogbackLogback
Log4j slideshare
Log4j slideshareLog4j slideshare
Log4j slideshare
Ahmed M. Gomaa
 
Log4j
Log4jLog4j
AtoM feature development
AtoM feature developmentAtoM feature development
AtoM feature development
Artefactual Systems - AtoM
 
Java Logging
Java LoggingJava Logging
Java Logging
Zeeshan Bilal
 
Logging Services for .net - log4net
Logging Services for .net - log4netLogging Services for .net - log4net
Logging Services for .net - log4net
Guo Albert
 
Logging
LoggingLogging
Log4j is a reliable, fast and flexible
Log4j is a reliable, fast and flexibleLog4j is a reliable, fast and flexible
Log4j is a reliable, fast and flexible
Ramakrishna kapa
 
Different Techniques Of Debugging Selenium Based Test Scripts.pdf
Different Techniques Of Debugging Selenium Based Test Scripts.pdfDifferent Techniques Of Debugging Selenium Based Test Scripts.pdf
Different Techniques Of Debugging Selenium Based Test Scripts.pdf
pCloudy
 
Functional Application Logging : Code Examples Using Spring Boot and Logback
Functional Application Logging : Code Examples Using Spring Boot and LogbackFunctional Application Logging : Code Examples Using Spring Boot and Logback
Functional Application Logging : Code Examples Using Spring Boot and Logback
Mohammad Sabir Khan
 
LogRhythm Training Syllabus Data Sheet
LogRhythm Training Syllabus Data SheetLogRhythm Training Syllabus Data Sheet
LogRhythm Training Syllabus Data Sheet
jordagro
 
Logging configuration in mule
Logging configuration in muleLogging configuration in mule
Logging configuration in mule
Son Nguyen
 
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptxFAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
gattamanenitejeswar
 
Automation using ibm rft
Automation using ibm rftAutomation using ibm rft
Automation using ibm rft
Prashant Chaudhary
 
Oscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest SlidesOscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest Slides
ctalbert
 
Oscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest SlidesOscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest Slides
ctalbert
 
Oracle forms les02
Oracle forms  les02Oracle forms  les02
Oracle forms les02
Abed Othman
 
Logging best practice in mule using logger component
Logging best practice in mule using logger componentLogging best practice in mule using logger component
Logging best practice in mule using logger component
Govind Mulinti
 

Similar to Log4j with selenium tutorial: How to Setup log4j logging in selenium automation framework (20)

Log4e
Log4eLog4e
Log4e
 
Selenium Training in Chennai
Selenium Training in ChennaiSelenium Training in Chennai
Selenium Training in Chennai
 
Logback
LogbackLogback
Logback
 
Log4j slideshare
Log4j slideshareLog4j slideshare
Log4j slideshare
 
Log4j
Log4jLog4j
Log4j
 
AtoM feature development
AtoM feature developmentAtoM feature development
AtoM feature development
 
Java Logging
Java LoggingJava Logging
Java Logging
 
Logging Services for .net - log4net
Logging Services for .net - log4netLogging Services for .net - log4net
Logging Services for .net - log4net
 
Logging
LoggingLogging
Logging
 
Log4j is a reliable, fast and flexible
Log4j is a reliable, fast and flexibleLog4j is a reliable, fast and flexible
Log4j is a reliable, fast and flexible
 
Different Techniques Of Debugging Selenium Based Test Scripts.pdf
Different Techniques Of Debugging Selenium Based Test Scripts.pdfDifferent Techniques Of Debugging Selenium Based Test Scripts.pdf
Different Techniques Of Debugging Selenium Based Test Scripts.pdf
 
Functional Application Logging : Code Examples Using Spring Boot and Logback
Functional Application Logging : Code Examples Using Spring Boot and LogbackFunctional Application Logging : Code Examples Using Spring Boot and Logback
Functional Application Logging : Code Examples Using Spring Boot and Logback
 
LogRhythm Training Syllabus Data Sheet
LogRhythm Training Syllabus Data SheetLogRhythm Training Syllabus Data Sheet
LogRhythm Training Syllabus Data Sheet
 
Logging configuration in mule
Logging configuration in muleLogging configuration in mule
Logging configuration in mule
 
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptxFAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
 
Automation using ibm rft
Automation using ibm rftAutomation using ibm rft
Automation using ibm rft
 
Oscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest SlidesOscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest Slides
 
Oscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest SlidesOscon2008 Qa Leak Testing Latest Slides
Oscon2008 Qa Leak Testing Latest Slides
 
Oracle forms les02
Oracle forms  les02Oracle forms  les02
Oracle forms les02
 
Logging best practice in mule using logger component
Logging best practice in mule using logger componentLogging best practice in mule using logger component
Logging best practice in mule using logger component
 

More from Chirag Thumar

Industrial perspective on static analysis
Industrial perspective on static analysisIndustrial perspective on static analysis
Industrial perspective on static analysis
Chirag Thumar
 
[IoT Testing]- 4 Challenges We may face in IoT Testing
[IoT Testing]- 4 Challenges We may face in IoT Testing[IoT Testing]- 4 Challenges We may face in IoT Testing
[IoT Testing]- 4 Challenges We may face in IoT Testing
Chirag Thumar
 
Tutorial on the integration of Selenium with cucumber for experts and fresher’s
Tutorial on the integration of Selenium with cucumber for experts and fresher’sTutorial on the integration of Selenium with cucumber for experts and fresher’s
Tutorial on the integration of Selenium with cucumber for experts and fresher’s
Chirag Thumar
 
6 Points to Consider Before Testing any Mobile Application
6 Points to Consider Before Testing any Mobile Application 6 Points to Consider Before Testing any Mobile Application
6 Points to Consider Before Testing any Mobile Application
Chirag Thumar
 
5 cybersecurity facts about which you must have knowledge
5 cybersecurity facts about which you must have knowledge5 cybersecurity facts about which you must have knowledge
5 cybersecurity facts about which you must have knowledge
Chirag Thumar
 
Why all software engineers are not fit for software development jobs in india?
Why all software engineers are not fit for software development jobs in india?Why all software engineers are not fit for software development jobs in india?
Why all software engineers are not fit for software development jobs in india?
Chirag Thumar
 
8 digital trends in 2018
8 digital trends in 20188 digital trends in 2018
8 digital trends in 2018
Chirag Thumar
 
Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...
Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...
Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...
Chirag Thumar
 

More from Chirag Thumar (8)

Industrial perspective on static analysis
Industrial perspective on static analysisIndustrial perspective on static analysis
Industrial perspective on static analysis
 
[IoT Testing]- 4 Challenges We may face in IoT Testing
[IoT Testing]- 4 Challenges We may face in IoT Testing[IoT Testing]- 4 Challenges We may face in IoT Testing
[IoT Testing]- 4 Challenges We may face in IoT Testing
 
Tutorial on the integration of Selenium with cucumber for experts and fresher’s
Tutorial on the integration of Selenium with cucumber for experts and fresher’sTutorial on the integration of Selenium with cucumber for experts and fresher’s
Tutorial on the integration of Selenium with cucumber for experts and fresher’s
 
6 Points to Consider Before Testing any Mobile Application
6 Points to Consider Before Testing any Mobile Application 6 Points to Consider Before Testing any Mobile Application
6 Points to Consider Before Testing any Mobile Application
 
5 cybersecurity facts about which you must have knowledge
5 cybersecurity facts about which you must have knowledge5 cybersecurity facts about which you must have knowledge
5 cybersecurity facts about which you must have knowledge
 
Why all software engineers are not fit for software development jobs in india?
Why all software engineers are not fit for software development jobs in india?Why all software engineers are not fit for software development jobs in india?
Why all software engineers are not fit for software development jobs in india?
 
8 digital trends in 2018
8 digital trends in 20188 digital trends in 2018
8 digital trends in 2018
 
Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...
Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...
Tips to Build Your Blog Using ASP.NET and Types of blogs by ASP.NET Developme...
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 

Log4j with selenium tutorial: How to Setup log4j logging in selenium automation framework

  • 2. • Here, we have included advanced ideas that would benefit from optimizing the Testing Automation framework and produces more clarity to the users. • We would consider the logging feature and it's possible, debugging capabilities etc. • Benefits of Logging in Selenium Scripts: Introduction Offers an understanding of test suites execution Log messages can be saved in external files for post-execution scrutiny Logs are an outstanding assistant in debugging the software execution problems and breakdowns Logs can also be examined to determine the application's position
  • 3. Log4j Log4j – A Java-based Logging Utility • Let's Discuss the technical aspects of logging. • Log4j was a decision of collaborative endeavors of people at Secure Electronic Marketplace for Europe to produce a utility. • Log4j is an open source tool and licensed under IBM Public License. • It would support us generating logs and hence the log4j came into consideration in the year 1996. • There are three main elements that form the implementation of log4j:
  • 4. 1. Loggers Logger Class: It is a java based utility/API that has grown all the generic methods already done so that users can enable to use Log4j. Log Levels: Log levels are commonly identified as to printing methods. These are utilized for printing log messages. 5 Types of Log Levels: 1. error() 2. warn() 3. info() 4. debug() 5. log() We have to only call any of the above printing methods over the logger instance.
  • 5. 2. Appenders Now where we can get to view the logs? Answer is "Appenders“ Appenders are generally applied to define the data source/medium where the logs should be created.
  • 6. 3. Layouts Layouts are a utility that enables the user to choose the wanted set up in which the logs would be performed. Appenders and Layout have a tight coupling between them. Make a note that the user is leveraged to determine various appenders, each map with a different layout.
  • 7. Installation Here we learnt about the basics of log4j and its parts, now let's implement these phenomena for Debugging Selenium Scripts with Logs Logging using log4j can be performed and configured in particularly two ways: • Using Script via Programmatically • Configuration files via Manually Above both suggested configuration ways have merit as well as demerits. Here we will configure log4j manually using Configuration files as its comfort and simplicity.
  • 8. Continue To create a log4j.xml file. You can use below code in configuration file:
  • 9. The output of the above code is: 01-07-2014 12:56:32 INFO [GmailLogin]: Sample log message Here, • First is Execution Date • Second is Time in which the test step was performed • Third is one of the log level • Fourth is name of the test class • Fifth is Log message Put the log4j.XML file into the project’s root folder/base directory now. Continue
  • 10. Continue Now parse the log4j.xml file
  • 11. Continue Now we have to generate a test class “GmailLogin.java” under the project. Then import the logger class to be able to perform the log statements. Syntax: import org.apache.log4j.Logger; Now instantiate the object of the Logger class Syntax: //object initialization for log static Logger log = Logger.getLogger(Demo.class.getName()); This logger will be used over the complete test class to create the log statements.
  • 12. Conclusion Here we used log4j use to perform logging. We explained the essential parts that form log4j from a usability view. With the Appenders and layouts, you can leverage to determine the wanted logging form/model and the data reference/position. References: Debugging Selenium Scripts with Logs (Log4j Tutorial) Debugging Selenium Scripts with Logs
  • 13. Contact Us Web: www.nexsoftsys.com Email: info@nexsoftsys.com Call: +1-646-971-0799