- Notifications
You must be signed in to change notification settings - Fork15
Selenium Automation Bundle is an extendable and adaptable solution that simplifies automated testing to help focus on writing tests with Selenide and TestNG using the best test design patterns.
License
sysgears/selenium-automation-bundle
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Selenium Automation Bundle is a seed project for Quality Assurance engineers to help them start designing, writing,and running automated data-driven tests with Selenide, TestNG, and Allure.
- Automatic initialization of Selenium WebDriver for Chrome, Firefox, Edge, and Safari
- Structured test reports with detailed logs of test execution generated with the help of Allure
- Integrated Selenide for handling dynamic behavior on your pages and for writing less code in page objects
- Custom annotations for accessing and mapping test data stored in a tree-like structure to streamline data-driven testing
- A simple mechanism to add your own CLI commands for running tests or handling test data
- Groovy support to write concise test classes and page objects
- Selenium
- Selenide
- TestNG
- Allure
- Groovy
- aShot
You can consult theWiki ordocs to know more about writing tests and general use of the bundle. For start, youcan follow to the documents below:
- Introduction to Writing Tests with Selenium Automation Bundle
- Detailed Guide to Writing Tests with Selenium Automation Bundle
- Data Driven Testing with Selenium Automation Bundle
Selenium Automation Bundle is built around Selenium ecosystem, which is why you should have a basic understanding ofJava, Selenium, and TestNG. The core modules of the bundle are actually written in Groovy, but you can still use Java towrite test classes and page objects.
In this section, you're going to install Selenium Automation Bundle on your computer, run the tests, and view the testresults in the browser.
Install Java 8.
Google Chrome is the default browser that we’re using with Selenium Automation Bundle. Make sure that you have thelatest version of Chrome before you run the demo tests later in this guide.
You can use any favorite IDE such as Intellij IDEA, Eclipse, or NetBeans when working with the bundle.
Clone the repository using the following command:
git clone https://github.com/sysgears/selenium-automation-bundle.git
There are several test examples to help you get started. To run them, change the current working directory:
cd selenium-automation-bundleAnd now you can run the demo tests using the command below:
./gradlew
Note that if you're using Windows, you should execute
gradlew.batinstead of./gradlew.
TheGradle Wrapper will take it from here: It will run the demo tests in Chrome and show a confirmation in theterminal that the tests were completed. During the execution of the demo tests, Chrome will automatically open and close several times.
Once the tests are completed, you can generate and serve a report to your default browser by running the followingcommands:
./gradlew downloadAllure./gradlew allureServe
Congratulations, you've just started using Selenium Automation Bundle!
As a Quality Assurance specialist, you have to take several steps before you can write automated tests for a webapplication. You usually have to:
- Determine what approaches and patterns should be used to write tests.
- Find the best tools to write and run tests, handle test data, and create test reports.
- Configure the tools and make them work together efficiently.
- Create your own abstractions and tools to fulfill basic testing tasks.
However, you can avoid all that hassle by using Selenium Automation Bundle.
Selenium Automation Bundle is basically a fully prepared infrastructure that helps you to start writing automated testsinstantly. The infrastructure is built of many classes that make it simple to create tests and page objects, interactwith databases and REST API, handle test data, and fulfill other important tasks.
You can also adapt the bundle to your specific requirements. In other words, you retain full control over the providedtools, and you can configure them and add your own libraries as you need.
The main idea is to give you the tools and approaches to carry out most of the tasks for automated testing, so you don'thave to make decisions every time you start a new project for your tests.
Having explainedwhy the bundle exists, let's discusswhat exactly it provides. Below, you'll find more informationabout thebundle structure, as well as thepatterns,libraries, andabstractions that the bundle is built around.
The directory structure of Selenium Automation Bundle is typical of Groovy-based projects generated with Gradle.Here's what the project looks like (note that several unimportant directories aren't shown in the diagram):
selenium-automation-bundle├── allure/├── .gradle├── build ├── allure-results/ ├── reports/ ├── allure-report └── tests/ └── test/├── gradle/├── src/ ├── main/ ├── groovy/com/sysgears/seleniumbundle/ ├── core/ ├── pagemodel/ └── Main.groovy └── resources/ └── config/ApplicationProperties.groovy └── test/ ├── groovy/com/sysgears/seleniumbundle/ ├── common/ ├── listeners/ └── tests/ └── resources/ ├── data/ └── testng.xml├── .gitignore├── build.gradle├── gradle.properties├── gradlew├── gradlew.bat├── LICENSE├── README.md└── settings.gradleIn the table below, we discuss only the key directories and files that you'll use when writing tests with the bundle.
| Directory or File | Purpose |
|---|---|
build/ | The build code and test reports are generated into this directory. |
build/reports/ | Thereports directory will contain the test reports generated by TestNG and Allure. |
| ---------- | ---------- |
src/main/ | Bundle Code |
src/main/.../core/ | Contains the bundle code. You don't need to change anything incore/ unless you want to add a very specific functionality for your test project. |
src/main/.../pagemodel/ | Stores page objects. You can view the demo page objects and put your page objects in this directory. |
src/main/resources/config/ApplicationProperties.groovy | Stores the global application properties. You can set the base URL for your app or change the browser for running tests in this file. |
| ---------- | ---------- |
src/test/ | Test-Related Code |
src/test/.../common/ | Contains the basic test classes such asBaseTest andFunctionalTest, which provide default configurations for your tests. You can add more methods to these test classes or create your own classes to fulfill other basic test tasks. |
src/test/.../tests/ | Contains all kinds of tests for your app. You can put your functional, end-to-end, integration, and UI tests into this directory. |
src/test/resources/data/ | Stores YAML files with test data easily accessible from test classes with custom annotations to help to use the data driven testing approach. |
src/test/resources/testng.xml | Provides default TestNG configurations. You may need to updatetestng.xml to change test suites or classes to run. You can also add new XML files with specific TestNG configurations next totestng.xml. |
| ---------- | ---------- |
build.gradle | Stores build configurations. You can find the list of dependencies, plugins, and Gradle tasks in this file. |
gradle.properties | Contains various project properties. For example, you can change the groups of tests, which should run, in this file. |
LICENSE | License information. |
README.md | The document you are reading now. |
The page object pattern was first introduced by Selenium community, and it encouragesthe reuse of code and theseparation of test code from the presentation. You can encapsulate repetitive code that works with HTML elements inpage object methods and then reuse them in your tests. Page objects also don't contain any test code to make it simpleto maintain the tests. To learn more about page objects, you can consultthis article.
Selenium Automation Bundle suggests using thedata-driven approach for creating tests. Internally, the bundle usesTestNG in conjunction with custom annotations and classes to implement the Data-Driven Testing pattern. As a result,it'll be easier for you to access test data (stored in a tree-like structure in YAML files) and map data to test classes.
The core of Selenium Automation Bundle consists of the following tools: Selenide (includes Selenium), TestNG, andAllure. With these tools, you can fulfill roughly 90% of testing tasks: write and run tests, and generate test reports.
But the bundle gives you much more. For example, UI testing is greatly simplified thanks to theautomatic comparisonof screenshots of the user interface. For that, we've integratedaShot into thebundle.
Further below, we give more details about the bundle abstractions and included tools. Naturally, if you’re familiar withany library that we integrated into the bundle, you may skip the section about it.
You may consider Selenium a medium between the browser and your web application. Selenium lets you handle browsers whentesting your app. We recommend that you refresh your memory aboutSelenium WebDriver. You can also consultthis guide to learn more about the main Selenium concepts.
Selenide is a framework built around Selenium, and it provides simple methods to find and manipulate elements on anHTML page, and, more importantly, to handle pages thatchange dynamically. With Selenide, you’ll write less codethan with Selenium.
TestNG is a framework that manages the testing process. You should be familiar with these three aspects of TestNG: howtoconfigure TestNG, how to useits annotations, and how to createtest groups. Additionally,you may want to run through aTestNG tutorial.
Allure can generate HTML-basedreports with full logs and timeline to help inspect test results presented in suites ordiagrams. Additionally, Allure can serve reports to your favorite browser and work with various Continuous Integrationsystems.
Groovy is a programming language for the Java platform, and it features [simpler syntax than Java]. Although SeleniumAutomation Bundle is written in Groovy, you can still use Java as the main language to create page objects and testclasses, or write any additional code.
UI testing can be complicated, but Selenium Automation Bundle makes it easy by including theaShot library. AlthoughSelenium allows you to take screenshots of the UI, its functionality is rather limited. aShot, on the other hand, cantake screenshots of particular elements, viewports, or entire pages, and highlight elements. The bundle provides custommethods to seamlessly incorporate screenshot comparison with aShot directly into your tests.
The bundle defines a few convenient methods, which you can use to intercept and send HTTP requests. You can easily tapinto the network traffic between the client code and the server in order to, for example, verify if correct requestswere sent by the client.
Selenium Automation Bundle comes with its own methods and commands to let you move test data such as page screenshotsand video recordings to and from cloud storage such as Dropbox.
The bundle implements methods and commands so you can work with MongoDB directly from your tests. For example, themethods can be used to verify if the app state, stored in MongoDB, was changed as expected after running the tests.MongoDB Java Driver is used for this functionality.
Video Recorder is a simple library sometimes necessary to debug tests. When some of your tests fail, it can be quitedifficult to figure out why that happened. But with Video Recorder, you can record all the dynamic changes that happenon the web page during testing. Video Recorder hasa simple API for TestNG which you may have a look at.
Copyright © 2016, 2017SysGears INC. This source code is licensed under theMIT license.
About
Selenium Automation Bundle is an extendable and adaptable solution that simplifies automated testing to help focus on writing tests with Selenide and TestNG using the best test design patterns.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors4
Uh oh!
There was an error while loading.Please reload this page.