0% found this document useful (0 votes)
25 views22 pages

Functional and Regression Test Automation Job Aid - GitActions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views22 pages

Functional and Regression Test Automation Job Aid - GitActions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

ICT DCQA

Functional and Regression


Test Automation Job Aid
Document identifier Functional and Regression Test Automation
Version number 1.0
Effective date Apr 26, 2019
Expiration date Apr 26, 2021
Functional and Regression Test Automation

Table OF Contents
Table OF Contents 2
1. Scope .....................................................................................................................................................................3
2. Introduction ...........................................................................................................................................................3
3. System Requirements .............................................................................................................................................3
4. Pre-Requisites.........................................................................................................................................................3
5. Eclipse Installation and Configuration 4
6. Selenium Installation and Configuration 4
7. HP ALM Requirements 4
8. Framework set up 4
9. GitHub configuration...............................................................................................................................................6
10. Guidelines for Creating Automated Test Scripts ......................................................................................................7
11. Example of How to Create an Automated Script......................................................................................................8
12. Execution of Scripts...............................................................................................................................................8
13. Configuration for Internet Explorer ........................................................................................................................8
14. Password Encrypt Utility ........................................................................................................................................9
15. DevOps Integration ............................................................................................................................................ 10
16. How to verify functional testing invoked? ............................................................................................................ 13
17. How to view results in Jenkins job? ..................................................................................................................... 15
17. How to automate using Selenium Recording Option? ........................................................................................... 16
18. Integrate recorded script into Jenkins pipeline ..................................................................................................... 17
19. How to check results in Jenkins pipeline .............................................................................................................. 19
20. Tips and Tricks to use in Selenium Recording ........................................................................................................ 20
Owner – 11780 DealerCONNECT-DCQA Technical and Testing Service-N-P................................................................... 22
Refrence Document:................................................................................................................................................. 22

DealerCONNECT Process Page 2 of 22


Functional and Regression Test Automation

1. Scope
This document details the steps required to install and configure applications required for functional and regression
test automation for DealerCONNECT applications. After completing these instructions users will be able to
create and execute automated test scripts using HP ALM, Selenium, and Eclipse .

2. Introduction
This document is intended for application teams supporting DealerCONNECT applictions that require functional
and/or regression testing.

3. System Requirements
1. Windows 64 bit system
2. 4 GB Ram
3. Atleast 20 GB free hard disk space

4. Pre-Requisites
1. Updated JDK(64 bit) is installed on the system(current version : 1.8.0_201, You can check current vers ion by
typing java –version in command prompt)
2. System environment variables have path and java_home variables with required path for JDK.
3. Eclipse(same bit version as java) is downloaded and up and running. (We will need instructions for installing
and configuring eclipse including link to software instal).
4. Selenium (We will need instructions for installing and configuring eclipse.)
5. HP ALM installed (Add any requirements that are needed like regression test cases documented in HP ALM
and placed in regression testing foder)
6. Framework set up jar files are extracted and stored at local system.

DealerCONNECT Process Page 3 of 22


Functional and Regression Test Automation

5. Eclipse Installation and Configuration


- Eclipse can be downloaded from below url:
o https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2019-
03/R/eclipse-jee-2019-03-R-win32-x86_64.zip&mirror_id=1142
- Once downloaded, extract the contents into any local folder. Eclipse does not require installation.
- Create a shortcut for eclipse.exe from the extracted folder for easy access.
- Double click on eclipse.exe(or shortcut)to run the eclipse. It will ask or workspace set up(one time activity).
- Navigate to Help->Eclipse MarketPlace. Searc for “EGIt” and install the egit plugin.
- Select/Create any folder on local drive to create workspace and then click on OK. Make sure to select “Use this
as default and do not ask again” checkbox.

6. Selenium Installation and Configuration


- We do not need selenium installation or configuration. This part has been included in adding external jar files
below.

7. HP ALM Requirements
- HP alm desktop client is installed and user has access to required project and domain.
- Test cases which are to be automated are kept in TestLab, executed atleast once with screenshots at each step.

8. Framework set up
1. Create a folder with name as “functionalTest” in local drive(Base location).
2. Keep Mastersheet.xlsx, TestData.xlsx and RunTest.xml in the created folder.
3. Copy the contents of <RequiredJarFiles> folder and keep at base location. Will need these jars below.
4. The folder structure(base location) will be same as shown below:

