Showing posts with label QTP. Show all posts
Showing posts with label QTP. Show all posts

Wednesday, October 8, 2014

How to know if Reporter Fail has been logged

How to know if Reporter Fail has been logged



Declare a variable at the start of the vbs file (it should be outside all the function ie., global). And assign a value "true". In case of error insert "false" into it so that it can be visible when you are in different function.

Monday, July 21, 2014

QTP : Open different browsers

Open different browsers




SystemUtil.Run "iexplore.exe" ,"url"
SystemUtil.Run "firefox.exe" ,"url"
SystemUtil.Run "chrome.exe" ,"url"

Sunday, July 6, 2014

QTP : Important operations

QTP : Important operations





DATASHEET:


GLOBAL SHEET
A
B
C



3





1







LOCAL SHEET
A
B
C



a





b





c






To : Fetch only those cells from localsheet which  has been mentioned in Global sheet .ie., fetch only 3 and 1 cell in the same order from local sheet .
Output: ca
 
rowcount = DataTable.GetSheet("Global").GetRowCount  
for i=1 to rowcount step 1
DataTable.GetSheet("Global").SetCurrentRow(i)      
val=DataTable.Value("A","Global")                              '
DataTable.GetSheet("Local").SetCurrentRow(val)
msgbox (DataTable.Value("A","Local")
next

WEBTABLE
r=Browser("Google").Page("title:=.*").WebTable(“name:= TTable").RowCount 
c=Browser("Google").Page("title:=.*").WebTable(“name:=TTable").ColumnCount(r)
strData= Browser("Google").Page("title:=.*").WebTable(“name:=TTable").GetCellData(1,1)
Set ChldItm = Browser("Google").Page("title:=.*").WebTable(“name:=TestTable,"index:=0").ChildItem(1,1,"micclass",index)

if(ChldItm .GetRoproperty("micclass")<>"Page") then
.....
....
end if

EXCEL:
Set xl = createobject("excel.application")
xl.Visible = True
Set Wb= xl.Workbooks.Open("C:\qtp1.xls")
Set  ws=Wb.Worksheets("Sheet1")
Row=ws.UsedRange.Rows.Count

data = ws.cells(1,1).value

wb.saveas" "
wb.save
wb.close
xl.quit

DATABASE
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")

con.open"Driver={SQL Server};server=MySqlServer;uid=MyUserName;pwd=MyPassword;database=pubs"
rs.open "select * from emp",con

Do while not rs.eof
VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")
VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")
VbWindow("Form1").VbButton("ADD").Click
rs.movenext
Loop

'Release objects'Release objects
Set rs= nothing
Set con= nothing

FILES , FOLDERS
Set fso=createobject("Scripting.FileSystemObject")

Set ctrl__folder=fso.GetFolder(Sourcefolder)
Set  sub_folder=get_folder.SubFolders
Set  sub_files =get_folder.Files

for each i in sub_folder
               sub_folder.name
next

TEXT FILE
Set txt=fso.CreateTextFile("C:\qtptest.txt")
Set ctrl_file=fso.getfile("C:\qtptest.txt")
Set txt_file=ctrl.openastextstream(1)

Do while txt_file.AtEndOfStream <> true
Msgbox  txt_file.ReadLine 
Loop
----------------------------------------------------------------------------
·        mid("ABC",1,2)     'answer=AB
·        instr(1,"ABC","B") 'answer=2
·        len("ABC")     'answer=3
·        ubound(a,2)   ' a(2)(3) ---answer=3

Friday, September 13, 2013

Wednesday, June 12, 2013

QTP : DataTables

QTP : DataTables
 
 
 
'Note in QTP  COLUMNS ARE CALLED AS "PARAMETERS "
 
'Setting Row to be operated
'----------------------------------------------------------------------------------
datatable.GetSheet("Global").SetCurrentRow 1
'----------------------------------------------------------------------------------                                                                                                              
 
 
'Write Data into a cell
'----------------------------------------------------------------------------------
datatable.GetSheet("Global").AddParameter "A","Hi" 
datatable.GetSheet("Global").AddParameter "B","Bye"                              
'----------------------------------------------------------------------------------
 
 
'Read Data into a cell
'----------------------------------------------------------------------------------
msgbox  datatable.GetSheet("Global").GetParameter ("A").Value                 
msgbox  datatable.GetSheet("Global").GetParameter ("B").Value
'----------------------------------------------------------------------------------
 
 
'Read Columns and Rows
''----------------------------------------------------------------------------------
msgbox "Row Count ="&datatable.GetSheet("Global").GetRowCount 
msgbox "Column Count ="&datatable.GetSheet("Global").GetParameterCount                              
'----------------------------------------------------------------------------------
 
 
'Display                Column name
'----------------------------------------------------------------------------------
msgbox "Column 1 Name="&  datatable.GetSheet("Global").GetParameter (1).Name 
'----------------------------------------------------------------------------------
 
 
'Number of Actions or Datatables
'----------------------------------------------------------------------------------
Msgbox "No of Actions ="&Datatable.GetSheetCount-1                       
'----------------------------------------------------------------------------------
 
 
'Add New Column
'----------------------------------------------------------------------------------
datatable.GetSheet("Global").AddParameter "xyz",""
'----------------------------------------------------------------------------------

'Datatable in Actions
'----------------------------------------------------------------------------------
RunAction "Action1",oneIteration,Datatable("A","Global")   'A=> 1-2
'----------------------------------------------------------------------------------



Saturday, May 11, 2013

QTP : Excel As DataBase

 Excel As DataBase


Create an excel book in "c:\1.xlsx" and  name any sheet as "Sheet1" (Default name). In  Sheet 1 , the 1st row is the column names , the rest of the rows forms the data .


CODE BELOW:

Dim objCon, objRecordSet, strExlFile, colCount, row, i

Set objCon = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

sPath="c:\1.xlsx"
sSheetname="Sheet1"

objCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="& sPath &";Extended Properties=Excel 12.0;Persist Security Info=False"
strSQLStatement = "SELECT * FROM ["& sSheetname &"$]"

objRecordSet.Open strSQLStatement, objCon 'create recordset
colCount = objRecordSet.Fields.count 'Number of columns in the table

While objRecordSet.EOF=false
row=""
For i=0 to colCount-1
row=row &" "& objRecordSet.fields(i)
Next
'Print row 'If you are running this in Qtp you can uncomment this line
msgbox row
objRecordSet.moveNext
Wend

Set objRecordSet = Nothing
objCon.Close
Set objCon = Nothing

Friday, May 10, 2013

Qtp 11 not identifying .NetObjects

Qtp 11 not identifying .NetObjects


Our app was upgraded from existing Infragistics 2009.1 to 12.2 . We needed to make sure app had no bugs after upgrade.Therefore our automation Framework needed to keep up with that.


Here is following upgrades on App
1.Upgrading from 32Bit to  64 Bit
2.Upgrading to Xp sp 3 to 7
3.Upgrading Dot Net FW 3.5 to 4
4.Upgrading to Net Advantage 12.2

Simultaneous Qtp upgrades needed for automation
1. DotNetFW 4.0 which our new app uses does not support our existing Qtp 10 we need 11 or above.
2. Since Dev Team will be getting Infragistics Net Advantage 12.2 , I suggested we must be equipped with Test adv 12.2

Download QTP 11.0 Link
http://www8.hp.com/us/en/software-solutions/software.html?compURI=1172957#
Click on > Trials and Demos >Select Hp QTP Essentials 11.0 English Evaluation (Web Gui testing only)

During my analysis these are the following findings :

1.  Qtp 11.5 or Unified Functional Testing Tool 11.5 is only compatible with ALM (App LifeCycle Managment )   10 or above . Meaning if you are using QC  you are screwed.
2.  Test Advantage 12.2 requires at-least Qtp (Uft) 11 or above.
3. Unlike Qp 11.5 , Qtp 11 is compatible with both QC and Alm.

Sl no
Environment
Vxxxx64xxxx
Dxxxx32
Axxxxxx32
Vxxxx64_2
1
Machine Type
64 Bit
32 Bit
32 Bit
64 Bit
2
Operating System
64 bit  Xp
Xp
Xp
64 Bit Xp
3
Dot Net Framework Version
·         MS Dot Net Framework 2.0
·         MS Dot Net Framework 3.0
·         MS Dot Net Framework 3.5
·         MS Dot Net Framework Full 4.0
Same
Same
Same
4
QTP Version
Qtp 11 Demo
Qtp 11 Demo
Qtp 11 Demo
Qtp 11 Demo
5
Net Advantage Version
12.2
12.2
12.2
12.2
6
Test Advantage
No
12.2  Demo
12.2 Demo
No
7
Object Identification For Current app ( 3.0 ) using  QTP 11.0
Yes
Yes
Yes
Yes
8
Object Identification For New app (1.0)  using QTP 11.0
No
Yes
Yes
No
















Now I chose Qtp 11 as we had our scripts integrated with QC.But  Qtp 11.0 was not able to recognize any objects on the application .

After slogging for 3 days , here are the solutions :-)

Solution 1 :
 
1.Install Qtp 11 , along with dot Net addins (at the start of qtp installation  , installer asks whether to install  .net addin)
2. Install Infragistics Test advantage 12.2 (Demo is free of cost ). (Doing this  triggers the part of Qtp brain which handles DotNet to start working).You can disable infragistics(Desktop>Start>Infragistics) in version settings.
3.Once you have installed go to/ Documents and Settings and search for "Sample" , infragistics provides you with sample DotNet app to test .Try working on it .Qtp should be able to recognize , now start testing on your app.


Solution 2:
1.Install Patch QTP_00699
2.Here unpacking takes more time and looks similar to installation and sometimes installation will overlap unpacking.If is asks "Another installation is in process do you want to continue " Press Yes. I had mistaken this part and paid huge price.
3.Install Patch QTP_00709. (Your qtp will start to identify objects as Winobjects in record mode )
4.Install Patch Qtpnet_0051

Now your Qtp should be able to record objects in good old  " Swf " fashion .


Note :All the patches mentioned above comes with QTP 11 ,yeah that's right even with Demo version.