Ask a Question

Unable to find DotNetBar control

asu
New Contributor

Unable to find DotNetBar control

We are using DotNetbar controls from here: http://www.devcomponents.com/dotnetbar/download.aspx 

Our application is using ribbon controls from the package.

The ribbon controls have the next hieararchy

-RibbonControl

  --RibbonPanel

    --RibbonBar

      --ItemContainer

        --Buttons and other simple controls



My problem is that TestComplete doesn't see ItemContainer control and anything below it. The buttons on it are not searchable by Find\FindChildren methods.



Controls.Count property of RibbonBar always returns 0.



Is there a workaround to this issue?


6 REPLIES 6

Hi Olexandr,



We've reproduced the behavior here and currently we are investigating the issue.



As a workaround, you can try setting the Depth parameter of the Find (FindChild) method to 1. This approach works fine on our side. Please see the Find Method article for details.



If the suggestion does not help, please zip the entire project suite folder along with the test execution logs and send us the archive.



Also, you can vote for the control in this survey.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
asu
New Contributor

Hi David,



Thank you for your reply.

What property(ies) and value(s) did you use to find ItemContainer using Find method?



BR,

Olexandr

Hi,



Actually, we did not find a way to find the ItemContainer object. It is not displayed in the OB and cannot be located from script. However, we succeeded to find the buttons in the container. We used the Text property to locate the buttons.



Please note that for our sample application, the child objects of the target ItemContainer control are displayed in the OB. If the behavior is different on your side, please send us a sample application demonstrating the issue. Also, please send us your project. You can get in touch with us via the Contact Support web form.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
asu
New Contributor

Please find a sample application in attachment.

Here is the script I tried to find the button and it didn't work for me:



Dim PropArray, ValuesArray


Dim RibbonBar


Set RibbonBar= Sys.Process("SampleDNB").WinFormsObject("Form1").WinFormsObject("MainRibbon").WinFormsObject("OrganizationRibbonPanel").WinFormsObject("OrganizationCreateBar")


Dim Button


PropArray = Array("Text")


ValuesArray = Array("Test1")


Set Button=RibbonBar.Find(PropArray,ValuesArray,1)


Log.Message Button.Exists

Hi Olexandr,


Thank you for the sample.


I suggest that you work with the target controls via their native properties and methods. The following script demonstrates how to click the Test1 button:

Sub Main

  Dim p, wMain, wRibbonBar, strItem

  Set p = Sys.Process("SampleDNB")

  Set wMain = p.WinFormsObject("Form1")

  wMain.Activate

  Set wRibbonBar = wMain.WinFormsObject("MainRibbon").WinFormsObject("OrganizationRibbonPanel").WinFormsObject("OrganizationCreateBar")

  strItem = "Test1"

  If clickItem(wRibbonBar, strItem) Then

    Log.Message "The '" & strItem & "' item was successfully clicked."

  Else

    Log.Error "The '" & strItem & "' item was not found."

  End If

End Sub



Function clickItem(wRibbonBar, strItem)

  Dim oCont, itemCount, itemId, itemObj, bounds,  mainBounds

 

  clickItem = False

  Set oCont = wRibbonBar.Items.Item(0)' Looks like It is the Container object

  itemCount = oCont.SubItems.Count

  For itemId = 0 To itemCount - 1

    Set itemObj = oCont.SubItems.Item(itemId)

    If SameText(itemObj.Text, strItem) Then

      Set bounds = itemObj.AccessibleObject.Bounds

      Set mainBounds = wRibbonBar.AccessibilityObject.Bounds

      Log.LockEvents(1)

      Call wRibbonBar.Click(bounds.Left - mainBounds.Left + bounds.Width / 2, bounds.Top - mainBounds.Top + bounds.Height / 2)

      Log.UnlockEvents

      Log.Event "The '" & strItem & "' item was clicked."

      clickItem = True

      Exit Function  

    End If     

  Next

End Function


Also, you can use MSAA to address the target buttons. To do this, you need to add the WindowsForms* window class to the list of accepted MSAA windows (right-click your project in Project Explorer | Edit | Properties | Open Applications | MSAA). See the Testing With Microsoft Active Accessibility article for information.


I hope this helps.


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
asu
New Contributor

Thank you Allen!

The suggested approach works perfectly.



BR,

Olexandr
cancel
Showing results for 
Search instead for 
Did you mean: