Skip to main content


Showing posts from March, 2012

Selenium - HTTP to HTTPS SSL problems

In the daily life of selenium users, the SSL certificate problem is the constant which irritates the testers again and again. Lot of workarounds and solutions are on the way for this problem. Here are some ways that I came across. 1. Use Browser modes In Selenium 1.0 and before, the try to use *chrome and *iehta In Selenium 1.x and later, try to use *firefox and *iexplore Also we can use *firefoxproxy and *iexploreproxy. But this have limitations on no. of instances and multi window modes. 2. Install your application certificates If you have certificates for your SSL layer supported application, the best way is to install that certficate provided by your developers. 3. Install CyberVillains certificates For those who don't have their own security certificates, selenium itself provides some inbuilt certificates in the package called CyberVillains. You can install these certificates to avoid the SSL switching problems. 4. Separate Browser Profiles Create a separate profile by running firefox…

Connect QC from QTP and Execute Scripts

Here is the sample code to connect QC and execute scripts stored in QC using QTP. Dim QTP_App      ' Declare the Application object variable Dim QTP_Test     ' Declare a Test object variable Dim QTP_Results  ' Declare a Run Results Options object variable Dim QC_Path      ' Declare QC Path and assigned actual path ' Create the QTP Application object Set QTP_App = CreateObject("QuickTest.Application") ' Start QuickTest QTP_App.Launch ' Make the QuickTest application visible QTP_App.Visible = True 'Connect to Quality Center QTP_App.TDConnection.Connect QC_Path, False 'Function to open QTPScript and run that script

Regular Expressions - Date, Email

Here are some sample regular expressions for your ref.
Reg Expression for Date:
(0[1-9]|1[012])[//](0[1-9]|[12][0-9]|3[01])[//]200[0-9]$ Reg Expression for Email IDs:
\b[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}\b ((\w+)(\.|\_|\-)(\w+)|(\w+))(\@)(\w+)(\.)(w+)

Java - DataBase Connections

For those who are working in selenium and related automation tools using Java API are in need of connecting back end databases to verify the values. Here is the high level info.
Required package:
import java.sql.*; Code Sample:
//Initializing the driver for JDBC connection Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Creating properties to be passed for connection Properties properties =new Properties(); properties.put("user","shan"); properties.put("password","pass"); properties.put("characterEncoding","ISO-8859-1"); properties.put("useUnicode","true"); //actual connection string String url ="jdbc:mysql://ServerName:port/DataBaseName"; //Getting the connection object using properties and url

Java Collections - Array, ArrayList, HashTable

Array vs ArrayList in Java:
Array - Fixed Size, Same Data Types only
int[] myArr =new int[10]; myArr[0]=10; System.out.println( myArr[0]); System.out.println( myArr.length ); ArrayList - Dynamic Size, Different data types but not primitive types, Synchronized.
ArrayList<String> myList =new ArrayList<String>(); myList.add("abcd"); myList.add(10);//Adds in end of list because index not mentioned. System.out.println( myList.get(0));
//Lot of methods are there here. add(index, Value); addAll(collection); clear()

Make machine unlocked while QTP execution

Lot of guys could have faced this problem and some could able to give some workaround and somebody may still in searching for solution. Here are some ideas you can consider.
Option 1:
1. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest
2. Locate the key SkipEnvironmentChecks
3. Change the value to 1 (Default value is 0)
4. Restart the QTP.
Option 2:
Consider the API developed by Tarun Lalwani.

QTP Rare Tips II

1. Optional Step in QTP
As we know, lot of times we need to check the existence of the object before continuing to the actual operation  on that object. Here is nice option which will reduce these kind of If(obj.Exist) lines like,
OptionalStep.Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select "Paris" Keep in mind that this OptionalStep considers test objcts only. If Object exists, will do the action otherwise will skip the line and continue.

This OptionalStep can be used only with full test object descriptions like above statement.
'This will not work Dim objPage Set objPage = Browser("Mercury Tours").Page("Find Flights") OptionalStep.objPage.WebList("depart").Select"Paris" 'and You can't use inside with statement With Browser("Mercury Tours").Page("Find Flights")   .WebList("depart").Select"Paris" EndWith 'If you want to use inside w…

Run JavaScript from QTP

Yeah, You can run your pure JavaScript from QTP using RunScript method. Lot of times, we are in need of firing events or simulating actions on web page which is not supported by QTP. At that time, you can use your direct DOM methods and directly execute your script on the web page from QTP like,
Dim MyPage, SearchBox Set MyPage = Browser("title:=Google").Page("title:=Google") Set SearchBox = MyPage.RunScript("document.getElementsByName('q')(0);") SearchBox.Value="testing"
'if objects available in frames, Set SearchBox = MyPage.RunScript("document.frames(4).document.getElementsByName('q')(0);")
Set objFrame = Browser("title:=Google").Page("title:=Google").Frame("title:=something")
objFrame.RunScript("document.getElementsByName('q')(0);") Also, you can execute by obtaining actual browser window object if you have IE app like, Dim IEApp Set IEApp = CreateObject("Internet…