Automation Set Up and Scripting Instruction

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

I/ Install JDK (Java Development Kit) And Config environment variables

(Windows):
1. Go to: https://www.oracle.com/java/technologies/downloads/#jdk22-linux
- Select JDK 22> Select OS (Linux, Mac, Windows) > Select .exe file to download

2. Install the downloaded file:

3. Create Java_Home variable:


This PC -> Properties -> Advanced system settings-> Environment variables
 Click New for System variables:
 Variable name = JAVA_HOME
 Variable value must be the path to installed JDK
 Click OK

 Edit Path in System Variables:

 Click New:
 Add this value: %JAVA_HOME%\bin
 Click OK

4. Open cmd and type “java -version” to check if JDK has been installed successfully and java version is
shown.
II/ Install IntelliJ:
1. Access this link: https://www.jetbrains.com/idea/download/?section=windows
Scroll down and download this version (Community Edition)

III/ Install Apache Maven and Configure Maven Environment Variables:

1. Access link: https://maven.apache.org/download.cgi


Download this Zip file:

Then unzip the file in some folder.


2. Create Maven_Home variable:
This PC -> Properties -> Advanced system settings-> Environment variables

 Add New system variable with:


 Variable name = MAVEN_HOME
 Variable value = the path to unzipped Apache maven folder
 Click OK

 Select Path and Edit:


 Add this value: %MAVEN_HOME%\bin
 Click OK
3. Open cmd and type “mvn -version” to check if Maven has been installed successfully and mvn version
is updated
IV/ Install Git:
1. Access this link to download Git:
https://git-scm.com/download/

2. Follow instruction from this link for more details:


https://www.makeuseof.com/install-git-git-bash-windows/

3.After successful installation, open cmd and type “git –version” to check if git has been installed.

V/ Clone git repo and open project framework with IntelliJ:

Repo link (for DWB UI Testing):


https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/cct-lhubdt-ui-testing-workbench

 Open folder you want to clone code, open cmd

 Type: git clone + repo link


chrome

 Open IntelliJ, File>Open>Select Folder where you have cloned repo


 Switch to Develop branch

 Now you’ll see the full framework:


VI/ Scripting Instruction
1. Create Test Scenario

 Firstly, brainstorm and outline the test scenarios you’re going to write: which module, which
pages, which functionality, what are the web elements you’re going to interact with.
 Then go to tests folder and create separate feature file for each module like this:
This is a sample Test Scenario for Payment Mode:

 The tag name (eg: @PaymentMode) helps us to pick up any scenarios that we want to run which
will be configured in test runner> xml files.
 “Example” is mandatory in scenario which is the test data File we use for the scenario

2. Go to resource>locators and create separate .loc file for each module:

 Inside the loc file we will declare all the web element locators of the pages: fields, buttons,
textboxes, title,…..
 The element locator should be xpath and following existing Json format, For example:
3. Create Page Classes to write step definition for steps (main automation scripts).
We also have separate classed for each module:

 How to create new class:


-Right click on the folder> New> Java Class

-Then enter class name:


4. Create scripts inside Page Classes:

 Firstly, import necessary classes:

 Second, write scripts for each feature step like this:


 Note that: each code block will represent (links) a separate step that was previously created in
feature file.
 Description must be the same with step, otherwise the step won’t be linked to the scripts.

 Note that we will use a lot of pre-configured methods in some classes (Browser Global,
lhubCommonBase, lhubCommonSteps) which are common actions interacting with web elements
like scroll to elements, verify the presence of elements, click on buttons, input texts to fields…..
 For example, if you want to verify if an element is present, the script will be like:

 Here are some commonly used methods:


 BrowserGlobal.iClickOn: Click on element
 BrowserGlobal.iWaitUntilElementNotPresent: Wait until element not present
 BrowserGlobal.iWaitUntilElementPresent: Wait until element present
 BrowserGlobal.iVerifyElementPresent: Verify if element present
 BrowserGlobal.iAssertElementEnabled: Verify if element is enabled or not
 BrowserGlobal.iInputInTo: Input texts into the field
 BrowserGlobal.iVerifyLocatorWithPartialTextIgnoringCase: verify if element contains some
certain texts

5. For the step when user must input multiple data to multiple fields, it’d better to prepare test data
file (excel) and use this below structure (e.g)

Go to resource>data to add test data file (xlsx)


 Name of fields in feature step must match field name in test data file in order for the mapping to
work properly:

6. After scripts are created in page class, go to test runner to create xml file to configure test run.

 Inside runner.xml file:


 The test environment and test browser will be defined here:

 This line means all the scenarios having the tag name= @PaymentMode will be executed in test
run:

Which means this scenario will run:

6. After test runner.xml created, open Terminal (Alt +F12) and run this command:
mvn clean install -DtestSuiteFile="test-runner/{name of the text runner file}"\
(e.g: mvn clean install -DtestSuiteFile="test-runner/PaymentMode_runner.xml"\)
7. After text execution is completed, to read report, right click dashboard.htm> Open
In>Browser>Chrome to view test result report:

Test passes:

Report Details:

You might also like