Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
UltraTool bar
posted

Hi,

Thanks in advance.

We are using qtp 9 and trying to click on a toolbar button in the ultratoolbar.

We used .NET spy and were able to see some properties like Enabled = true.for all the buttons..

But we are not able to change any value in them.

Is there any way we can click the button in the ultra tool bar.

There are some 8 buttons and we want to clcik on the first button.

We planned to disable the other buttons and keep the first button enabled and use the firevent click in the .net spy for toolbarmanager.

Since we are not able to set the enabled property to false,it is not working for us.

Please help us in this.

Thanks,

Kala

Parents
  • 7695
    Offline posted

    Hi Kala, 

      While Mercury's QuickTest Professional(QTP) does expose the Object model such that you can manipulate an object if it is absolutely required, it is highly recommended if you need to set a property that we do not explicitly expose through our proxy for QTP, you should have your developer expose a means to manipulate it. 

       This also coincides with the general practices and expectations of testing products such as QTP that tests the User Interaction (UI) layer of your application. Which is if the state you are trying to test is not attainable via the UI, then there would be no reason to test that state with a UI testing tool. 

      That being said, it is possible to both access and set public properties of an object through the use of QTP. It will require knowledge of both our NetAdvantage object model, as well as information about the internals of your applications Tool structure, and likely a lot of trial an error testing as there will be no intellisense and QTP is not forgiving. Also to my knowledge, and I could be wrong as this is more about QTP's internal specifics that I am not an expert on, but QTP does not appear to offer a means to access indexed properties directly such as in the case of Tools[0].Key. But most of our collection objects offer methods to allow you to work around this limitation. 

      For our object model, I can direct you to our Online Help, which should get your through most of the hurdles.   

    So a script similar to this would be able to set a tool's Enabled property to false:

    Dim cToolbars        ' Collection of Toolbars
    Dim oMyTool ' MyTool Object

    set cToolbars = SwfWindow("Form1").SwfToolbar("_Form1_Toolbars_Dock_Area_Top").Object.ToolbarsManager.Toolbars
    Set oMyTool = GetToolFromToolbar(cToolbars,"MyToolbar", "MyTool")

    oMyTool.SharedProps.Enabled = false


    Function GetToolFromToolbar(byref cToolbars, sToolbarKey, sToolKey)
        Dim oToolbar   ' Toolbar object
        Dim bToolbarFound
        Dim bToolFound
        
        bToolbarFound = false
        bToolFound = false
        
        For x = 0 to cToolbars.Count - 1
            If sToolbarKey = cToolbars.GetItem(x).Key Then
                set oToolbar = cToolbars.GetItem(x)
                bToolbarFound = true
                Exit for
            End If
        Next

        If bToolbarFound = true Then    
            For x = 0 to oToolbar.Tools.Count - 1
                If sToolKey = oToolbar.Tools.GetItem(x).Key Then
                    Set GetToolFromToolbar = oToolbar.Tools.GetItem(x)
                    bToolFound = true
                    Exit for
                End If
            Next
            
            If bToolFound = false Then
                Reporter.ReportEvent micFail, "Tool Not Found","Tool [" + sToolKey + "] not found in the Toolbar [" + sToolbarKey + "]"
            End If
        Else
            Reporter.ReportEvent micFail, "Toolbar Not Found", "Toolbar ["+sToolbarKey + "] not found in the collection supplied"
        End If
    End Function
Reply Children