Tuesday, October 15, 2013

QTP / UFT - Manually unlock test

Pretty useful:

1) Have everyone close their QTP / UFT scripts and log out of the project
2) Log into site admin, expand the project, and select the locks table. If any records appear in the locks table, run the
following SQL query in the text box above the results.
DELETE FROM LOCKS WHERE LK_USER = 'username' AND 
LK_OBJECT_TYPE = 'TEST' 
a. Note: username needs to be replaced with a username in the LK_USER column from the results above.
3) Users should now be able to log back into the project and access the QTP / UFT scripts.

Source:

Monday, October 14, 2013

UFT (QTP) - Find Element by Properties

If you need to find a specific element with UFT (QTP) here is something to try:
Note: you can choose what properites to use:

Function GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
    Dim Desc
    Set Desc = Description.Create()
    Desc("micclass").Value = MicClass
    Desc("innertext").Value = Innertext
    Desc("html tag").Value = HTMLTag
    Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function

Function FindMyObject(Page, MicClass, Innertext, HTMLTag)
    Select Case MicClass
                Case  "WebButton"      
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case  "WebElement"
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case  "Image"
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case  "Link"
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case  "Static"
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case  "WebEdit"
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case  "WebList"
                        Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)  
                Case Else
                        myReport micFail, "An object of type """ & MicClass & """ could not be found!"
                        ExitIfError
    End Select
End Function

'Function call example
FindMyObject(Browser("Browser_Local").Page("Page"), "WebElement""ObjectToBeFoundInnertext""STRONG")(0).Click