Integration of Junit test with Jmeter

In this post I will show you how to integrate and execute Junit test with Jmeter .

Junit test:

Here I have created two Junit test:
1. JunitFirstTest.java:
package com.test;

import org.junit.*;

public class JunitFirstTest {

    @BeforeClass
    public static void beforeClassAnnotation() {        
         System.out.println("@BeforeClass - for junit class 1");
    }

    @AfterClass
    public static void afterClassAnnotation() {       
         System.out.println("@AfterClass - for junit class 1");
    }  

    @Test
    public void testAnnotation() {       
        System.out.println("@Test - first class test method");
    }    
}

Road to integration of WebDriver test script with TestLink

TestLink Installation:  Test link installation you first need to go this link click here

TestLink Setup for Automation:
1. First you need to enable Automation (API keys) of your test link project.
Open your testlink project, click on check box of “Enable Test Automation (API keys)” and click on save button.

2. Generate Key: This key provide interface between webdriver test scripts and testlink. You must generate this  key. To generate this click on >> My Settings  menu and click on “Generate a new key” button under “API interface” section.


3. Create test link project.
4. Create test link plan and add test plan to created test link project.
5. Create test suite and test cases under created test link project.

How to install and setup Testlink on window machine?

Perquisite:
  1. Download and install xampp application into your machine from link: "http://www.apachefriends.org/en/xampp-windows.html" 
  2. Download testlink from link "http://sourceforge.net/projects/testlink/files/" and put into xampp's htdocs directory.
  3. Extract downloaded zip file into xampp's htdocs directory.
  4. Start Xampp application and start “Apache” and “MySql” Server, your window look like below screen:
Steps to setup:

1. Open browser and go to url “localhost/phpmyadmin”
2. Click on “DataBases” menu and create new data base like “testlink”
3. Your created data base listed in left side panel like as in below screen:

Road to handle file download popup in webdriver using Sikuli

In this post I will show you how to integrate webdriver test script with Sikuli automation tool to handle window popup utility like file download and upload etc.
Here I take example of a file download window popup utility, which we can not handle by using webdriver functions. Some people use different-2 automation tool like AutoIt, java Robot class to handle this.
Here is an example of webdriver sikuli integration to handle below selenium jar file download window popup utility.

Some Webdriver API functions in java and its implementation

Following are the some API functions and it implementation
1. How to click on element: By using click() function we perform click operation on page element:

WebElement el  =  driver.findElement(By.id("ElementID"));
el.click();

2. How to enter text into page element: By using sendkeys() function we enter text in page element such as text field, area etc:

WebElement el  =  driver.findElement(By.id("ElementID"));
el.clear(); //use to clear input field
el. sendKeys (“User name”);

3. How to count total number rows in table:

List rows = driver.findElements(By.className("//table[@id='tableID']/tr"));
int totalRow = rows.size();


Road to data driven testing in SoapUI from csv file

In this post I will show you how to execute SoapUI test for a set of values. For this I have put all data in csv file. I write groovy scripts for reading data from csv and executing the test steps.
Below is the groovy script for reading data from “URL.csv” file where I put all user credentials.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

def csvFilePath = "D:\\URL.csv"
context.fileReader = new BufferedReader(new FileReader(csvFilePath))

rowsData = context.fileReader.readLines()
int rowsize = rowsData.size()

for(int i =0;  I < rowsize;  i++)
{

    rowdata = rowsData[i]
    String[] data = rowdata.split(",")
    log.info data[1]
   
    groovyUtils.setPropertyValue("Login", "UserName", data[0])
    groovyUtils.setPropertyValue("Login", "Pass", data[1])
    testRunner.runTestStepByName( "Login")  
}

In above code I read data from “URL.csv” file and pass user name and password into “UserName “ and “Pass” of Login steps parameters.
“Login”  test step executed by using test runner for every data.

Road to reading data from text file in SoapUI using groovy script

In this post, I am going to show you how to read data from text file in SoapUI. SoapUI Pro has some advance feature which is not in SaopUI as data fetching from external sources so in SoapUI we use Groovy script for that. Following are the peace of groovy script code for reading data from text file.

1. Reading all data from text file.
//reading all txt file at once

File file = new File("D://user.txt")
fileContent = file.getText()                 
log.info fileContent

2. Reading data line by line from text file.
//reading text line by line

File file1 = new File("D://user.txt")
List textLine = file1.readLines()
log.info textLine

3. Reading data randomly of any line from text file.
//reading text randon line number

File file2 = new File("D://user.txt")
List textLine2 = file2.readLines()
rowIndex  =  Math.abs(new Random().nextInt() % 4 + 1)
log.info textLine2[rowIndex]

Road to handle popup window using text in Webdriver

Some times we have not title of pop window so in this case we can identified some unique text (content ) of popup window which is not in other window. Using this text we can switch to pop window. Below are the logic and implemented code.

Road to installation of SoapUI plugin into Eclipse.

Following are the steps to install soapui plug-in into eclipse.
1. Open Eclipse IDE and goto “Help” menu and click on “Install New Software”
2. Click on add button you should see like below window.


3. Enter some text into “name” field as “SoapUI“ and enter url http://www.soapui.org/eclipse/update into “Location” field.
4. Click on “OK” button, you should see below screen and soapUI will display.

Execution of SoapUI project using Junit

In this post I am going to show you how to execute SoapUI project using Junit.
SoapUI provide testrunner class name “SoapUITestCaseRunner” which can be used to run soapui test using java class, maven or ant build tool. We create object of this class in java file and call the run function to execute soapui project.

Steps to create Junit test for soap ui project:
1. Chose any IDE as eclipse or NetBean
2. Add “soapui-4.5.1.jar” from soapui bin folder and soapui lid folder as library to class path of your project (eclipse).
3. Use “SoapUITestCaseRunner” class object to run soapui project as mentioned in below code: