CICD Test Automation WorkFlow

Automation Development Team: Scripting of new test cases and continuous maintenance of existing ones.

GitLab Server: All the source code of the automation project is stored on git server.

CI Server: Builds and executes Test Cases.  Email Notifications is triggered to recipient list in Jenkins job.

Jira: It’s the integrated test tool to manage and report test execution. All the automated test cases results are updated live in  Jira as soon as the test cases execution is completed. You can create a Jira Dahboard for easy reference of all the results in jira.

Appro Server: Test case execution artifacts are stored on Appro cloud server. It is accessible anytime by clicking on the hyperlink in the email report or on the execution record in jira. (P.S: This is a sample repository, you can use any other as per your requirement)

Email Notification: Email notification contains an overview of the all the test cases status(Pass/Fail) and execution time taken.

HOW TO DO GUI TESTING EFFECTIVELY

Through my past experience I have found that GUI testing is a beautiful art rather than simply comparing the designs with the developed HTML.Because of the manual nature of task involved in GUI testing it may sound little boring and monotonous which again can lead to defects sliding through one’s eyes.To combat this human error and handle this task effectively I have listed some methods you can use to make your GUI testing more productive.

1) Check for spelling mistakes and grammatical errors using any simple text editor : To check for any spelling mistakes and grammatical errors one needs to just copy and paste the static text content to any simple text editor like MS word,etc.

2) Use exact colour code to check for text and button colours instead of simply scanning through eyes : Get the exact text/button colour codes from style guide or ask designers, then do inspect element for the element under test and check if the colour codes are matching.This process eliminates human eye perception errors that often go unnoticed.

3) Use exact font size and font family for testing text : Get the exact font size and font family from style guide or ask designers, then do inspect element for the text under test and check if the font size and font family are matching.There are many similar looking fonts and doing this type of testing completely removes any chances of font issues sliding in.

4) Check for pixel perfect implementation of the designs to HTML : One can use various online tools and browsers extensions that are easily available(like pixel perfect add-on for chrome) to do pixel perfect testing thereby saving lot of testing time and manual hassle.

5) Always do cross browser testing for GUI : It is often seen that same design looking great on one browser completely breaks on another.To avoid getting issues at later phase from users like buttons/text cutting off or misplaced and various other issues it is always a good practice to do cross browser testing for GUI.

6) Use style guides instead of mapping specific PSDs to designs per page for checking font colour,font size and font family.It truly saves a lot of time.

7) Many a times it is observed that a particular font looks perfect in on browser but the same font is rendered completely different in another.This issue can not be detected by checking the font family but only a human eye can detect this defect.

8) Check for proper alignment of the text.

9) Test if the clarity of the images are proper and of acceptable level.

10) Test on different screen resolution that is supported : Even when we say our site is not responsive and we support desktop only, then also there is a range of resolution which needs to be supported and we need to test at-least if the minimum and maximum screen resolutions are compatible with the site under test.

Tsung Installation Ubuntu

Tsung is a high-performance distributed load testing tool. It is protocol-independent and can currently be used to stress HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and Jabber/XMPP servers.

Step 1. Install Erlang dependencies and other packages required for building reports:

i) apt-get install erlang gnuplot libtemplate-perl

Step 2. Install tsung:

i) wget http://tsung.erlang-projects.org/dist/tsung-1.6.0.tar.gz

ii) tar zxvf tsung-1.6.0.tar.gz

iii) cd tsung-1.6.0

iv) ./configure

v) make

vi) make install

Step 3. Check the version of tsung installed on your system.

i) tsung -v

Step 4. Below is a sample configuration file:

<?xml version=”1.0″?>
<!DOCTYPE tsung SYSTEM “/usr/share/tsung/tsung-1.0.dtd”>
<tsung loglevel=”debug” version=”1.0″>
<clients>
<client host=”localhost” maxusers=”1″ use_controller_vm=”true”></client>
</clients>

<servers>
<server host=”localhost” port=”1883″ type=”tcp” />
</servers>

<load>
<user session=”mqtt_publisher” start_time=”10″ unit=”second”></user>
<arrivalphase phase=”1″ duration=”20″ unit=”second”>
<users maxnumber=”1″ arrivalrate=”1″ unit=”second”/>
</arrivalphase>
</load>

<sessions>
<session name=”mqtt_publisher” probability=”100″ type=”ts_mqtt”>
<request>
<mqtt type=”connect” clean_start=”true” keepalive=”10″ will_topic=”test_topic” will_qos=”0″ will_msg=”will_msg” will_retain=”false”><!–mqtt>
</request>

