WORKING WITH QTP

TestEveryThinG

Archive for the ‘Miscellaneous’ Category

Available Android app of Testeverything Site

Posted by rajivkumarnandvani on July 26, 2016

Hi,

Now you view the TestEverything Site updates on your Android mobile.just download the android app

Please refer the below link to download the apk file of  Teverything Site.

https://drive.google.com/file/d/0B27kZ9NQHijSQnJtc1RYdGVyR2M/view?usp=sharing

Download TesteveryThing APK file
TesteveryThing APK

Posted in Automation, DATABASE, FAQ QTP, Jenkins, JMETER, Miscellaneous, QTP, QTP FAQ, SELENIUM, WEB, WEBDRIVER, WINDOWS | Tagged: , , , | Leave a Comment »

Convert HTML text to Simple text VB Script

Posted by rajivkumarnandvani on November 6, 2009

Hi All,

Some time we required HTML text change to simple text here i created a function which will convert your HTML text to simple readable text.

‘ *************************************************************************************
‘ Function Name:    ConvertHTMLtoText
‘ Description:        This function is used to convert HTML string to Simple Text
‘ Arguments:        HTML string

‘ Return Value:        SimpleText
‘‘Syntax of calling the defined function:    Call  ConvertHTMLtoText(strHTML)
‘ *************************************************************************************

Public Function ConvertHTMLtoText(byVal strHTML)
If InStr(1,strHTML,”<“) > 0 Then
Do
startVariable = InStr(1,strHTML,”<“)

endVariable = InStr(startVariable,strHTML,”>”)
varName = Mid(strHTML,startVariable, endVariable-startVariable+1)
strHTML = replace(strHTML,varName,””)
Loop While InStr(1,strHTML,”<“) > 0
End If
strHTML = replace(strHTML,”&gt;”,””)
strHTML = replace(strHTML,”&lt;”,””)
ConvertHTMLtoText = strHTML
End Function

msgbox ConvertHTMLtoText(“<br><br><font color=””””#008000″”””>TestingGUID position 26 with dashes must be one of the following: AB234567</font></body></html>”)

Posted in Miscellaneous | Leave a Comment »

Create ZiP file VB QTP / UnZip file VB QTP

Posted by rajivkumarnandvani on May 13, 2009

Function WindowsUnZip(sUnzipFileName, sUnzipDestination)
Set oUnzipFSO = CreateObject(“Scripting.FileSystemObject”)
If Not oUnzipFSO.FolderExists(sUnzipDestination) Then
oUnzipFSO.CreateFolder(sUnzipDestination)
End If
With CreateObject(“Shell.Application”)
.NameSpace(sUnzipDestination).Copyhere .NameSpace(sUnzipFileName).Items
End With

Set oUnzipFSO = Nothing
End Function
Function WindowsZip(sFile, sZipFile)

Set oZipShell = CreateObject(“WScript.Shell”)
Set oZipFSO = CreateObject(“Scripting.FileSystemObject”)

If Not oZipFSO.FileExists(sZipFile) Then
NewZip(sZipFile)
End If

Set oZipApp = CreateObject(“Shell.Application”)

sZipFileCount = oZipApp.NameSpace(sZipFile).items.Count

aFileName = Split(sFile, “\”)
sFileName = (aFileName(Ubound(aFileName)))

‘listfiles
sDupe = False
For Each sFileNameInZip In oZipApp.NameSpace(sZipFile).items
If LCase(sFileName) = LCase(sFileNameInZip) Then
sDupe = True
Exit For
End If
Next

If Not sDupe Then
oZipApp.NameSpace(sZipFile).Copyhere sFile

‘Keep script waiting until Compressing is done
On Error Resume Next
sLoop = 0
Do Until sZipFileCount < oZipApp.NameSpace(sZipFile).Items.Count
Wscript.Sleep(100)
sLoop = sLoop + 1
Loop
On Error GoTo 0
End If
End Function

Sub NewZip(sNewZip)
Set oNewZipFSO = CreateObject(“Scripting.FileSystemObject”)
Set oNewZipFile = oNewZipFSO.CreateTextFile(sNewZip)

oNewZipFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)

oNewZipFile.Close
Set oNewZipFSO = Nothing

Wscript.Sleep(500)
End Sub

WindowsZip “c:\rajiv.htm”, “c:\rajiv.zip”

Posted in Miscellaneous | Tagged: , , | 15 Comments »

Running DOS Commands QTP VB

Posted by rajivkumarnandvani on May 3, 2009

Running DOS Commands

You can run standard DOS commands in your QuickTest test or function using the VBScript Windows Scripting Host Shell object (WSCript.shell). For example, you can open a DOS command window, change the path to C:\, and run the DIR command using the following statements:

