Wednesday, 19 October 2011
QTP Script: Write a value to the Registry
21:19
7 comments
' ============================================================= ' Sub : RegistryWrite ' desc : Writes a key value to the registry ' params : strRoot is the root key, i.e. "HKLM", "HKCU" ' strPath is the path to create, i.e. ' "Software\Test\Automation" ' strValue is the value to write in the key ' returns : void ' =============================================================...
QTP: Example of how to write text to a file
21:19
No comments
' ============================================================= ' function: WriteLog ' desc : Writes a message to a log file. File is created ' inside a Log folder of the current directory ' params : strCode is a code to prefix the message with ' strMessage is the message to add to the file ' returns : void ' ============================================================= Function WriteLog(strCode, strMessage)...
QTP Script: Using Description Objects to interact with a web page
21:18
No comments
This example will illustrate how to use description objects to interact with a web page, www.QTPHelper.com to be more exact... Note that for the Browser and Page I've used programmatic descriptions, but for the buttons, edits and check-boxes I've used Description Objects. Also take note of the regular expression in the Browser and Page description, just in case the titles change in the future. You can add more properties to your description objects if you need to, i.e. if your web page has numerous objects of the same type with similar...
QTP Script: Using the replace method to find and replace text in a string
21:17
1 comment
MsgBox ReplaceText("Automating with QTP is rubbish.", "rubbish.", "great!") MsgBox ReplaceText("QTP is a great automation tool but I can't use it","but.*","!") ' ============================================================= ' function: ReplaceText ' desc : Uses a regular expression to replace text within a string ' params : strString is the string to perform the replacement on ' strPattern is the regular expression ' ...
QTP Script: Register a procedure with an object class
21:16
No comments
' add GetItemsCount as a method of the WebList class RegisterUserFunc "WebList", "GetItemsCount", "GetItemsCountFunction" ' ============================================================= ' function : GetItemsCountFunction ' desc : Returns the number of items from a weblist ' ============================================================= Function GetItemsCountFunction(objWebList) If (objWebList = Nothing) Then GetItemsCount = 0 Else GetItemsCount = objWebList.GetROProperty("Items...
QTP Script: Read a value from a key in the registry
21:15
No comments
' ============================================================= ' function : RegistryRead ' desc : Read a value from the registry ' params : strRoot is the root key, i.e. "HKLM", "HKCU" ' strPath is the path to read, i.e. ' "Software\Test\Automation" ' returns : Value from the registry key ' ============================================================= Function RegistryRead(strRoot, strPath)...
Subscribe to:
Posts (Atom)