<for from=”1″ to=”10″ incr=”1″ var=”loops”>
<request subst=”true”>
<mqtt type=”publish” topic=”test_topic” qos=”1″ retained=”true”>test_message USER ID : %%_tsung_userid%% </mqtt>
</request>
</for>

<request>
<mqtt type=”disconnect”></mqtt>
</request>
</session>
</sessions>

</tsung>
Step 5. Run the above configuration file:
cd to the folder where this configuration file is saved
i) tsung -f example.xml start

Step 6. Go to log directory:

i) cd ~/.tsung/log/20150923-1239

Step 7.Generate graphical Report:

i) /usr/lib/tsung/bin/tsung_stats.pl

Step 8. Open report in Firefox browser:

i) firefox report.html

Step 9. You are done 🙂

Testing Made Easier With These 10 Chrome Extensions

1.Check My Links:

‘Check My Links’ quickly finds all the links on a web page, and checks each one for you. It highlights which ones are valid and which ones are broken, simple as that.

2.Grammarly Spell Checker and Grammar Checker:

The free Spell Checker & Grammar Checker by Grammarly helps you write clearly and confidently on Gmail, Facebook, Twitter, Linkedin, Tumblr, and nearly anywhere else on the Web. With Grammarly, you can always be sure that your words are mistake-free and say what you mean.

3.FireShot:

What you can do with FireShot Webpage Screenshot: ✓ Capture web pages entirely ✓ Capture only visible part of the page ✓ Capture selection ✓ Save screenshot to disk as PDF, PNG, and JPEG ✓ Copy screenshot to clipboard ✓ Print screenshot Additionally, users on Windows can do the following: ✓ Edit screenshot: crop, resize, add text and arrow annotations, blur areas and apply other effects ✓ Print ✓ Save screenshot to PDF files ✓ Save screenshot to disk as PDF, PNG, GIF, JPEG, BMP ✓ Send to OneNote (Pro version) ✓ Upload to Twitter, Google Picasa, Facebook, ImageShack, Flickr, EasyCaptures ✓ Copy screenshot to clipboard ✓ Print screenshot ✓ E-Mail ✓ Export to external editor.

 4.Perfect Pixel:

This extension allows developers and testers to put a semi-transparent image overlay over the top of the developed HTML and perform per pixel comparison between them.

5.WhatFont:

What is the easiest way to find out the fonts used in a webpage? Firebug and Webkit Inspector are easy enough to use for developers. However, for others, this should not be necessary. With this extension, you could inspect web fonts by just hovering on them. It is that simple and elegant. It also detects the services used for serving the web fonts. Supports Typekit and Google Font API.

6.YSlow:

YSlow analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. YSlow grades web page based on one of three predefined ruleset or a user-defined ruleset. It offers suggestions for improving the page’s performance, summarizes the page’s components, displays statistics about the page.

7.Responsive Web Design Tester:

Test your mobile site on mobile devices. This extension reflects both the size and the browser of the mobile device. Quickly preview your responsive website designs at the dimensions they will be seen on popular mobile devices. RWD tester also uses the correct User-Agent, but it does not render web pages in the same way as the mobile device. It is primarily for developers who want to test how a page responds to different devices. Supports both external and internal network (localhost). Includes presets for iOS (iPhone, iPad), Android (Samsung Galaxy, Nexus 7). Add your own devices if you don´t find anything that suits your needs.

8.Screen Resolution Tester:

Screen resolution tester resizes the browser window for developers to view their websites in different screen resolutions. It uses a pre-defined list of screen resolutions from netmarketshare.com, which compiles the data from tens of millions of users each month. You can also enter a custom screen resolution and the browser will resize to that resolution.

9.Web developer:

The Web Developer extension adds a toolbar button to the browser with various web developer tools. This is the official port of the Web Developer extension for Firefox.

10.Firebug Lite:

Firebug Lite is not a substitute for Firebug, or Chrome Developer Tools. It is a tool to be used in conjunction with these tools. Firebug Lite provides the rich visual representation we are used to see in Firebug when it comes to HTML elements, DOM elements, and Box Model shading. It provides also some cool features like inspecting HTML elemements with your mouse, and live editing CSS properties.

Apache Ant Integration with TestNG

Apache ANT-Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other.

To be able to create the better TestNG Report we need to use Apache Ant and Saxon Parsor..Download apache ant and extract the folder where you want to extract. And Set …\bin path of ant in environment variable.

2.build.xml