Dim oShell

Set oShell = CreateObject (“WSCript.shell”)

oShell.run “cmd /K CD C:\ & Dir”

Set oShell = Nothing

Posted in Miscellaneous, QTP | Tagged: , , , | Leave a Comment »

Importance of Parenthes when we call Function or Sub QTP

Posted by rajivkumarnandvani on May 3, 2009

Whenever you define a function with using argument always define the argument type by using ByVal OR ByRef Because if u not define the argument type by default it take ByRef

Parenthesis matter in QTP (and VBScript). And they surely make a difference. During debugging a function call. There was different behaviour between these two function calls:
foo(bar)
call foo(bar)
Passing an argument to a function surrounded by parenthesis means: “Protect me” or in other words: treat me as byVal even if it is defined in the function as byRef.

Example:
sub samplesub (a, b) ‘ a and b are by default handled as byRef
a = a + b
end sub

And this is happening when we call samplesub:
x = 1
y = 2
z = 4
samplesub x, y
samplesub (z), y
msgbox x ‘ displays “3”
msgbox z ‘ displays “4” because z was passed as if it was passed byVal

The same applies when you call a function:

function samplefunc(c)
c = c^2-1
samplefunc = (c mod 2 = 1)
end function

q = 8
samplefunc q
msgbox q ‘ returns 63

‘ When you accidentally forgot to call:
p = 9
samplefunc(p)
msgbox p ‘ returns 9, because p is returned byVal

‘ With call:
r = 10
call samplefunc(r)
msgbox r ‘ returns 99, because r is returned byRef

‘ With call and argument protected:
s = 11
call samplefunc( (s) )
msgbox s ‘ returns 11, s is returned byVal

‘ And a last example of a function call with multiple argument with combined protection:
call multifunc( (IamProtected), IamUnprotected )

Rules in short:
A sub/function call with an argument in protected mode overrides a byRef in the function.
A sub/function call with an argument in unprotected mode is returned byRef by default unless it is overridden in the function by a byVal.
An literal or const is always returned byVal.

Syntax proposal:
OK, it is ugly, but if you use parenthesis because they are part of the call, you should use them with spaces between the first and last argument and no space between the function:

call f( a, b )

If you want to use arguments in protected mode, you should use no spaces between the parenthesis and the arguments, but do use them between the function/sub and the parenthesis belonging to the function/sub call:

f (a), (b)
or
call f( (a), (b) )

Posted in Miscellaneous, QTP | Tagged: , , , , | Leave a Comment »

Performance increase in table lookup functions QTP

Posted by rajivkumarnandvani on May 3, 2009

Using object properties instead of QTP standard functions will improve the performance of QTP tests significantly. In our case, we often want to lookup the location of a certain value in a WebTable. QTP provides several functions to read out data from a table, but is slow when used iterating the table (like two for loops, one iterating the rows, the embedded second one iterating the columns per row).

Example of a conservative way to do this:

Public Function LocateTextInTable(byRef tbl, textToFind, byRef row, byRef col)

For row = 1 to tbl.RowCount
For col = 1 to tbl.ColCount
If tbl.GetCellData(row, col) = textToFind then
LocateTextInTable = True
Exit function
End if
Next
Next

row = -1 : col = -1
LocateTextInTable = False
End Function

The crux is this: .GetCellData is not a very fast method and with a table, consisting of 30 rows and 10 columns, this method is iterated up to 300 times in the most worse case scenario (= text not found).

A faster way to retrieve the data is through the Document Object Model (DOM). This allows you to use the more native properties of an object with the sacrifice of some ease of use.

A table consists of row elements and each row element contains one or more cells. We can iterate them just the same way as we did with the function above:

Public Function LocateTextInTableDOM(byRef tbl, textToFind, byRef row, byRef col)

Dim objRow, objCell

row = 1 : col = 1

For each objRow in tbl.object.Rows
For each objCol in objRow.Cells
If objCol.Value = textToFind then
LocateTextInTableDOM = True
Exit function
End if
col = col + 1
Next
row = row + 1
Next

row = -1 : col = -1
LocateTextInTableDOM = False
End Function

Posted in Miscellaneous, QTP | Tagged: , , , | 3 Comments »

Work With text box( Windows WinEdit box) QTP

Posted by rajivkumarnandvani on May 3, 2009

