Testing Automation technique

 This page shows you the technical topics on writing Testing Automation code using the Selenium and JUnit. These techniques are often used in the example project and tutorial. Please refer this page from the link on reading example's explanation.

Connect to the web browser

 In order to make WebDriver connecting to the web browser, you have to initialize it. The code to do it is at the java class, which is named "org.alinous.test.common.WebDriverFactory".

Selenium WebDriver initialize code

The actual code to get and initialize driver is implemented in getDriver() function in the class.

Using Firefox web driver

 When you use Firefox, then specify the "DRIVER_TYPE" variable's value as "DRIVER_TYPE_FIREFOX". Then the code below is executed.

Most of the setting is for download strategy. When running web browser on the JUnit code, download has to be done without download dialog.

The downloaded file is saved automatically into the "DownloadFile.DOWNLOAD_FOLDER", whose value is "download/".

Using Chrome web driver

 When you use Chrome web browser, then specify the "DRIVER_TYPE" variable's value as "DRIVER_TYPE_CHROME". Then the code below is executed.

In this case, also most of the setting is for download strategy. Sama with the Firefox'case, downloaded file is saved automatically into the "DownloadFile.DOWNLOAD_FOLDER", whose value is "download/".

Using Selenuim

 On using selenium, some common functions are prepared. The are in the "org.alinous.test.common" package.

Common selenium utilities

Set the select input's value

 This function is a member of "ActionUtils". This function make the code to set selected value into the select tag easy.

The class of WebDriver is either "TakesScreenshot" or "RemoteWebDriver". This function supports both type.

Take a screenshot

 This function is a member of "ScreenCapture". This function is called to take screenshot.

The class of the driver instance inherits the "RemoteWebDriver" or "TakesScreenshot". This function supports both cases.

Download a file

 This function is a member of "DownloadFile".

Database setup Automation

 Database setup Automation is used in the chain of test cases. When a test case is executed and the database records changed,and next test case use the changed records, this function is used.

Database setup automation class

Backup current data

 This function is to download zip file, which includes all records of the database. This function uses backup from in the "Backup and restore database" example.

This code is tested in Testing Backup database example. For more detail, take a look at the page.

Restore data from backup data

 Restore the database records from the zip file, which is backuped by Backup current data.

This code is also tested in Testing Backup database example. For more detail, take a look at the page.


Go to Top