Apache ant works based on a file called as build.xml

This file typically contains information related to

– Directorys to be used i.e.

src – where all your java test classes would be stored

build – where all the compiled .class files would be stored

directory where testng-xslt.xml is stored(This directory create or delete when test is run)

testng.xml – the file that TestNG referes to for knowing the Test Classes to consider for executing tests

etc.

– Various tasks i.e. <target> to be run by ant

compile the java code

create log

run TestNG tests

send mail with test run results attachment

Mail functionality

We need to use java mail related APIs that are provided in the jar files mail.jar & activation.jar

Copy these files to Apache Ant /lib folder.

If mailing functionality is not working then check two things.

1.Tools.jar is present in JDK’s lib folder.

  1. And check port “587” or “465” in target function “<target name=”sendmail” depends=”report”>”

either of two port may be working.

For sending mail please give appropriate credentials in target function stat with “<target name=”sendmail” depends=”report”>” in build.xml.

Run eclipse class through ant use two commands

  1. ant report – Which gives you only reports and creates testng-xslt folder where you can see result by clicking on index.html
  1. ant sendmail – which sends mail with an attachment of Reports.

 

 

Installation of selenium webdriver with TestNG

Selenium Webdriver: WebDriver is a tool for automating testing web applications, and in particular to verify that they work as expected.

TestNG: TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

TestNG is designed to cover all categories of tests:  unit, functional, end-to-end, integration, etc.

Software Required: Eclipse Juno, Java 32/64 bit depends on your PC configuration, Selenium Java APIs, Selenium Browsers Drivers, Selenium Server Standalone API, JXL APIs, Java Mail APIs, Apache Ant, Saxon Parser, Test NG APIs.

Installation of Eclipse with Selenium Web driver Test NG

1.First Install Java with respect your OS configuration. For 64 Bit OS install 64 bit latest JDK , and for 32 bit OS install latest 32 bit JDK.

2.After Installing JDK set “JAVA_HOME” environment variable and set value in “path” variable also.

JAVA_HOME= C:\Program Files\Java\jdk1.7.0

Path=C:\Program Files\Java\jdk1.7.0\bin

3.Now install latest eclipse Juno with respect OS configuration and Java Configuration.

4.Now create shortcut of eclipse on desktop and open the eclipse , Now while opening eclipse it ask for workspace. So create your workspace in Work folder as “SeleniumWorkspace”.

5.Now after giving workspace your eclipse will open. Now you are set with eclipse.

6.Now create one java project, File- > New- > Java Project. Give some appropriate name for project , for sample project I am giving “TestProject”. Now your java project is created.

7.Now create one package, Right click on project then New- > Package. Here also give some appropriate package name, for sample , I am giving “Testpackage”.

8.Now right click on package and New- > Class. Give appropriate name for class as well. I am giving “Testclass”.

9.Now you are set with Project -> Package – > Class

10.Now right click on Project folder and Build Path -> Configure Build Path – > Libraries .

11.Now click on Add External Jars to add selenium webdriver jars or libraries. And select each and every jars from respective jar folder.

12.Now selenium jars are configured with project. Now go to project to write code.

13.Now selenium jars are configured with project. Now go to project to write code.

To check selenium is working fine just place below code in Main function and run it.

WebDriver seldriver;

seldriver = new FirefoxDriver();

seldriver.get(“http://google.com“);

After placing this code you will see some errors as libraries are not imported. Just mouse over where errors are showing and include those libraries which eclipse is suggesting.Those libraries are below:

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;)

Now just run the project and check whether google is opening. Now write your project automation code on Selenium Web driver with Java TesNG.

 

Installation of TestNG in Selenium Webdriver project:

1.After successful execution of sample script mentioned in above steps now we can add Test NG plugin.

2.Go to Help-> Install New Software and paste http://beust.com/eclipse this url in “Work with” textbox.

3.Check the checkbox of TestNG and click on link “Next” now TestNG plugin installation starts.

4.After complete installation, your TestNG jar by default will store in lib folder where all other selenium jars are stored.

5.To check whether Test NG jar is added in external jar , Right click on project then Build Path- > Configure Build Path – > Check whether testng jar is added in Libraries.

6.Now you are configured test ng with eclipse now whenever you create any new project just add all jars through Add External jars button from where selenium jars presents and with those jars only testng jar also added.

 

Creating Standard Folder Structure for Selenium Scripts:

<Project Root Directory>

1.After Creating Java project from eclipse , one project folder is created in your workspace directory.

2.In that project folder now structure should be

