Sunday, 18 August 2013

How to Get Names of All Open Browsers

Set b = Description.Create()
b(“application version”).Value = “internet explorer 6″
Set bC = DeskTop.ChildObjects(b)
Cnt = bC.Count
MsgBox “There are total: ” & Cnt & ” browsers opened”
For i = 0 To (Cnt -1)
MsgBox “Browser : “&i&” has title: “& bC(i).GetROProperty(“title”)
Next
Set b = Nothing
Set b = Nothing

Introduction of GetROProperty

GetROProperty allows us to get the current value of a test object property. This requires the test object’s corresponding runtime object to exist. QTP will touch the runtime object, and retrieve the value of the property from it.
For example, if the text of the Notepad window changed from when that object was recorded, this command will retrieve the updated value:
Msgbox Window(”Notepad”).GetROProperty(”text”)

Code to determine that the first character is upper- or lowercase and whether it’s alphabetic or numeric

Function CheckText (sText)
Dim nChar
If Len(sText) > 0 Then
nChar = Asc(sText) – Asc
If nChar >= 65 And nChar = 97 And nChar <= 122 Then
CheckText = "The first character is lowercase"
Else
CheckText = "The first character isn't alphabetical"
End If
Else
CheckText = "Please enter something in the text box"
End If
End Function

Use Chr(34) to Embed Quotation Marks Inside a String

sSQL = “SELECT * FROM tbl WHERE myCol=” & Chr(34) & sValue & Chr(34)
‘Chr() functions returns the character associated with an ANSI character code.

'Code to Run Script at Specified Time 6.00 PM

Paste below written code at the beginning of script & run your script
strTime=hour(Now)
Do while strTime”6″
strTime=hour(Now)
wait(1800)
Loop