UI Test Automation Framework Flashcards
What is POM?
A page object or a page class is basically a representation of all or some of the actions and operations which can be performed on that page of your application. POM (Page Object Model) is a design pattern that is used in selenium test automation for organizing the helper code for maintainability and reducing code duplication.
What is LoadableComponent?
LoadableComponent is a base class that aims to ensure: Pages are loaded. The initial state of the page is asserted. The elements are intractable before we use them.
WebDriver Manager
create our web driver objects in a way that it can handle parallel runs
BaseTest
super class for all test classes
locators file
Locators file could be of any format, such as .properties, .xml, .json, .yaml, .ini, .toml. For demonstration purposes, .properties is considered.
Need for DataManager
Oftentimes, we will be using some static test data that is specific to an environment. The environment could be staging, production, development, etc For maintaining the environment, we can have a separate class for managing that.
Sample page objects
when creating instances of the pages, we need to call get() to take advantage of the LoadableComponent feature.
Abstract Base Test class
Abstract base test class will be a superclass for all test files; it will have driver initialization, navigating to launch Urls and will have common functionalities used across the test classes
Best practices for automation
No hardcoding of test data in a test class.
Add logs for important steps.
Lots of meaningful assertions should be added.
No hard coding of configurations.
Page operations should be part of the page object class.
Helpers for DB, files, etc., should be part of utility class.
Add proper test comments.
Give meaningful names to the test methods and follow java naming conventions.
Group tests (such as sanity, regression, P0, etc.).
Avoid dependent tests.
Building a gradle project#
gradle clean build -x test
Tests for allure steps and attaching screenshots on failure:
gradle clean test –tests “com.educative.test.TestGoogleSearch” -Dbrowser=chrome
Overriding configuration from command line
gradle test -Dbrowser=firefox
Generated report paths
TestNG - ./test-output/index.html
Allure - ./build/reports/allure-report/index.html
Gradle - ./build/reports/tests/test/index.html
./gradlew clean build -x test
Generating the test Framework Jar. The project will be cleaned, compiled and the distribution jar will be created along with Javadoc and sources
Uploading the test Framework Jar
./gradlew uploadArchives