Eclipse Set up->>


6. Right Click in eclipse ->New->Project:

DealerCONNECT Process Page 4 of 22


Functional and Regression Test Automation

7. Select Java project from the wizard:

8. Enter project name (any) and click next->finish to create the project
9. Now right click on the created project, select Properties->Java Build Path->Libraries->Add external jars—Add the
jar files as shown below(jars extracted in step 4)
10. Create structure (with exact package name) similar to one below in eclipse:

DealerCONNECT Process Page 5 of 22


Functional and Regression Test Automation

-ApplicationCommonFunctions: Java file which contains customized, user created common functions which we
will be using for AUT.
-RunScript: Java file to run the test script. No need to change anything in file .Required for test execution
initializationduring script development phase.
-OR: Interface file short name for Object Repository, where we store xpath of objects from AUT.
-Driver: Framework required file which defines the execution path, flow and creates required instances.

9. GitHub configuration
1. User needs to get access to GitHub repository to access the framework setup files.
2. Right click on empty space in Project Explorer area of eclipse and select Import.
3. Select Git ->Projects from Git from the dialog box:

4. Click on next button


5. Click on Clone URI from select repository source dialog box and then click on Next Button.
6. Enter the following details in pull dialog box:

DealerCONNECT Process Page 6 of 22


Functional and Regression Test Automation

-URI : URI shared for the project repository.


-User: domain\username(TID)
-Password: <your tid password>

7. Click on Next button and check the branch as BranchForDevelopment from the dialog box,uncheck others.
8. Click on Next button.
9. Select the local destination directory and click on Next.
10. Click on “Import existing Eclipse Project” and click on Next
11. Click on Finish button.
12. Now the project is connected to GitHub.

10. Guidelines for Creating Automated Test Scripts


-Steps to follow for creation of automated test script:
1. Create a new testNG class file in src->TestScipts (Right click on package->TestNG->create a testNG class file)
2. Copy the class initialization code from SampleClassFile.java
3. Create a function by declaring its type(publc static final void <functionName>)
4. make an entry with the same function name in MasterSheet.xlsx and Testdata.xlsx with iteration count as 1.
5. TestScript for the function name specified is ready to start.

DealerCONNECT Process Page 7 of 22


Functional and Regression Test Automation

11. Example of How to Create an Automated Script


1. Copy the initialization code from SampleClassFile .java for the created function above.
2. Start with declaring variables for parameters to be used in the function.
3. Start replicating steps from manual test cases.

12. Execution of Scripts


1. Double check Mastersheet and testdata sheet for expected inputs to be provided.
2. Right Click on RunScript.java file (inTestScripts package) and select RunAs->Java Application.
3. RunScript.java inturn calls RunTest.xml kept in application folder in local drive.
4. RunTest.xml is responsible for executing the testcase by reading appropriate tests from Mastersheet and
applicable TestData.
5. Once the execution starts, it creates ExecutionReports folder at the base directory.
6. All results are kept in the ExecutionReports folder and uploaded to ALM(if selected) to corresponding TestID
mentioned.

13. Configuration for Internet Explorer


-While executing scripts on Internet Explorer(v11.0 +, 64Bit), we need to make some setting change in IE. Following are
the steps that need to be followed for same:

1. Open IE
2. Go to Internet Options->Security
3. Check Enable Protected Mode for all zones(internet, local Intranet, trusted Sites and Restricted)
4. Go to Advanced Tab→ Security
5. Check ☑ Enable 64-bit processes for Enhanced Protected Mode(screenshot below)

DealerCONNECT Process Page 8 of 22


Functional and Regression Test Automation

6. Click Apply and OK


7. Now we can execute the scripts on IE by changing the browser value in testdata sheet to IE.

14. Password Encrypt Utility


-This utlity is used to encrypt the user password, incase we want to provide password in test data sheet for
specific user login.
Below are the steps required to mask the password in testData sheet:
1. Run the EncryptPasswordUtility.jar file from any location(ref. as pBase)
2. Enter the password to be encrypted
3.Click on Ok
4. Encrypted password is displayed on screen. Encrypted password is also stored in EncryptedPassword.txt file
created at pBase from where user can copy the encrypted password.
5. Copy the password from text file and paste it in testData against the required row, coloumn header
“Password”.

DealerCONNECT Process Page 9 of 22


