Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get identification property from object when object doesn't exist on page
#2
Not Solved
'The following example retrieves an object repository's objects and properties,
'looks for specific test objects using several methods, and copies a test object
'to another object repository.

Code:
Dim ImageObj, PageObj, RepositoryFrom, RepositoryTo

Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
Set RepositoryTo = CreateObject("Mercury.ObjectRepositoryUtil")

RepositoryFrom.Load "C:\QuickTest\Tests\Flights.tsr"
RepositoryTo.Load "E:\Temp\Tests\Default.tsr"
Function EnumerateAllChildProperties(Root)
'The following function recursively enumerates all the test objects directly under
'a specified parent object. For each test object, a message box opens containing the
'test object's name, properties, and property values.
Code:
Dim TOCollection, TestObject, PropertiesCollection, Property, Msg

    Set TOCollection = RepositoryFrom.GetChildren(Root)

    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
            Set PropertiesCollection = TestObject.GetTOProperties()

            For n = 0 To PropertiesCollection.Count - 1
                Set Property = PropertiesCollection.Item(n)
                Msg = Msg & Property.Name & "-" & Property.Value & vbNewLine
            Next
            MsgBox Msg

EnumerateAllChildProperties TestObject
    Next

End Function

Function EnumerateAllObjectsProperties(Root)
'The following function enumerates all the test objects under a specified object.
'For each test object, a message box opens containing the test object's name,
'properties, and property values.
Code:
Dim TOCollection, TestObject, PropertiesCollection, Property, Msg

    Set TOCollection = RepositoryFrom.GetAllObjects(Root)

    For i = 0 To TOCollection.Count - 1
        Set TestObject = TOCollection.Item(i)
                    Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine

            Set PropertiesCollection = TestObject.GetTOProperties()
            For n = 0 To PropertiesCollection.Count - 1
                Set Property = PropertiesCollection.Item(n)
                Msg = Property.Name & "-" & Property.Value & vbNewLine
            Next

        MsgBox Msg
    Next

End Function

Function RenameAllImages(Root)
'The following function sets a new name for all image test objects under a specified object.
Code:
Dim TOCollection, TestObject, PropertiesCollection, Property

    Set TOCollection = RepositoryTo.GetAllObjectsByClass("Image")

    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            RepositoryTo.RenameObject (TestObject, "Image " & i)
            RepositoryTo.UpdateObject TestObject
    Next

End Function

Function RemoveAllLinks(Root)
'The following function recursively enumerates all the test objects under a specified object.
'It looks for all test objects of class Link and removes them from their parent objects.
Code:
Dim TOCollection, TestObject, PropertiesCollection, Property

    Set TOCollection = RepositoryFrom.GetChildren(Root)

    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            TOClass = TestObject.GetTOProperty("micclass")

         If TOClass = "Link" Then
                RepositoryFrom.RemoveObject Root, TestObject
            End If

        EnumerateAllChildProperties TestObject
    Next

End Function
Reply


Messages In This Thread
RE: Get identification property from object when object doesn't exist on page - by vinod123 - 03-07-2012, 05:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  File Chooser on Chrome doesn't work - UFT 15.0.1 Nenna Rosa 1 3,697 10-31-2020, 01:16 PM
Last Post: Ankur
  Enabling Smart Identification for SAP Gui object prasanna.kale5@gmail.com 0 967 12-05-2019, 08:04 PM
Last Post: prasanna.kale5@gmail.com
  Exist and Visible Are True When Objects Aren't There - Is there A Better Way? zunebuggy 3 3,202 04-24-2018, 02:12 PM
Last Post: Ankur
  Time Delay issue with Exist mv8167 11 24,917 06-19-2017, 02:56 PM
Last Post: grosorg
  Object identification is taking too much time JACKSPARROW 0 1,712 01-17-2017, 11:08 AM
Last Post: JACKSPARROW

Forum Jump:


Users browsing this thread: 2 Guest(s)