CONVATE GROUP HOME PAGE AUTOMATION STRUCTURE
1) In order to implement automation for the Convatec Group page, the following tools are being
used:
a) Cucumber: Cucumber is a software tool for testing other software. It is built on Behavior Driven
Development principles where developers write tests in a language that business can
understand known as Gherkin. The cucumber test scripts often work hand in hand with the non-
technical stakeholders making it possible to test and verify that the software does what the
“business” should perform as required by the business requirements.
b) Apache Maven: Apache maven is a project management tools which can be used to download
relevant libraries (JAR files), build your project, handle reporting etc.
c) Selenium WebDriver: Selenium WebDriver is a web based automation framework which can
used to automate different web browsers (Chrome, firefox, edge) which can be combined with
programming languages such as Java to develop automation test scripts.
d) Serenity BDD: Serenity BDD also known simply as Serenity, is an open-source test automation
framework designed to support Behavior-Driven Development (BDD) practices. It offers a
powerful platform for writing high-quality automated acceptance tests in a structured and easily
understandable format.
e) Java language: Java is a preferred language for Selenium testing for several reasons:
Maturity and Stability: Java has been around for a long time and is widely used in enterprise
environments. It is a stable and mature language with robust features, making it suitable for
building reliable and maintainable test suites.
Platform Independence: Java programs can run on any platform that has a Java Virtual Machine
(JVM) installed, making them highly portable. This platform independence is beneficial for
Selenium testing as tests written in Java can be executed on various operating systems without
modification.
2) Design pattern to use: The Page Object Model (POM) is a design pattern used in test
automation to enhance the maintainability and readability of test code. It promotes creating a
separate class for each web page in an application, encapsulating all the interactions and
elements of that page within the class.
Project structure according to the Page Object Model design pattern.
a) POM.xml: It file can be referred to as the heart of your project; it’s an XML file which aids the
process of building your project and downloading relevant dependencies from the web
(https://mvnrepository.com/)
Serenity Core: This dependency includes the core functionality of the Serenity BDD
framework. It's used for organizing and executing automated tests.
Serenity Cucumber: This dependency provides integration between Serenity BDD and
Cucumber, allowing you to write BDD-style tests using Cucumber syntax. It's scoped for
testing purposes.
Serenity JUnit: This dependency integrates Serenity BDD with JUnit, enabling the
execution of Serenity tests using JUnit.
JUnit: JUnit is a popular testing framework for Java. This dependency provides the
necessary libraries for writing and executing JUnit tests. It's scoped for testing purposes.
Slf4j Simple: This dependency includes a simple implementation of the Simple Logging
Facade for Java (SLF4J). It's used for logging within the tests. It's scoped for testing
purposes.
JUnit: The JUnit dependency is for including the JUnit testing framework in the project.
JUnit is a popular framework for writing and executing unit tests in Java. It provides
annotations and assertions that simplify the process of writing and organizing tests, as
well as reporting mechanisms for identifying test failures.
Maven Surefire Plugin: This Maven plugin is used for executing unit tests during the
build process. It's configured to include test classes that end with "Runner.java".
Maven Failsafe Plugin: This Maven plugin is used for executing integration tests during
the build process. It's configured to include test classes located in the "test" directory
and is executed with the "integration-test" and "verify" goals.
Maven Compiler Plugin: This Maven plugin is used for compiling Java source code. It's
configured to use the Java version specified in the properties section.
Serenity Maven Plugin: This Maven plugin is used for generating Serenity test reports.
It's configured to execute during the "post-integration-test" phase and aggregates the
test results."
3) Class structure
Test Runner class:
Package Declaration: The class is declared within the package com.convatec.group.
Annotations:@RunWith(CucumberWithSerenity.class): This annotation is used to specify the test
runner class that should be used to execute the tests. In this case, it indicates that the tests will be
executed with Serenity BDD's integration for Cucumber.
CucumberOptions Annotation:@CucumberOptions: This annotation is used to configure the behavior
of Cucumber when executing the tests.
plugin = {"pretty" }: Specifies the format of the output generated by Cucumber. In this case, it's set to
"pretty", which generates human-readable output.
features="src/test/resources/features": Defines the location of the feature files containing the
Cucumber scenarios.
glue="com.convatec.group": Specifies the package where Cucumber step definitions are located.
snippets = CucumberOptions.SnippetType.CAMELCASE: Specifies the style of generated step
definitions. In this case, it's set to "CAMELCASE".
tags = ("@Login"): Specifies the tags that identify which scenarios should be executed. In this case, only
scenarios tagged with "@Login" will be executed.
Class Declaration public class Runner: Defines the class name as "Runner". This class serves as the entry
point for executing the Cucumber tests.
Overall, this test runner class is responsible for configuring the execution of Cucumber tests with
Serenity BDD integration, specifying the location of feature files, step definitions, output format, and
other relevant settings. It's designed to execute tests tagged with "@Login" located in the specified
package and feature file directory.
Features:
In Cucumber, "features" are used to describe the behavior or functionality of a software application in a
human-readable format. Features serve as high-level descriptions of what the application should do
from the perspective of an end user or stakeholder.
Feature file: Text file where acceptance criteria are written in Gherkin format. These acceptance criteria
could be seen as the tests we are going to prepare.
Step Definition: Files written in the programming language used, where Cucumber will
be able to associate which actions to execute associated with each step of each
acceptance criterion defined in the different features.
Util Class:
The Utils class is used to avoid code duplication and to improve code readability and maintainability.
Grouping these functions in a single class facilitates their access and reuse in different parts of the code,
which helps to keep the code clean and organized. In this case, the Utils class is named "Website.
HomePageValidations class
The HomePageValidations class is designed to handle validations related to elements on the home page
of a web application. Extends the PageObject class, indicating that it represents a page within the
application.
This class includes declarations for various web elements, such as welcome messages, search tags,
buttons, menu items, and titles. These elements are positioned using different methods, including XPath
and CSS selectors with the ByShadow mechanism.
The class also initializes a WebDriver instance to interact with the browser session.
In summary, HomePageValidations encapsulates validations for various elements on the home page,
providing a structured approach to testing and ensuring the correctness of the application's user
interface.
HomePage
At a general level, the HomePage class is responsible for representing and interacting with elements
present on the home page of a web application. Overview of what this class does:
Element Declarations: The class declares various web elements found on the home page using the
@FindBy annotation. These elements include text fields, buttons, images, and links.
Initialization: The class extends PageObject, indicating that it represents a page within the application. It
initializes the WebDriver session and provides methods to interact with the elements on the page.
Element Locators: The @FindBy annotations are used to locate elements by different methods such as
ID, XPath, and CSS selector. These annotations help in identifying and interacting with the elements
during test automation.
Element Interaction: The class provides access to elements like text fields, buttons, and links, allowing
actions such as entering text, clicking buttons, and navigating to different pages through links.
ByShadow Mechanism: Additionally, the class uses the ByShadow mechanism to locate elements
shadowed within the web components. This mechanism extends the capabilities of Selenium locators to
handle shadow DOM elements effectively.
Overall, the HomePage class serves as a representation of the home page in the application and
provides methods to interact with its elements, enabling automated testing and validation of the home
page's functionality and user interface.
HomePageValidationsSteps
This HomePageValidationsSteps class contains step definitions for validating various elements and
functionalities on the home page of a web application. Here's a general description of what this class
does:
Inheritance: The class extends HomePageValidations, indicating that it inherits validations and
interactions defined in the HomePageValidations class.
Validation Methods:
titleIsVisible(): Checks if the title is visible on the home page.
getCurrentURL(): Retrieves the current URL of the web page.
titleSearchIsVisible(), ConfirmRightSearch(), ConfirmIncorrectSearch(), ConfirmMainMenu(): Validate the
visibility of different elements on the page.
ConfirmMenuItems(List<String> expectedMenuItems): Validates the presence of menu items by
comparing them with expected menu items.
confirmConvatecPage(), ConfirmlnContactUs(): Validate the visibility of specific page elements.
URL Methods:
Methods like urlConvatec(), urlFacebook(), etc., return URLs for specific pages or social media platforms.
Handling error:
The class includes error handling mechanisms, catching assertions errors and printing stack traces.
HomePageSteps class
The HomePageSteps class serves as a collection of step definitions for interacting with elements on the
home page of a web application. Here's a general description of what this class does:
Inheritance: The class extends HomePage, indicating that it inherits the elements and functionalities
defined in the HomePage class.
Step Methods:
typePassword(String password): Enters a password to access the Convatec group page.
clickButtonGo(): Clicks on the "Go" button.
clickImgConvatec(): Clicks on the Convatec logo.
clickLblSearch(): Clicks on the search label.
typeSearch(String search): Enters a search query in the search field.
clickIconSearch(): Clicks on the search icon.
clickIconClose(): Clicks on the close button.
clickImgSecondImgConvatec(): Clicks on the second Convatec image.
clickLinkContactUs(), clickLinkConvatec(): Clicks on the Contact Us and Convatec links, respectively.
clickImgFacebook(), clickImgInstagram(), clickImgLinkedIn(), clickImgTwitter(), clickImgYoutube(): Clicks
on the Facebook, Instagram, LinkedIn, Twitter, and YouTube icons, respectively.
Step Annotations: Methods are annotated with @Step to indicate that they represent a step in the test
scenario. This annotation is typically used with Serenity BDD to generate detailed reports.
Element Interactions: Methods interact with web elements on the home page, such as clicking buttons,
entering text, and clicking on links.
HomePageSteps provides a set of reusable steps that testers or developers can use to define the
behavior of the application's home page in automated tests.