Soap UI Assertions

In this post I am going to explain what assertion in soapui is and how we can apply script assertion.

Assertion

Assertion functionality in SoapUI is used to validate the response of request received by the Test Steps at the time of execution. Usually assertion is to compare a part of message (or the entire message) to some expected value.
Assertion applied in SoapUI at response of request, if any assertion failed then test marked as failed. Failed test can be verify and find out the reason.

Data driven testing using java webdriver TestNg framework

In this post I implemented that how to perform data driven testing using java Webdriver  TestNg framework. As we know testNg provide @DataProvider annotation, using this I can pass a set of data into our Webdriver test method.  I have created a sample test script for Wikipedia where I use a set of country data, with Wikipedia search functionality and verify searched country.

Ant build tool

Apache Ant is java based library and command line tool. Ant drive application using build xml file, control behavior of build, compile and run targets define in build xml file.

Basically ant build is a java based application. It can be Also  build non java applications such as C, C++, PHP, Python etc by passing their compile/interpreter. Ant is written in java so ant user can be develop their own library. Ant is easy to use it does not impose coding convention or directory layouts to the java projects.

Ant use a configuration xml file, default name of file is build.xml. ant directly call target define in build file. Targets can be define their dependencies, ant will automatically execute dependent target.

Here is a sample of ant buid.xml file.

Screen Recording (Video) of Java Webdriver script

Sauce lab provided screen capturing functionality to test scripts execution, I was looking same type functionality to work on local machine and came up across “Monte Media Library” java based library developed by Werner Randelshofer.. In this post I have described a way to capture screen cast/ Video recording of selenium/webdriver test script execution.

Step to implement Monte Media library to selenium/Webdriver test scripts.
  1. Download “MonteScreenRecorder.jar” from link http://www.randelshofer.ch/monte/
  2. Add this jar file to your selenium/webdriver eclipse project.
  3. This jar file contain “ScreenRecorder” class, we need to create this class object by following way.

Sikuli Firefox Webdriver

Sikuli launched new API for java based programming language frameworks. This API provide image based GUI automation.  The new java library API has re-designed  and included several new functions that were not available in original sikuli script. Such as the ability match color. Handle events and fund geometric patterns such as rectangular button.  It can be integrated with maven build.

Requirements
  1. Java Runtime Environment(JRL) or Java Development Kit (JDK) version 1.6 or newer.
  2. Apache maven version 2.0.10 or newer if you want to build it from maven.
Supported Platform:
  1. Windows 7 (64/32 bits) 
  2. Mac OS X(64 bits)
  3. Linux (64 bits).

Watir Ruby Based Automation Tool

About Watir:
:
Watir is an open source,  ruby based automation tool for web application. Watir drives application on web similar type as user do. It click on browser, fill form data, press button etc. Also it check result such as when any text appear on page.
Using ruby programming language we can make connection to data base, read files(csv, xls, txt, xml etc.) We can create our own function and library for reusable code.

Webdriver C# test scripts execution using Grid2

Nunit framework is not support parallel execution of driver test scripts using Grid. If we use MbUuit framework then we can accomplish parallel execution of test scripts against Grid2. For set up MbUnit you can see “MbUnit Framework

Test scripts setup :
  1. Add reference Gallio and  MbUnit ddl file to your Webdriver project from installed Gallio folder.
  2. Add below code in project’s  “AssemblyInfo.cs” file.
using MbUnit.Framework;

[assembly:DegreeOfParallelism(2)]
[assembly:Parallelizable(TestScope.All)]
       3. We need to add below code for MbUnit framework in test scripts.
using MbUnit.Framework;

add [Parallelizable] annotation on test case lavel ass I added in belowtest scripts.
       4. I have created two test one “GridTest1.cs” file for internet explorer and “GridTest2.cs” file for firefox  browser.

C# WebDriver with MbUnit Framework

Set Up C# Webdriver with MbUnit and Gallio:
  1. Download and install Gallio from link ‘http://gallio.org/Downloads.aspx’
  2. Add reference Gallio and  MbUnit ddl files to webdriver project from installed Gallio folder.

