Friday, 7 September 2018

Compare Images in Selenium Test

Visual / UI Validation of web pages across different browsers & devices is very important these days as more and more applications are getting web enabled. And most of the websites are eyeing on 'Responsive Web Design' to create a single website across multiple resolutions.

This type of testing is usually performed manually. However, now you can automate these type of tests to an extent using different image comparison libraries like Thumbnailator, Slenium-Shutterbug, ImageMagick Applitools Eyes etc.

Using these libraries, both Functional Testing & Visual Testing can go hand-in-hand without having to maintain separate set of scripts.
One such example using Image-comparison.jar based on Thumbnailator library is as below:


Steps:


Wednesday, 5 September 2018

Capture Full Screenshot in Selenium using Shutterbug


Selenium with the new upgrade 2.0 to 3.* had changed the way it works in the background. Starting with this upgrade, FirefoxDriver has stopped taking the full screenshot. There are many instances where user needs complete screenshot of the web page.
Many teams have worked on it & provided few open source libraries like AShot, ShutterBug etc.

Below code snippet would enable you to get the full screenshot using ShutterBug java library.

STEPS:


Capture Full Screenshot in Selenium using AShot


Selenium with the new upgrade 2.0 to 3.* had changed the way it works in the background. Starting with this upgrade, FirefoxDriver has stopped taking the full screenshot. There are many instances where user needs complete screenshot of the web page.
Many teams have worked on it & provided few open source libraries like AShot, ShutterBug etc.

Below code snippet would enable you to get the full screenshot using AShot java library.

STEPS:


Wednesday, 25 July 2018

Native App Automation using Appium

In the Mobile world, we see multiple types of apps namely Native App, Hybrid App & the browser based application, Web App. Also, we see multiple types of operating systems like Android, iOS, Windows, Firefox OS etc.

Automated testing of these many variation of apps, is very tricky & difficult task. Not all of them are supported by single automation tool. Having said that, Appium which is built over Selenium webdriver supports most of the OS & apps with different configurations.

In this article, you would know a way to automate the Native App using AndroidDriver.

Prerequisites:

  1. Android SDK is downloaded and installed. (ANDROID_HOME env. variable should be set)
  2. Either Emulator or  Real device (USB debugging enabled) is available.
  3. Appium desktop app or non GUI package is installed. 

Steps:

  1. Create a java project in eclipse 'AppiumMobileTesting'.
  2. Create a class 'TestNativeApp' to add the automation code.
  3. Connect your device(USB debugging enabled), to system's USB port & accept if any confirmation pop ups.

Friday, 22 June 2018

Data Generation using Java

Data Generation in Test Automation is one of the tedious task which consumes lot of time before the start of execution. So, Why provide the data required for Automation manually? Automate it. !!

Having said that, it is not so easy to address every requirement with single solution. In the below example, i am trying to address few of the generic use cases which will let us automate the data creation. 

NOTE: 

  • Below sample uses 'Xegeran automation library to generate text from regular expressions.
  • Apache commons RandomStringUtils class to generate the random text.


Below example will let you know the way to generate the Random strings of different types.


public class RandomTextGenerator {

Thursday, 31 May 2018

Web App Automation using Appium

In the Mobile world, we see multiple types of apps namely Native App, Hybrid App & the browser based application, Web App. Also, we see multiple types of operating systems like Android, iOS, Windows, Firefox OS etc.

Automated testing of these many variation of apps, is very tricky & difficult task. Not all of them are supported by single automation tool. Having said that, Appium which is built over Selenium webdriver supports most of the OS & apps with different configurations.

In this article, you would know a way to automate the mobile web app using RemoteWebdriver.

Prerequisites:

  1. Android SDK is downloaded and installed. (ANDROID_HOME env. variable should be set)
  2. Either Emulator or  Real device (USB debugging enabled) is available.
  3. Appium desktop app or non GUI package is installed. 

Steps:

  1. Create a java project in eclipse 'AppiumMobileTesting'.
  2. Create a class 'TestWebApp' to add the automation code.

Sunday, 29 April 2018

How to Avoid Certificate Popups to enable smooth Automation


Certificate Popups are common in a secured environment or while accessing the internal applications. It is a basically a way to authenticate the users accessing the application.

Yes, I know..! This is annoying for automation testers.
To overcome this annoying feature and yet without compromising on security, we have to make certain settings on each browser. These settings enable us to have smooth automation.

The fix is very simple, let the browser know which certificate to select as default one. Thus stops asking you for a client certificate. Follow the settings mentioned below based on the browser:

NOTE: 
  1. This approach will help when you have no or only single certificate added to browser.
  2. This approach is tested on windows OS.

Mozilla Firefox:

Step 1: Import Certificate