Functional and Regression Test Automation

15. GitActions Integration


Changes required in repository to integrate automation framework ito CI/CD pipeline and invoke functional/regression
automation testing as part of pipeline are(In application githubrepository):

• Raise a DriveIT request to assignment group: N_USA_XXX_GITHUBACTIONS_SUPPT to enable Selenium


Integration to your gitRepo.

• A folder “functionalTest” need to be created in repository:

• functionalTest folder comprises of 2 folders(TestScrips and CommonUtils) and 3 files (TestData.xlsx,


MasterSheet.xlsx and RunTest.xml)

DealerCONNECT Process Page 10 of 22


Functional and Regression Test Automation

DealerCONNECT Process Page 11 of 22


Functional and Regression Test Automation

• CommonUtils contains ApplicationCommonFunctins and Utility:

• TestScripts folder contains your testcscripts, Object repository and Runscript.java file. For eg: we have all
methods in DealerScoreBoard.java for dealesrscoreboard application. You can have multiple files for 1
application, just make sure to give same name in Runtest.xml(File located in functionalTest folder.)

DealerCONNECT Process Page 12 of 22


Functional and Regression Test Automation

• That’s all. Now, automation framework will be invoked whenever there is commit done on the repo code..

16. How to verify functional testing invoked?


1. Navigate to the GitActions tab in GitHub.
2. Click on the job which we just did commit for.

DealerCONNECT Process Page 13 of 22


Functional and Regression Test Automation

3. Select the SeleniumTesting->Build - > run Maven job

4. Search for “Running TestScripts ” in the logs. If found, we can verify the logs as seen in the reports.

DealerCONNECT Process Page 14 of 22


Functional and Regression Test Automation

17. How to view results in GitActions job?


1. Navigate to Summary Tab for the current job

2. Scroll down to find the Artifact generated during execution

3. Download the artifact, extract the zip file on your local system
4. Navigate to ExecutionReports folder and view the results

DealerCONNECT Process Page 15 of 22


Functional and Regression Test Automation

17. How to automate using Selenium Recording Option?


• Install Selenium Recording plug in in Egde browser:
1. Navigate to the link in edge browser: Selenium IDE · Open source record and
playback test automation for the web
2. Click on chrome download
3. Click on ----
4. Once add on is installed, restart edge browser.
5. Verify selenium plug in is installed and appears on address bar.

• Open Selenium Plug in by clicking on plug in icon


• Click on Record a new test in a new project

• Enter Project name and click on Ok


• Enter BaseURL(pref. stage dealrconnect url) and click on Start Recording
• A new instance of edge browser is launched. Navigate to desired steps of the test case. Once the test case is
completed, click on stop recording icon in Selenium IDE window. Make changes in your script(if needed – like
adding verification points etc.)
• Enter test name to save the recorded steps and click on OK
• Hover mouse over the testname(provided in last step) in Selenium IDE project window and click on Ellipsis
icon as shown below

• Click Export->Java Junit->Export


• Provide a location to save the exported test(exported file extension is java)

DealerCONNECT Process Page 16 of 22


Functional and Regression Test Automation

18. Integrate recorded script into Jenkins pipeline


• Open the exported java file from previous step in any editor(eclipse, notepad etc)
• Make necessary changes as listed below:
• Add reporting logs after each line that you need to report
• log .report ( "Username Entered" ,getDriver ());--sample
• Add below code in .java file - setup method
@BeforeClass
public static void setUp() {
log.createSummaryFile();
ChromeOptions chOption = new ChromeOptions();
chOption.addArguments("--headless","--window-size=1920,1200");
chOption.addArguments(" --disable-dev-shm-usage");;
chOption.addArguments("--whitelisted-ips=\"\"");;
chOption.addArguments(" --no-sandbox");;

driver = new ChromeDriver(chOption);


// driver = new ChromeDriver();
js = (JavascriptExecutor) driver;
vars = new HashMap<String, Object>();
System.out.println("Chrome going headless");
}

public static WebDriver getDriver() {


return driver;
}
public static void setDriver(WebDriver driver) {
partTest.driver = driver;
}
@After
public void closeDetail() {
log.closeDetailFile();
System.out.println("m in close fetails after test");
log.addInSummary(tcUpdate, "description", System.nanoTime());
}
@AfterClass
public static void footer() {
driver.quit();
log.footerSummary();
}

