Cucumber Java Selenium – Super Brief sum up

I am trying to sum up the whole thing using few Bullet points.

You need to create 3 files in Eclipse.

  1. Feature file
    1. CreateAccount.feature
    2. Login.Feature
    3. Feature: Login
      Description: This feature is to test the login functionalityScenario: Successful Login with Valid Credentials
      Given User is on Home Page
      When User enters Username and Password
      And Clicks Go button
      Then A message is displayed
  2. Step Definition File:
    public class TestingSteps {
     static WebDriver driver;
     static String URL;@Given("^User is on Home Page$")
     public void user_is_on_Home_Page() {
     System.setProperty("webdriver.gecko.driver", "H:\\somePath\\geckodriver.exe");
     WebDriver driver = new FirefoxDriver();
     URL = "";
    @When("^User enters Username and Password$")
     public void user_enters_UserName_and_Password() {
     WebElement loginLink = driver.findElement("login"));;
    WebElement emailField = driver.findElement(By.xpath("//div[@id='email']//input"));
    WebElement passwordField = driver.findElement(By.xpath("//div[@id='password']//input"));
     @When("^Clicks Go button$")
     public void clicks_Go_button() {
     WebElement goButton = driver.findElement("goButton"));;
     @Then("^A message is displayed$")
     public void a_message_is_displayed() throws Throwable {
     WebElement practicePage = driver.findElement("DrpDwn"));;
     System.out.println("Login Successful");
  3. JUnit Runner
    1. package tests;
      import org.junit.runner.RunWith;
      import cucumber.api.CucumberOptions;
      import cucumber.api.junit.Cucumber;
      public class TestRun {

      4. Right click on the TestRunner file and click on Run as Java Application.


Leave a comment

Really Microsoft…

Just wanted to rave.

So, I was looking for some information on transaction time. Google brought me to the following screen:


So, I clicked on the link. Which did NOT take me to “What is a transaction”. It took me here:


So, again, click on the next icon. After all, third times a charm, correct? WRONG!

Nice looking URL. But, the information is nowhere to be found.



Leave a comment

Regular Expression

This is a good site to test regex to use with QTP:

If our word is:



Or, ^Ctrl

Or, ^Ctrl$

Or, ^C…$

Or, C…

Or, ^C(?=trl)

Now, if the next word is:


Regex= C.....

Or, ^C(?=trl)..* (works in site, but does not work with the site mentioned at top).

Or, ^C* (does not work always)

Now, text: ctl11$sometext


Or, ^c[a-z]{2}\d\d[a-z]+$

Now, [a-z]{2} is to get the letter ‘t’ and ‘l’. I need to be specific to QTP does not go and recognize anything else.

The other part, [a-z]+$

The + means, the letters must occur one or more time. So, it would fail if the text is “ctl11”




If the number is 123.123


Leave a comment

What to check first if your QTP cannot connect with Quality Center?

Log in to Quality center server and make sure the SQL server service is running. It happened quite a few times. So, instead of going through the pinging the server, checking Quality center connections, just check the service first.

Leave a comment

How to set up hudson and continuous testing – part 1

My plan was simple. It was almost the same plan as Selenium implementation using Maven. This time, the goal was to use QTP instead of Selenium, since most (well, almost all) of my teammates are more familiar with QTP that they are with the other tool.

Anyway, installing Hudson was simple enough.

Download hudson from here:

Then, follow the text from this link:

Here the text:
Installing Hudson is super easy. Just download the war file, open your terminal/command-prompt and issue the command “java -jar hudson.war”. Now point your browser to http://localhost:8080. That was easy, right?

Well, turned out, if I save the war file in some random places, i.e. C:/this is one folder/and this is another/hudson.war, the war file gives error when you issue the command.

Easy solution, save your war file in C:/hudson. It will finish installation.

Running Hudson would look like this:


Here is how Hudson looks after loading first:


Now, to run QTP, we can just google to find out the necessary VB code. I used this site:

Dim qtApp 'As QuickTest.Application 'Declare the Application object variable
Dim qtTest 'As QuickTest.Test 'Declare a Test object variable

Set qtApp = CreateObject("QuickTest.Application") 'Create the Application object
qtApp.Launch 'Start QuickTest
qtApp.Visible = False 'Make the QuickTest application visible
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Normal"
qtApp.Options.Run.ViewResults = True
qtApp.Open "E:\QTP_scripts\Admin_user_search", True 'Open the test in read-only mode

'set run settings for the test

Set qtTest = qtApp.Test
qtTest.Settings.Run.OnError = "NextStep" 'Instruct QuickTest to display dialog box
qtTest.Settings.Run.ObjectSyncTimeOut = 30000 'Instruct QuickTest to wait for 30 seconds for response
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 'Create the Run Results Options object
qtResultsOpt.ResultsLocation = "E:\hudson\workspace\QTP-Hudson\General_results" 'Set the results location

qtTest.Run qtResultsOpt 'Run the test

' Save the Run-time Data
qtApp.Test.LastRunResults.DataTable.Export "E:\hudson\workspace\QTP-Hudson\Runtime.xls" ' Save the run-time Data Table to a file
WScript.StdOut.Write "Status is:" & qtTest.LastRunResults.Status & vbCr & vbLf ' Check the results of the test run
WScript.StdOut.Write "Error is:" & qtTest.LastRunResults.LastError & vbCr & vbLf ' Check the most recent error
WScript.StdOut.Write "Result path is:" & qtTest.LastRunResults.path & vbCr & vbLf

sRespath = qtTest.LastRunResults.path
sResultsXML = "" & sRespath & "\Report\Results.xml"
sDetailedXSL = "C:\Program Files\HP\QuickTest Professional\dat\PDetails.xsl"
sShortXSL = "C:\Program Files\HP\QuickTest Professional\dat\PShort.xsl"

ApplyXSL sResultsXML, sDetailedXSL, "E:\hudson\workspace\QTP-Hudson\Results_Detailed.html"
ApplyXSL sResultsXML, sShortXSL, "E:\hudson\workspace\QTP-Hudson\Results_Short.html"

Public Function ApplyXSL(ByVal inputXML, ByVal inputXSL, ByVal outputFile)
sXMLLib = "MSXML.DOMDocument"
Set xmlDoc = CreateObject(sXMLLib)
Set xslDoc = CreateObject(sXMLLib)

xmlDoc.async = False
xslDoc.async = False

xslDoc.load inputXSL
xmlDoc.load inputXML

outputText = xmlDoc.transformNode(xslDoc.documentElement)

Set FSO = CreateObject("Scripting.FileSystemObject")

Set outFile = FSO.CreateTextFile(outputFile,True)
outFile.Write outputText

Set outFile = Nothing
Set FSO = Nothing
Set xmlDoc = Nothing
Set xslDoc = Nothing
Set xmlResults = Nothing
End Function

qtTest.Close ' Close the test
qtApp.Quit ' Exit QuickTest
Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object

To be continued …


Leave a comment

How to store and call QTP random function.

This is from google. I cannot find the original link at this time. however, the main purpose is how to call the function, not about the function itself.

So, here is the function which is saved in Resources of Quality Center as nzrandom.qfl.

'Function to Create a Random Number of Any Length
Function nzrandom(LengthOfRandomNumber)

Dim sMaxVal : sMaxVal = ""
Dim iLength : iLength = LengthOfRandomNumber

'Find the maximum value for the given number of digits
For iL = 1 to iLength
sMaxVal = sMaxVal & "9"
sMaxVal = Int(sMaxVal)

'Find Random Value
iTmp = Int((sMaxVal * Rnd) + 1)
'Add Trailing Zeros if required
iLen = Len(iTmp)
nzrandom = iTmp * (10 ^(iLength - iLen))

End Function
'================== End Function =================

So now, if we want to call this function from another script, we need to write it the following way:

LoadFunctionLibrary ("[QualityCenter\Resources] Resources\nzrandom.qfl")
msgbox nzrandom (3)


Leave a comment

How to use Selenium 2 webdriver with new IE Driver

Even though the following information is present in the web, I had to wed through multiple sites in order to get them in one place. Also, it’s not helpful to see that the current version of IE driver would be deprecated until you finish coding and ran your test. So, here it is:

import static org.junit.Assert.*;
import;//We need to put the IE Driver path
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;

public class myfirstTest {

public void startWebDriver(){
//WebDriver driver = new FirefoxDriver();

File file = new File("C:/My Box Files/IEDriverServer_Win32_2.30.2/IEDriverServer.exe");
System.setProperty("", file.getAbsolutePath());
WebDriver driver1 = new InternetExplorerDriver();

//WebDriver driver2 = new ChromeDriver();




//assertEquals("Title", driver1.getTitle());



1 Comment

If you are running Selenium from Eclipse using Maven

Never ever forgot to have the word “Test” in the name of the class file.



Leave a comment

QTP database connectivity and integer comparison

Here’s a quick summary of what happened in last few weeks. Looks like this days I am spending more and more time with QTP and LoadRunner. Looks like, it would be a while before I can write back on the SOA testing. So, here goes.


The scenario was simple. There is a dynamic value in screen which needs to be compared with database. Simple, right. Well, for some reason, things didn’t go exactly as planned.

First, capture the value from database and then capture the value from UI. That didn’t go as planned, because, the value in database only gets generated when user perform some specific tasks in UI. So, first capture the value from UI and then capture the value from DB.

So, here is a pretty straight forward to capture an output from UI.


Browser(“Browser”).Page(“Somesite”).WebEdit(“ssousername”).Set “something”

Browser(“Browser”).Page(“Somesite”).WebEdit(“password”).Set “seomthing”


Browser(“Browser_2”).Window(“somewindow”).Page(“Save Comments”).Output CheckPoint(“adj_out_text “)

Here, comes the first problem. The screen itself is dynamic, and no way we could capture the specific value using text output by defining the text before and text after. It’s all or none. So, instead of capturing ‘1’, we are capturing ‘Value 1 is created’.

Well, nothing that can’t be solved with a bit of string manipulation. So, we did the following like in excel, by using MID.

2. c2=datatable.Value(“adj_out_text”,1)


Now, after we get our value, we need the get the value from database and compare.


Dim strConn

strConn = “Driver= {Microsoft ODBC for Oracle}; ” &_

                  “ConnectString=(DESCRIPTION=” &_

                  “(ADDRESS=(PROTOCOL=TCP)” &_

                  “(HOST=something) (PORT=1521))” &_

                  “(CONNECT_DATA=(SERVICE_NAME=something)));uid=something; pwd=something;”


Dim obConnect

Dim obRecset


Set obConnect =CreateObject(“ADODB.Connection”)

Set obRecset = CreateObject(“ADODB.Recordset”)


sql=”select  * from something”


obRecset.Open sql,strConn

datatable.GetSheet(1).AddParameter “DB_Adj_no”, “”
Do while Not obRecset.EOF





We get the value from dB and stored it in runtime. Though it’s not necessary, just to see in the results table. Now. Go ahead with Micpass.


If c7=c1 Then

                Reporter.ReportEvent micPass,”Values matched”,”Calculated Correctly ” & c1 & ”  = ” & c7


                Reporter.ReportEvent micFail,”Values Did not match”,”Did not calculate correctly ” & c1 & ” != ” &  c7

End If

Not a good result. Out report is showing Micfail, with 1 !=1. That’s weird.

After some head scratching, we thought we found out the reason. The string manipulation is giving us a string in return. We should convert that to a number and that should give us MicPass.





We already checked that the value in DB is number. But, still we are getting Fail. So, we go ahead and converted the DB output into number (integer, to be precise; same as the previous one).






Voila, now it’s all working good. At last, we are getting 1=1.

, , , ,

Leave a comment

How to enable Alt + Tab in citrix remote desktop

It’s been a year since the last post. Time does fly, now I see. Here is quick tidbit that I am using now a days.

HKEY_LOCAL_MACHINE \SOFTWARE\Citrix\ICAClient\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Keyboard\

Value Name: TransparentKeyPassthrough

Type: REG_SZ

Value: FullScreenOnly, Remote, or Local

Remote applies the Windows hotkeys to the window in focus.

Local never applies the Windows hotkeys to the session.

I am using ‘Remote”. Life seems easy.

Edit: 04/14/2011 – Looks like the settings are different for windows 7 64 bit. I will post on that soon.



%d bloggers like this: