Latest post from this blog

How to Manage Test Execution Across Different Browsers and Environments (QA, UAT, Staging)

In real-time automation projects, test execution is never limited to a single browser or a single environment . Applications must be validated across multiple browsers (Chrome, Firefox, Edge) and multiple environments such as QA, UAT, and Staging before going live. A well-designed Selenium + Java + Cucumber automation framework should allow testers to switch browsers and environments easily without changing test scripts . This blog explains how to manage test execution efficiently across different browsers and environments using best practices followed in real projects. Why Multi-Browser and Multi-Environment Testing Is Important Different users use different browsers QA, UAT, and Staging environments have different configurations Bugs may appear only in specific environments or browsers Same test cases must be validated everywhere before production release Common Challenges Testers Face Hardcoded browser names and URLs Maintaining separate test scripts for each environment Browse...

How to Maintain Logs in Your Automation Framework

Introduction

  • Importance of logs in debugging and maintaining automation frameworks.
  • Types of logs (Execution logs, Application logs, Error logs).
  • Overview of popular logging libraries such as Log4j, SLF4J, or java.util.logging.
Setting Up a Logging Framework
  1. Choosing a Library: Explain why you chose a specific logging library (e.g., Log4j2).
  2. Adding Dependencies: Show how to add the library to your project using Maven/Grad
XML
<!-- Example for Log4j2 -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.x.x</version>
</dependency>

      3. Configuration:
  • Provide a sample configuration file (log4j2.xml or logback.xml).
  • Discuss different log levels (INFO, DEBUG, WARN, ERROR).

 XML

<Configuration status="WARN">

    <Appenders>

        <Console name="Console" target="SYSTEM_OUT">

            <PatternLayout pattern="%d{HH:mm:ss} %-5p %c{1} - %m%n"/>

        </Console>

    </Appenders>

    <Loggers>

        <Root level="info">

            <AppenderRef ref="Console"/>

        </Root>

    </Loggers>

</Con

figuration>

Integrating Logs in Your Framework

1. Creating a Utility Class:

Create a Logger utility for centralized logging.

Java Code:

import org.apache.logging.log4j.LogManager;

import org.apache.logging.log4j.Logger;

public class LogUtil {

    private static final Logger logger = LogManager.getLogger(LogUtil.class);

 public static void info(String message) {

        logger.info(message);

    }

    public static void error(String message, Throwable t) {

        logger.error(message, t);

    }

}

2. Adding Logs in Tests:

Show how to use the logger in your test cases and Page Object methods.

Example: 

LogUtil.info("Navigating to login page");

driver.get("https://example.com/login");

3.Logging Across Framework Layers:

  • Logs for driver initialization, framework setup, and teardown.
  • Logs for actions in test cases and validation steps.
Analyzing and Managing Logs:
  • Storing Logs: Save logs in a central location for CI/CD pipelines.
  • Third-party Tools: Discuss tools like ELK Stack, Splunk, or Datadog for advanced log analysis.
Conclusion:
Summarize the benefits of maintaining logs in an automation framework.
Encourage adopting good logging practices to improve debugging and maintainability.

Comments

Popular posts from this blog

How to Manage Test Execution Across Different Browsers and Environments (QA, UAT, Staging)

Purpose of the StepData Class in Selenium + Java Cucumber Automation Framework

Ensuring Thread Safety in Parallel Test Execution with Selenium, Cucumber, and Java