Java junit client of WSDL webservices

In this post, I will show you how to create java client for WSDL web services.
I will Create a example of currency converter,  This is wsdl URL  for same. “currency converter

Request of “ConversionRate” method:

Webdriver implicit and explicit wait for element locator.

Today most of web application using Ajax, When page is load some element load in a different time of interval or some time request send without page loading if the element not present then it through element not found exception or not visible element etc.. To handle this Webdriver provides two type of wait “implicit” and “explicit” wait

Implicit Wait: implicit wait provide to load DOM object for a particular of time before trying to locate element on page. Default implicit wait is 0. We need to set implicit wait once and it apply for whole life of Webdriver object. Add below line of code in test for implicit wait. However implicit wait slow down execution of your test scripts if your application responding normally.

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Calabash android predefined steps.

Calabash android has some predefined steps, you don’t need to define these steps in your steps definition ruby file. Just call these functions in your  feature file by passing valid argument.

Assertion steps:
Following are the some steps definition for the assertion

Then /^I see the text "([^\"]*)"$/  

Then /^I see "([^\"]*)"$/

Then /^I should see "([^\"]*)"$/ do

Then /^I should see text containing "([^\"]*)"$/ do

Then /^I should not see "([^\"]*)"$/ do

Then /^I don't see the text "([^\"]*)"$/ do

Then /^the view with id "([^\"]*)" should have property "([^\"]*)" = "([^\"]*)"$/ do

Then /^the "([^\"]*)" activity should be open$/ do


Road to verify css properties value using Webdriver

To get css values of any locator, we will create java script function with the use of “getDefaultComputedStyle”function. We will execute java script function using webdriver and fetch css properties value.
getDefaultComputedStyle () gives  default computed value of all css properties of an element.
Here I have created a sample example in which I am verifying Google home page menu bar css properties color, height and width.

package com.test;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class WebdriverCSSValue {

   private WebDriver driver;
   private String baseUrl;

   @BeforeSuite
   public void setUp() throws Exception {
         driver = new FirefoxDriver();                    
         baseUrl = "https://www.google.co.in/";
         driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
   }

   @Test
   public void testCSSvalueVerifying() {
         driver.get(baseUrl + "/");
              
         // js scripts
         String js = "return window.document.defaultView.getComputedStyle(" +
                                       "window.document.getElementById('gbx3'))";
         String jsColor = js+".getPropertyValue('color')";
         String jsHeight = js+".getPropertyValue('height')";
         String jswidth = js+".getPropertyValue('width')";

         // execution of js scripts to fetch css values
         JavascriptExecutor jsexecuter = (JavascriptExecutor) driver;
         String color = (String) jsexecuter.executeScript(jsColor);
         String height = (String) jsexecuter.executeScript(jsHeight);
         String width = (String) jsexecuter.executeScript(jswidth);
              
         //assertion
         Assert.assertTrue(color.equals("rgb(34, 34, 34)"));
         Assert.assertTrue(width.equals("986px"));
         Assert.assertTrue(height.equals("29px"));
              
         // print css values
         System.out.println(color);
         System.out.println(height);
         System.out.println(width);
   }
  
   @AfterSuite
   public void tearDown() throws Exception {
         driver.quit();
  }

Ruby WebDriver – procedure to create test scripts in RSpec

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
4. Run below command for Rspec.
gem install rspec
5. For more detail about RSpec go to link “http://rspec.info/

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();