This repository contains different examples that are used during a basic Frontend Testing workshop.
The code was written in general in a simple way, without any frameworks or external tools that could hide the basic steps to develop tests with Selenium WebDriver.
The main idea of the code is to show how tests can be written from scratch, but it is clear that different frameworks could be used to simplify the code and provide helper functions. Nevertheless, the intention is to keep it basic and simple.
The examples are provided in Java with TestNG and JavaScript with Mocha + Chai.
-
A page is opened, the page title is retrieved, and finally an assertion of a expected value is done.
-
This is an example where a guest searches for a brand and puts an item in the shopping cart.
-
After having tests working, a natural step is to try to execute all of them in less time. Some simple examples where a page is loaded are executed in parallel.
-
A final round up of the hotel booking example but now using the Page Object model/pattern, which is know as one of the best practices when doing Frontend Testing.
Only if you want to run the Java examples
-
Or Install Maven with Homebrew
brew install maven
Only if you want to run the JavaScript examples
Zalenium is used to run most of the examples. This means:
-
You need to have docker installed, version >= 1.11.1. Here are the instructions for most of the supported platforms.
-
After installing docker, just run this command to start Zalenium:
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s startThis will check for the latest images and ask for missing dependencies.
To stop Zalenium when you are done testing, you can.
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s stop -
After getting the message
Zalenium in docker started!, head to http://localhost:4444/grid/console. -
If you want to see the browsers while the test is running, you can access the container with VNC through http://localhost:4444/grid/admin/live.