Parameterization in soap ui using soap ui property feature

Sometimes we need to use some values in several times in our api test, such as api end point, api methods name, user name, password etc. If these values we put in place and use these values when needed in our test. If these values changed then we need to update only a single place.

In SoapUI we can use parametrization from external files of property feature of SoapUI.

Parametrization using SoapUI properties:


 In soapui properties can be created at three level
  1.     Test Case
  2.     Test Suite
  3.     Project.    
Click on created test case. Click on properties tab at bottom of soapUI.
Click on + icon and enter property name.

As I created a property for endpoint url .


Similarly we can create properties for Test Suite and Project level..

How to use:
  1.     ${#TestCase#EndPoint} for test case property.
  2.     ${#TestSuite#EndPoint} for test suite property.
  3.     ${#Project#EndPoint} for project property.

Soap UI API (HTTP Test request) testing for beginner

About Soap UI:

Soap UI is a free and open source cross-platform Functional Testing solution. With an easy-to-use graphical interface, and enterprise-class features, Soap UI allows you to easily and rapidly create and execute automated functional, regression, compliance, and load tests. In a single test environment, Soap UI provides complete test coverage and supports all the standard protocols and technologies. There are simply no limits to what you can do with your tests.

Soap UI testing area:

SOAP UI is basically used for API testing, below are some areas of  SOAP UI testing.
  1. Functional Testing.
  2. Load testing.
  3. Service mocking 
  4. Security Testing.
  5. Http protocol request testing.
  6. SOAP and WSDL
  7. Rest API testing.
  8. JMS API testing.
  9. AMF type API testing.
  10. WEB and HTTP.
Procedure- test HTTP type API method.

Download and install Soap UI from url “sourceforge.net/projects/soapui/files/”.
Go to start >All Programs > SmartBear >soap UI *.*.*   and click on Soap UI-*.*.*
You should see Soap UI will open on machine.

Start with C# WebDriver - Procedure to create first test script for the beginners

Prerequisite:
  1. Visual studio should be installed in machine..
  2. Download “Nunit: from link http://nunit.org/index.php?p=download and install in your machine.
  3. Download selenium-dotnet-2.31.0.zip file from link http://docs.seleniumhq.org/download/ and unzip in your machine.
Step To create new project.

    1. Open Visual studio in your machine.
    2. Go to and click on  File > New > Project.
    3. Select visual C# from left panel and select class library


     4. Enter project name  chose location and click on OK button.
     5. A default class created with named “Class1.cs” under your project         
     6. Rename this class or create new class for your test script.

Start with Ruby WebDriver - Procedure to create first test script for the beginners

Setup of Ruby and Selenium 2
  1. Download ruby setup file  from url http://rubyinstaller.org/downloads . Install the executable file into your system and set Ruby as Environmental variable into your system.
  2. Open command prompt and check “ruby  -v “ to verify ruby installation and path setup.
  3. After ruby installation run below command for selenium2 installation.
gem install selenium-webdriver

Create First Test Scripts:

Capture your test scenario using selenium Ide. import test script into Ruby/ Test::Unit /Webdriver and save as a .rb file in your machine. I have created below a sample Google search script.

Start with PHP WebDriver - Procedure to create first test script for the beginners

Prerequisite:
  1. PHP should be installed and set up path in your machine. 
  2. PHPUnit Should be installed in machine.
  3. Java should be install and setup path in machine.
  4. Selenium2 jar(selenium-server-standalone-2.**.0.jar) file should in your machine.
Procedure & Setup of PHP and PHPUnit

If PHP and PHPunit are not installed in machine. We need to follow to installed them using below steps:
  1. Download PHP exe file from download and install in machine.
  2. Setup PHP path in environment variable if by default not path set. As if I installed in C:\\PHP drive the we need to setup path  “C:\\PHP”
  3. Now we need to install PEAR for this we open command prompt and go to PHP installation directory and run command
php.exe PEAR/go-pear.phar
     4.  After pear installed check version using command “pear  –V” . run below command to update pear.
  pear upgrade pear

TestNg Dependencies

Sometime we need to run test methods in certain order, As we need to run a test method always run after some test method. TestNg provide two ways to accomplish this either with annotation or XML suite.

Dependencies with annotations.

dependsOnMethods or dependsOnGroup attribute are used on @Test annotation to accomplish execution of dependent test.

There are two kinds of dependencies:

TestNG Parametrization: Part-2

If you need some complex parameter or parameter that need to created from java then using testng xml file parameter is not sufficient. For this need to use Data provider to pass values into test method. A data provider is a method of your class which return an array of array of objects. TestNg annotation of this method is @DataProvider.

TestNG Parametrization: Part-1

Parametrization means passing values in Unit test script using TestNG xml file, or using @DataProvider testing annotation

Parametrization using testing xml file:

For this type of parametrization need to declare “@Parameters” annotation in method which needs parameter testing, the value of parameter will be provided by using TestNG suite xml file. Using this we can Test a single unit test for multiple set of values.

How to create TestNG suite file.

TestNG suite means grouping two or more than two classes to execute with a single command.

How to create:
Create some test class as I created below two test class  “FirstTest.java” and “SecondTest.java” java files.

FirstTest.java:

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class FirstTest {
       
        @BeforeClass
        public void beforeClass() {           
           System.out.println("One time executed before first mathod");
        }
         
        @AfterClass
        public void afterClass() {
            System.out.println("One time executed after last method");
        }
                  
        @Test
        public void testFirstMethod() {       
           System.out.println("@Test - executed first test method");
        }
}


Some basic annotation of TestNG

Below are some basic annotation which we use in automation.
 
@BeforeSuite - Execute only one time before all testNg method..
@AfterSuite - Execute only one time after all testNg method.
@BeforeClass - Execute only one time before first test and after @BeforeSuite testNg method.
@AfterClass - Execute only one time after last test and before @AfterSuite testNg method.
@BeforeMethod - Execute before every @Test methods.
@AfterMethod - Execute after every @Test methods.
@Test – TestNG test method.

How to run java test scripts using Grid2

Prerequisites. 
  1. Java should be install and setup path in system.
  2. Eclipse should be configured TestNG plugin 
  3. Download the selenium-server-standalone-version.jar from the below location.
  4. TestNG jar file.
Steps to  create and execute test scripts:

1. Launch Grid 2 console(Hub ) and Nodes using below commands:

    Hub:
       java -jar selenium-server-standalone-2.29.0.jar -host localhost -port 4444 -role hub

    Nodes:
       java -jar selenium-server-standalone-2.29.0.jar -host localhost -port 5555 -role webdriver -hub http://localhost:4444/grid/register -browser browserName=iexplore,platform=XP,version=8

        java -jar selenium-server-standalone-2.29.0.jar -host localhost -port 5556 -role webdriver -hub http://localhost:4444/grid/register -browser browserName=firefox,platform=XP,version=13
       
2. Run test case parallel:  This “WebDriverGrid2Test “ example will be run test case on firefox and  internet explorer on version 8 and 13 respectively.

How to run python webdriver test scripts using Grid2

Prerequisite:
  1. Java and python should be installed and setup path in your machine..
  2. Download xmlrunner.py from below url: http://pypi.python.org/pypi/XmlTestRunner/0.16654
  3. Download and install “setuptools 0.6c11” from below link: http://pypi.python.org/pypi/setuptools
  4. Install selenium 2 in your system using command: > easy_install selenium
  5. Selenium server file should be in machine
Set up and launching Selenium Grid:

      1. Run below command in on your console to launch Grid hub console:
java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 4444 -role hub
       2. Open two console and run below command to launch and register node with Grid hub.
java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 5555 -role webdriver -hub http://localhost:4444/grid/register -browser browserName=firefox,platform=WINDOWS

java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 5556 -role webdriver -hub http://192.168.1.22:4444/grid/register -browser browserName=iexplore,platform=WINDOWS
           Replace local host to system IP of Hob machine. If you want to launch node in different machine.