In most cases, double-clicking on a data input field is the preferable method of selection; furthermore, it is usually necessary versus a single mouse click on the object. Double –clicking selects the all of the data in that field so that it can be replaced with the new data. A single- click operation, may only place the cursor in the input control , selecting none of the existing data and normally activates the insert mode . Not good. The existing data is not replaced with the new value. In some applications where multiple words or value separated by spaces can lives in a single edit box. We have found the even double-clicking may not get all of the text selected and ready for replacement. In this case, the method that consistently ensures that all of the data is selected is this: navigate to control via keyboard control, such as tabbing, right arrow or mouse click. Once the cursor is placed into the control, record these keystrokes:

Ctrl + Home
Ctrl + Shift + End
Delete

Like
Dialog(“Login”).WinEdit(“Agent Name:”).Type micCtrlDwn + micHome + micCtrlUp
Dialog(“Login”).WinEdit(“Agent Name:”).Type micCtrlDwn + micShiftDwn + micEnd + micShiftUp + micCtrlUp

Posted in Miscellaneous, QTP, WINDOWS | Tagged: , | Leave a Comment »

FIND CELL Value in EXCEL VB

Posted by rajivkumarnandvani on April 25, 2009

Some Time we have to Check that particular Cell Value Exist or Not and required the Cell address
rem this function return the first  find Cell address  value of your Excel sheet  & Change Color of Cell find value
rem input parameter xlFilePath := xls file path || FindValue =value which need to be find

dim sXLpath , FindValue ,getCellAddress
sXLpath =”C:\RajivKumarNandvani.xls” rem define xls file path
FindValue =”Rajiv” rem check rajiv in cell exist or not
getCellAddress = FindCellAddress(sXLpath ,FindValue )
msgbox getCellAddress

Public function  FindCellAddress(Byval  xlFilePath ,byval FindValue )

Set ObjAppExcel = CreateObject(“Excel.Application”)
rem Disable alerts
ObjAppExcel.DisplayAlerts = False
r
em Add a workbook to the Excel App
ObjAppExcel.Workbooks.open(xlFilePath)
REm Get the object of the first sheet in the workbook
Set objectSheet = ObjAppExcel.Sheets(“Sheet1”)
rem define the range from A1 to last column address and filnd the value in range
set objValueFind = objectSheet.UsedRange.Find(FindValue)
If not objValueFind is nothing Then
CellAddress =objValueFind.address
FindCellAddress=replace(objValueFind.address,”$”,””)
FindCellAddress=replace( FindCellAddress,”1″,””)

Do

set objValueFind = objectSheet.UsedRange.FindNext(objValueFind )

Loop While Not objValueFind Is Nothing And objValueFind.Address <> CellAddress

Exit function

End If
rem if not found then return the Empty
FindCellAddress=”NOT FOUND”

Set objValueFind =nothing
Set objectSheet =nothing
Set ObjAppExcel =nothing
End Function

Posted in Miscellaneous, QTP | Tagged: , , , , | 3 Comments »

Get Column Address Excel VB / Find Column

Posted by rajivkumarnandvani on April 25, 2009

Some Time we have to Check that particular column Exist or Not abd required the column address
rem this function return the column address of your Excel sheet
rem input parameter xlFilePath := xls file path || FindColumn =column value which need to be check

dim sXLpath , FindColumn ,getColumnAddress
sXLpath =”C:\RajivKumarNandvani.xls” rem define xls file path
FindColumn =”Rajiv” rem check rajiv in column exist or not
getColumnAddress = FindColumnAddress(sXLpath ,FindColumn )
msgbox getColumnAddress
Public function FindColumnAddress(Byval xlFilePath ,byval FindColumn )

Set ObjAppExcel = CreateObject(“Excel.Application”)
rem Disable alerts
ObjAppExcel.DisplayAlerts = False
rem Add a workbook to the Excel App
ObjAppExcel.Workbooks.open(xlFilePath)
‘Get the object of the first sheet in the workbook
Set objectSheet = ObjAppExcel.Sheets(“Sheet1”)
rem count used Column in sheet
nColumnCount =objectSheet.UsedRange.Columns.Count
rem get the last column address
c =replace(objectSheet.Cells(1,nColumnCount).address,”$”,””)
rem define the range from A1 to last column address and filnd the value in range
set objValueFind = objectSheet.Range(“A1:”&c).Find(FindColumn)
If not objValueFind is nothing Then
FindColumnAddress =replace(objValueFind.address,”$”,””)
FindColumnAddress =replace(FindColumnAddress,”1″,””)
Exit function

End If
rem if not found then return the Empty
FindColumnAddress =”NOT FOUND”

Set objValueFind =nothing
Set objectSheet =nothing
Set ObjAppExcel =nothing
End Function

Posted in Miscellaneous, QTP | Tagged: , , , | Leave a Comment »

 
%d bloggers like this: