? QA Design Gurus: Test Automation
Showing posts with label Test Automation. Show all posts
Showing posts with label Test Automation. Show all posts

May 10, 2016

How to speed up Test Execution using Selenium Grid


As we know that Selenium is the most popular web application automation tool in the market, because it is available at free of cost and open source. When testing a web application, will get couple of things in our mind.

  1. How to run the test case in different browser’s?
  2. How to run the test case in different versions of same browser?
  3. How to run the test case in different operating systems?
  4. How to run the test case parallel in different browsers or different versions of same browser or different operating systems?
Selenium Grid is the solution for all the above problems. Selenium Grid is one of the component of Selenium Tool. By using Grid, we can manage multiple environments from a central point and making it easy to run the tests against a vast combination of browsers/OS, which reduces the amount of total time to run your full automation tests.

Selenium Grid uses a Hub-Node concept, where test cases will be running on a single machine called Hub, but the execution will be done by different machines called Nodes. i.e., Node will have the browser drivers and Hub will be passing your test cases to each node and that will be executing.

What is Hub?

Hub is central point to the Selenium GRID, which receives the all the requests and distribute them to the right nodes. There is only on Hub in entire Selenium GRID Architecture.

What is Node?

Nodes are the selenium instances that will execute the tests. There can be any number of nodes in GRID. Each and every node communicates with hub and performs the appropriate action.

                        


How to set-up Selenium Grid?

Step – 1: Download the selenium standalone jar file from http://www.seleniumhq.org/download/

Step – 2: Run the selenium standalone jar file from command prompt as shown below:
C:\GridDemo\java –jar selenium-server-standalone.jar –role hub –port <port_number>
We can check the status of the node by accessing the URL http://localhost:<port_number>/grid/console

Step - 3: Now, go to the other machine and run the following command to setup the nodes
C:\java –jar selenium-server-standalone.jar –role node –hub http://<Hub_IP_Address>:<Hub_port_number>/grid/register -port <node_port_number>

Now, go the Selenium GRID web interface to see the configured nodes. All are set to use the Selenium GRID, only we have to do is develop the scripts that can run on GRID.

For more information, refer link https://github.com/SeleniumHQ/selenium/wiki/Grid2

Protractor to test AngularJS Applications, Why?



In today’s world, technology is growing day by day very fast and modern applications are built using emerging technologies in the market.  Most of the modern applications have to integrate with a variety of external services, database systems and APIs. On top of that, they have to accommodate an ever-shifting landscape of devices and browsers.

This is an area that is very difficult or even impossible to test with traditional methods such as unit tests and simple mocks. A database can fail, an external service can return an invalid result and a new browser version might have introduced a simple bug that we didn’t know about when we initially write out code.

This is where end-to-end testing comes into picture. We want to test our application as a whole and make sure that it works as expected, starting from user interface down to the subsystems.
As we know that, now-a-days most of the applications are using AngularJS to develop the applications very fast, to get rich look and feel. In order to test the such applications end-to-end, Google has released an end-to-end testing framework called “Protractor”.

Salient Features of Protractor:

  1. Built on top of WebdriverJS and Selenium Server
  2. Introduced very simple syntax to write the tests
  3. We can use Selenium GRID to run multiple browsers at a time
  4. Allows us to running the tests targeting to remote address
Protractor is a wrapper around Selenium WebDriver, so contains every feature available in the Selenium WebDriver. Additionally, provided new locator strategy and functions which are very helpful to automate AngularJS applications.

The main benefit of using Protractor is no need to add waits or sleeps to your test. Protractor can communicate with AngularJS application automatically and execute the next step in your test the moment the webpage finishes pending tasks, so don’t have to worry about waiting for your test and webpage to sync.

For more information, refer link http://angular.github.io/protractor/#/ 

All About JBehave


JBehave is a java based framework for Behavior Driven Development (BDD). BDD encourages to develop the software by following below five steps.


  1. Define the stories via scenarios that express the desired behavior in a textual format.
  2. Maps the textual steps to Java methods
  3. Allows us to configure the classes
  4. Running the textual stories using JUnit, Apache Ant, Maven etc.
  5. There will be a reporting that allows to monitor the outcome of the stories that have been run

For more information, refer link http://jbehave.org/

Handling Authentication Window with Selenium WebDriver



There are times when we get an authentication pop-up window when we hit the application URL based on the authentication type set by the application servers. How do we handle such kind of pop-ups?

If they were JavaScript browser pop-ups, we could have handle using selenium webdriver. However, there are cases, when those pop-ups are thrown by the operating system as part of network policy. In this we can handle those pop-ups in two ways.

  1. Providing username and password as part of the URL

Unfortunately, this trick will work for Firefox and Chrome, but not for IE. To handle in IE, we have to use AutoIt tool.

  1. Using AutoIt tool
First download and install the AutoIt software from https://www.autoitscript.com/site/autoit/downloads/ and write the AutoIt script as follows:

WinWaitActive(“windows security”)
Send(“testuser”)
Send(“{TAB}”)
Send(“password”)
Send(“{ENTER}”)

Save the file as login.au3 and compile the script, will get login.exe file. Execute the login.exe file using JAVA after opening the Application URL.

