Overview when starting an automation project

Tram Ho

Initially learning about Automation Testing, everyone must be in trouble and “confused”. Below is the basic knowledge that will help us have an overview of what to do when starting an automation project.

We have a problem as follows:

We have test cases to test functionality for a website: that web app can be an admin page, an online sales website, or any other web applications we need to test. …

These functional test cases are prepared for us to perform manual tests. Of course, we have to test each test case one by one until the test case is complete, from setting up precondition, input testdata, to comparing actual results and expected results. to type pass – fail for each test case.

The requirement for us is to automate as many test cases as possible!

So what should we do? Check out the solution below to know the main components of the project, thereby orienting the jobs we need to do!

1. Create automation project

First we create a project – Can use the IDE as Eclipse and then add these two libraries to that project:

  • Selenium Webdriver library: Library supports interacting with the browser via web brower.
  • A library used in unit tests like TestNG: This library allows you to create independent automation scripts. In the project, there are layers (layers), each floor only communicates with the previous floor and successive it in the following order:

The top three layers are usually organized into different packages:

  • Test classes package
  • Page object classes package
  • Framework classes package

2. Create class page objects

Corresponding to each web page divided in the test case, you will create a page object for it.

The page object class implements user interactions on a specific web page, including field information and methods.

The page object’s data fields include:

  • Title
  • Ulr
  • Locator of web elements
  • And other page specific information such as: source page, sub title, … The methods are used to:
  • Provide information about the webpage and the elements:
  • Page title
  • Page url
  • Value of the labels
  • Check that element is enabled or not, can be selected or not
  • Perform interactions on the page like:
  • Click on a specific element
  • Input text into the textbox
  • Select options of checkboxes or listboxes Our test scripts will use the information in this page object. The page object will then use the functions in the project’s framework framework to execute interactions with the site.

3. Create test classes

Here, each test cript we create corresponds to a test case.

And before each test script we need to add an @Test annotation corresponding to a unit of test this test script consists of two parts:

  • Navigate to the test page
  • Execute the test, and verify To navigate to the tested page, the script will call the information on the page object of that page.

And so each time when navigating to the test page, the script will perform the test and compare the actual results achieved with the expected results to draw test conclusions.

In the test classes, the ccript tests are grouped together, convenient for searching and upgrading.

Each test script group is grouped together based on the specific test group’s script.

Test classes do not only include test scripts, they also include test fixtures (test fixtures do not know how to translate into Vietnamese, let alone)

Test fixtures are special methods of unit test framework, such as:

  • The preparation of the test environment, which is required by the test scripts before it can actually be obtained (this step is usually in a separate function, with the @Before annotation)
  • The clean / reset test environment after running test scripts: such as resetting to the original settings, no cache …, (this step is also built into a separate function and has an @After annotation)

Test classes can be bundled together using groups and suites.

4. Create a base class – shared class

Tasks such as preparing the test environment or resetting the environment after the test can be used many times in different places in the project, so to avoid repetitions, we will put the tests This fixtures into a base class.

The test class will inherit this base class so that it can call and use functions in it.

5. Create class frameworks

Class frameworks are used in projects for common functions such as:

  • Create browser driver for different types of browsers
  • Interact with the web using explicit wait
  • Get the log file
  • Read information from a text file
  • Capture the screen image (capture screen) when an exception occurs
  • Automatically email test results
  • Create a report after the test results. The page page class will call these functions from the class framework we already have, to give information to get to that page.

So we can summarize an overview of the required components of an automation project that is: first will need to create a project in the IDE (Eclipse), next we need to determine that the project needs to have the Page class. The object, the test class, the base class, and the class are related to the framework.

Each class has its own purpose, understanding those classes makes our project more scientific, easier to manage, maintain and upgrade.

Hopefully the article helps us have an overview before starting with a project automation.

The article has been translated from the source:


Share the news now

Source : Viblo