• Copy afterClass and BeforeClass, After,WebDriver, SetDriver methods


• Make required changes in Build.xml
<!-- functional Test Target-->

DealerCONNECT Process Page 17 of 22


Functional and Regression Test Automation

<target name="functional-test-compile" >


<echo>start functional Test.</echo>
<javac srcdir="${bld.dir}/functionalTest"
destdir="${bld.dir}/functionalTest" debug="true" includeantruntime="false" verbose = "${full-
compile}">
<classpath refid="junit.class.path" />
</javac>
</target>

<target name="integration-test" depends ="clean,resolve,init,functional-test-


compile">
<echo>In Junit Test Task</echo>
<mkdir dir="${bld.dir}/${junit.output.dir}"/>
<junit printsummary="on" fork="true">
<classpath refid="junit.class.path"/>
<!-- <pathelement location="${bld.dir}/functionalTest"/> -->
<!-- </classpath> -->
<!-- <classpath refid="junit.class.path"/> -->
<formatter type="xml"/>
<batchtest todir="${bld.dir}/${junit.output.dir}">
<fileset dir="${bld.dir}/functionalTest">
<patternset id="tests">
<exclude name="**/functionalTest/*.java" />
</patternset>
</fileset>
</batchtest>
</junit>
</target>

• Create functionalTest/TestScripts folder at base location of your git repo


• Make sure your ivy.xml(base location->build->WAS855_ant->ivy.xml) is changed as below:

<!-- https://mvnrepository.com/artifact/org.openqa.selenium.webdriver/webdriver-common -->


<dependency org="org.openqa.selenium.webdriver" name="webdriver-common" rev="0.6.1039"
conf="runtime->default"/>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->


<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="4.0.0" conf="runtime->default"/>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->


<dependency org="org.seleniumhq.selenium" name="selenium-chrome-driver" rev="4.0.0" conf="runtime-
>default"/>
<dependency org="org.seleniumhq.selenium" name="selenium-edge-driver" rev="4.0.0"/>

<dependency org="commons-io" name="commons-io" rev="2.5" conf="runtime->default"/>


<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency org="commons-codec" name="commons-codec" rev="1.12">
<artifact name="commons-codec" ext="jar"/>

DealerCONNECT Process Page 18 of 22


Functional and Regression Test Automation

</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency org="junit" name="junit" rev="4.13.1"/>
<dependency org="fca" name="RecordedSelenium" rev="1.0">
<artifact name="RecordedSelenium" ext="jar"/>
</dependency>

19. How to view results in GitActions job?


1. Navigate to Summary Tab for the current job

2. Scroll down to find the Artifact generated during execution

3. Download the artifact, extract the zip file on your local system
4. Navigate to Reports folder and view the results

DealerCONNECT Process Page 19 of 22


Functional and Regression Test Automation

20. Tips and Tricks to use in Selenium Recording

At times when we record the script, there are few fields that are not recorded
properly. To avoid scripts failing at time of re-run, we can modify the steps as per
scenarios mentioned below.

Scenario 1: To add delay in script for loading of elements


Solution:
• Go to the specific step where the delay is to be added.
• Right click and select “Insert new Command”
• In Command text box add “wait for element visible”
• In Target text box add the xpath of the dropdown
• In Value text box, add the timeout in milliseconds, for script to wait for the element.

Scenario 2: To validate text on screen and report pass/fail accordingly


Solution:
• Go to the specific step where the delay is to be added.
• Right click and select “verify text”
• In Command text box add “verify text”
• In Target text box add the xpath of the dropdown

DealerCONNECT Process Page 20 of 22


Functional and Regression Test Automation

• In Value text box – provide the exact text that needs to be verified. This verification is case sensitive, so
provide exact text to avoid unnecessary failures.

Scenario 3: Dropdown value is not selected


Solution:
• If a dropdown is not selected during re run of the script. Please add delay (scenario 1) before the dropdown
to enable script to wait for the dropdown.

DealerCONNECT Process Page 21 of 22


Functional and Regression Test Automation

Owner – 11780 DealerCONNECT-DCQA Technical and Testing Service-N-P


This document may change at any time without prior notice. The master document and ownership is available in ADMS.

Refrence Document:
In driveIT - KB0032311

DealerCONNECT Process Page 22 of 22

You might also like