  1. Open Firefox > Options > Certificates > View Certificates > Your Certificates.
  2. Click Import & follow instructions to import a certificate(*.pfx)
  3. After Import, Success Message will be popped up.

Thursday, 21 December 2017

Connect Jira from Java using Jira REST API


Jira is one of the popular bug tracking tool developed by Atlassian. It also provides project management features inline with Agile methodology. Jira is basically written in Java & can integrate with source control programs like Perforce, Git, Clearcase, Subversion, TFS etc.
It also provides robust set of APIs which enables its integration with any system.

An interesting fact about its name 'JIRA': It is not an acronym, but a truncation of 'Gojira', the japanese name for 'Godzilla'.  :)

Example to Create Issue & Search Issue:

This example shows how to consume Jira REST APIs from Java using REST Assured libraries.

Step 1: Create a Project with dependent REST assured libraries.

NOTE: For the set up / usage of REST assured libraries can be found in another post.
https://advancedtestautomation.blogspot.in/2016/08/test-rest-web-services-using-rest.html

Thursday, 7 December 2017

Selenium Tips and Tricks


Get the DOM Object into View:


At times, few actions are not performed on a DOM object until it is visible in the view-port. Below is the small code snippet to get the DOM object into view using WebDriver's 'JavascriptExecutor' interface. 

WebElement element = driver.findElement(By.id("someId"));
JavascriptExecutor js= (JavascriptExecutor) driver;
js.executeScript("arguments[0].scrollIntoView(true);",element);

OR

((JavascriptExecutor) driver).executeScript("document.getElementById('text123').scrollIntoView(true);");

Selenium WebDriver Wait Commands:

For any automation scripts to work without any sync issues with application, wait statements are very important. Selenium WebDriver provide different types of Wait conditions to make automation scripts effective.

Below are different types of waits & its usage.

Thursday, 28 September 2017

Validate Website Performance using Google PageSpeed Insights

Google has developed a set of website Performance Optimization tools called 'Google PageSpeed'. It has 4 main components: PageSpeed Module, PageSpeed Insights, PageSpeed Service and PageSpeed Chrome Extension. These tools are built to idetify the flaws in website’s compliance with Google’s Web Performance Best Practices.Also, automate the flaw correction process.

PageSpeed Insights:


An online tool helps in identifying performance score on any website and provides suggestions on optimizations to make website faster. This can be accessed directly in any browser. It provides the webpage performance score on a scale from 0 to 100 for each url request, provides a report on suggested optimizations. It provides specific score for mobile & desktop & corresponding suggestions.

The scores fall under the below 3 categories:
Good: The page applies most performance best practices and should deliver a good user experience.

Needs Work: The page is missing some common performance optimizations that may result in a slow user experience.

Poor: The page is not optimized and is likely to deliver a slow user experience. Please prioritize and apply the recommendations below.

Monday, 17 July 2017

Integration of Selenium + Sikuli

Sikuli is a tool using Visual Recognition capability which automates anything seen on the screen of your computer running Windows, Mac, few Linux/Unix OS systems. It uses Image recognition powered by OpenCV to identify the GUI components.

The version of Sikuli is named as 'SikuliX'. It also comes with basic text recognition (OCR) feature to search text within images.Besides locating images on screen, it can handle mouse & keyboard events to interact with GUI elements. 

Friday, 19 May 2017

Selenium for Angular JS Pages


Selenium + NgWebDriver  =  Better AngularJS Support

Angular JS is a opensource web application framework based on Java-script. Any Angular JS implemented web page would have additional custom tag attributs like ng-app, ng-model, ng-bind, ng-repeat etc.

Automating the AngularJS based web application is possible using Selenium. However in certain cases where the web pages are built extensively using AngularJS  resulting in complex DOM structure, it is difficult to locate DOM elements with simple XPaths & CSS selectors.In this case, Protractor (an E2E test framework for Angular Applications) built on Java script version of Selenium makes it easy for identifying the locators easily.

Sunday, 19 March 2017

Voice Driven Testing using Perfecto Mobile

Most of the applications today started supporting voice commands either it is a desktop or a mobile.More & more functionalities are being supported by voice commands.

Testing these functionalities is very difficult as it requires audio files which are hard to edit / maintain them whenever required. Perfecto has come up with a better way to test these functionalities.

Steps to test Voice Driven Functionalities:
  1. Enter required text
  2. Convert Text to Audio
  3. Inject the generated Audio to application

Wednesday, 25 January 2017

Seamless Integration of Selenium + AutoIT

AutoIT is a freeware available to automate Windows GUI by simulating the combinations of mouse movements & key strokes. AutoIT has its own basic syntax, editor & control identification mechanism. However, to achieve the code level integration one can use 'AutoItX', packaged with AutoIT. This supports access to AutoIT functions using COM objects.

Monday, 16 January 2017

Extract Text & Images from PDF


Extracting text from PDF is not as simple as reading text from a text(.txt) file. One has to use suitable libraries to extract data from any pdf file. For example, Below code snippet shows one of the way to extract text or images from PDF file using Apache's PDFBox libraries.