lib – create one lib folder in the project folder and place all your required jars here so that while configuring selenium jars you can directly take all jars from this folder.

build.xml- Keep this file at the project root folder.

testng.xml- Keep this file at the project root folder. This also provided to you.

– This is the file where you can specify which package.class are to be run by TestNG. This file can changes with respect to your project. Open this file and give your test case name(Test case name can be anything but should be appropriate with respect to your scenario) and class name should be as given in eclipse . i.e. PackageName.ClassName

xslt – Create one xslt folder in src folder .

testng-results.xsl – This is a standard file from TestNG which specifies the format of the Better TestNG report.Keep this file at <project root directory>/src/xslt

 

Saxon Parser

This is a set of jar files that provides a facility to create HTML Report based on

  1. a) .xml file that contains data (in our case this would be testng-results.xml)
  2. b) .xls file that specifies the format of the HTML to be created (in our case this would be testng-results.xsl)

The HTML report generated in our case is in the directory

<project root directory>/testng-xslt

This folder actually would contain a set of HTML files, the summary report file to open is index.html and this folder is created automatically after running our project.

Saxson parser is basically the jar files (SaxonLiaison.jar, saxon-8.7.jar) add these jars in ourlib folder.

AutoIT Installation and Integration with Selenium Webdriver

AutoIt: AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!

Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scriptwriters would expect.

For Installation of AutoIt and its Integration with Selenium Webdriver follow the steps given below:

Step1. Download and install the latest AutoIT3 Production version from HERE

Step2. To create AutoIt file:

Right click on the folder where you want to create the file>New>AutoIt V3 Script.

Now AutoIt file is created.

Step3. To open AutoIt file to Edit.

Right on the AutoIt file>Edit Script

The AutoIt file opens in the Autoit editor.

Step4. Write code in the AutoIt file.

e.g To Upload an image.

WinWaitActive("File Upload")
Send("C:\\Users\\Test\\testimage.jpg")
Send("{ENTER}")

Step5. To Compile the autoIt code.

Right on the AutoIt file>Compile Script

Now your script is compiled and an .exe file of the AutoIt file is created.

Step6. Selenium code to handle upload button using AutoIt

@Test
 public void test() throws IOException {
 WebDriver driver=new FirefoxDriver();
 driver.manage().window().maximize();
 driver.get("http://www.convert-jpg-to-pdf.net/");
 driver.findElement(By.id("select_file_button")).click(); 

 // This will invoke AutoIT script
 Runtime.getRuntime().exec("C:\\Users\\Test\\upload.exe");
 }

Step 7. Now Run the selenium code and go!

Note: Do not forget to recompile your code whenever you make any changes to your AutoIt code.

Sikuli Installation and Integration with Webdriver

Sikuli: Sikuli automates anything you see on the screen. It uses image recognition to identify and control GUI components. It is useful when there is no easy access to a GUI’s internal or source code.

For Installation of Sikuli and its Integration with Selenium Webdriver follow the steps given below:

Sikuli Installation

Step : 1  Download sikuli-setup.jar

Step 2: Go to this path and downlaod https://launchpad.net/sikuli/+download

Step 3 : sikuli-setup.jar

Step 4: Now open the command Window go to folder where this jar file is present

C:/<path to the jar file> and then type runSetup.cmd  (note no spaces between runSetUp.cmd)in commandprompt

Step 5 : the a pop-up will open saying “Please read carefully before proceeding” click “OK”

Step 6: Sikuli Setup window will open select first 3 checkboxes and click on “Setup Now” then click “Yes”

Step 7 : Wait for completely Sikuli-ide-1.0.1.jar(12MB file) file to download (will take some time(around 5-10 minutes))

Step 8: Then Sikuli IDE will start automatically (DONE)

Integration with Selenium Webdriver

1.Add the following jar files to the project in which you want to integrate Sikuli tool.

i.Sikuli-api-1.0.2-standalone.jar

ii.Sikuli-webdriver-1.0.2-standalone.jar

iii.Selenium-server-standalone-2.33.0.jar

iv.selenium-java-2.25.0.jar

2.Take the image of the object on which you want to perform operations like click,type,etc.

Here is an e.g to click on a flash button.

Screen screen = new Screen();
Pattern image = new Pattern("path to flash button image");
screen.click(image);

3.After placing this code you will see some errors as libraries are not imported. Just mouse over where errors are showing and include those libraries which eclipse is suggesting.Those libraries are below:

import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.sikuli.script.FindFailed; 

4.Now run the code and you are good to go!