Public class Demo {
            Public static void main(String[] args) {
                        System.setProperty(“webdriver.ie.driver”,”C:\IEDriverServer.exe”);
                        WebDriver driver = new InternetExplorerDriver();
                        driver.manage().windows().maxmize();
                        driver.get(“https://www.engprod-charter.net/”);
                        Runtime.getRuntime().exec(“C:\\login.exe”);
            }
}

May 8, 2016

Integrating TestNG with Eclipse


TestNG is a testing framework developed for JAVA programming language. The “NG” means for “Next Generation”. The goal of designing TestNG is to cover different types of testings like functional, unit, integration, end-to-end etc.
               There is a TestNG plug-in for eclipse, which allows us to run the tests from Eclipse and monitor the scripts execution easily.

Follow the below steps to integrate TestNG with Eclipse.

Step -1: Menu -> Help -> Install New Software


Step -2: "Install" wizard will open upon clicking "Install New Software". Now click on "Add" button in "Install" wizard.


Enter “TestNG” for “Name” field and for “Location” provide value as http://beust.com/eclipse
Click “OK” button.

Step – 3: Continue the installation by clicking “Next” button until finish the TestNG installation.

Once the installation is done, we can check installation is completed properly or not by following below steps:
  1. Open eclipse.
  2. Click on Menu -> New -> Project
  3. Expand "Java" under 'Show View" wizard, we get "TestNG".

Now, we can create TestNG project for writing the testcases.

Fore more information refer link http://testng.org 


Mar 30, 2016

Be a QA


Quality Assurance (QA) ensures the quality of the product and focus on giving confidence for the release. As a person, it is good to have a few qualities which will help us to excel in our job.
Let me give my version of QA.

QA means Questions & Answers:
Questioning is very important in our life. If we want to buy a product, we ask a lot of questions and will know about the product completely and then take the decision. And, if you are a seller, providing proper answers are also equally important to sell the product.
In the same way, QA has to ask questions whenever there is a feature discussion or in any meetings. And, as a QA provide various kinds of answers when a customer asks questions.

The best way to achieve this is to be active in Community/Forum where we get to know various kinds of questions as well as answers.
Bottom Line: Ask as many questions as possible, provide as many answers as possible

QA means Quick & Automate:
In this busy life, we have to take decisions quickly to resolve issues. For example, if we have a problem in our family, we have to work on it as soon as possible before it gets bigger.

In the same way, if we found any issue in the product or process then raise it immediately without any delay. And, learning the things quickly will give us ample time to look into other activities. If you pay attention in whatever you do, then quick learning will automatically happen.

Software testing has a huge scope and it contains a lot of testing types. It is not easy to say ‘We are ready for Production’ without doing enormous work. We have to take care of each and every testing type and ensure that everything is working fine.
How can we test all testing types within a given period of time to certify a build?
The only way to achieve this is using a weapon called ‘Automation’.
Automation helps us to do our existing tasks quickly and it allows us to explore new things.

Let me give an example to illustrate the same.
We want to travel from a source to destination.
We decide to take a vehicle based on the distance that is there in between. For example, if we want to travel to the USA, we catch the flight. If we want to travel within India, we have a few more options along with flight.
So, we use a vehicle to reach our destinations quickly.

In the same way, if we use a vehicle called automation in our software testing then we can reach our destinations called deadlines successfully without any issues. And, we can save a lot of time and effort if we do automation. As a QA person, we have to take a decision on which tool we need to use based on our testing category.
Bottom Line: Be quick in every action and try to automate everything that is coming in your way
So, what are you waiting for?
Be a QA person in both personal and professional life!!!

Feb 8, 2016

TTS Tips: Moving elements in Element Repository from frame to its parent page

In the current software industry, web applications have been changing drastically day by day. There is a possibility that the application has frames at initial stages of development and will be removed at later point of development. This poses unique set of challenges during test automation. 

TTS uses global Element Repository concept to store element objects. If the application has frames, the elements inside the frame will be stored in the hierarchy like Page Node --> Frame Node--> Element Node and the elements outside the frame will be stored in the hierarchy like Page Node--> Element Node. 


Element inside the frame:

 


Element outside the frame:

 

 


The TTS execution engine does not use the page node but it uses both frame node if exists, and element node during test execution. Hence, even though element identification logic is same, the test case which has written on old application will not work on new application after removing frames. Unfortunately, we don't have any way from TTS tool which we generally use to automate, to move the elements from frame to its parent page. TTS tool also doesn't allow to delete the element from Element Repository if it used in any one regular step. So the only way from the tool is, delete the corresponding regular step then delete element if it still exists in Element Repository. Now add the new element and corresponding regular step again. If there are one or two then it will be ok but if we have more such scenarios then it will be very tedious to QA to perform those many steps for each time.

One alternative way by which we can move the element from frame to its parent page node is, updating ".tstest" file. Yes, what you have listen is correct. By updating ".tstest" file we can move the element from frame to its parent page node without going to TTS tool UI and run the same test case without deleting and adding same regular step with new element like what I have mentioned above. I hope, you all know that when we create test from TTS tool , the corresponding ".tstest" file will be generated at a specified location. This ".tstest" file has auto generated code by TTS tool so we have to be very careful while updating this file. Updating this file is nothing but updating meta data that will be used by TTS tool to render test.

Below are the steps that needs to be performed on ".tstest" file to move the element from frame node to its parent page node.


1. Open '.tstest' file in Notepad/Notepad++.

2. Go to 'Steps' section. To go to this section search for '"Steps": { ' in '.tstest' file.


3. Go to the step that needs to be update. You can search with the test step description like 'Click on Data Source Groups'.




4. Go to elements section of that step and update Frame value with null.



Before update:

 

After update:

 

If there are minimal elements or test steps that needs to be changed then I will always suggest first approach.