locked
Object Identification RRS feed

  • Question

  • Hello,

    I want to click a menu item.

    The menu item is not visible at first...we have to scroll down the list and then the menu item is visible.

    While recording the click action on menu item is recorded.

    But while playback the error- object is hidden - is given.

    How can this issue be sort?

    Wednesday, June 18, 2014 6:33 AM

Answers

  • Hi Ameett

    Could you also try the EnsureClickable() method for the control it should scroll the relevant parent control until it is not hidden anymore.

    HTH

    Wednesday, June 18, 2014 10:50 AM
  • Hi ameett,

    1.  If you use the DrawHighlight() on the control, do you see any bounding rectangle being drawn on the UI control?

    2.  Use ButtonControl.BoundingRectangle, does this return non-zero values ?

    3.  If the step 2 is true,

    Rectangle r = ButtonControl.BoundingRectangle.

    ButtonControl.SetFocus()

    Mouse.Click(new Point(r.X + r.Width/2, r.Y + r.Height/2));

    Test it again.

    In addition, the real issue is that whether you could see the specific control in your app UI when you playback the coded UI test, I mean that you will see that the recorded action play backed in your app UI, but if the specific control is hidden now, it would be failed, so we need to call the  Mouse.MoveScrollWheel(UITestControl, Int32) to scroll an UIElement to the desired position, I mean that we have to make sure that the specific control is not hidden in your app UI, and then it could capture and find the control.

    But if you make sure that the control is visible in your app UI when you playback the coded UI test, maybe it couldn't find the control with your search properties or it requires a specific location point for this control like the about step3. Hope it could help.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 19, 2014 5:59 AM

All replies

  • Hello,

    UITestControl has two properties Enable and Exists. Exists can be helpful to identify whether control is visible or not.

    In your case you can check for [YourMenuItem].Exists. if this returns true. you can click on that. if it returns false, then you can check for existence of [Scrollbar].Exists if it returns true then click on it and check for [YourMenuItem] existence until you get it or your scrolls reaches to end.

    Hope, this will give you logical idea to resolve your issue and provide you a guidance.


    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    Wednesday, June 18, 2014 6:42 AM
  • Thanks for Tejas's help. 

    Hi ameett,

    I think Tejas shared us a helpful solution, you could also call Mouse.MoveScrollWheel(UITestControl, Int32) to scroll an UIElement to the desired position if it returns false.

    http://msdn.microsoft.com/en-us/library/dd419179.aspx

    Best Regards, 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, June 18, 2014 9:14 AM
  • Thanks Tejas.

    But still it is not working...I have checked both the properties - Exist/Enabled - both are true...but still not able to highlight as well click the menu Item...It is still saying that the menuItem is hidden.

    Test Name: CodedUITestMethod1
    Test Outcome: Failed
    Result Message: 
    Test method ObjectFinding.CodedUITest1.CodedUITestMethod1 threw exception:
    Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnHiddenControlException: Cannot perform 'Click' on the hidden control. Additional Details:
    TechnologyName:  'MSAA'
    Name:  'HOITOTYÖ'
    ControlType:  'MenuItem'
     ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0xF004F002

     

    Wednesday, June 18, 2014 10:04 AM
  • Hi Ameett

    Could you also try the EnsureClickable() method for the control it should scroll the relevant parent control until it is not hidden anymore.

    HTH

    Wednesday, June 18, 2014 10:50 AM
  • Hi ameett,

    1.  If you use the DrawHighlight() on the control, do you see any bounding rectangle being drawn on the UI control?

    2.  Use ButtonControl.BoundingRectangle, does this return non-zero values ?

    3.  If the step 2 is true,

    Rectangle r = ButtonControl.BoundingRectangle.

    ButtonControl.SetFocus()

    Mouse.Click(new Point(r.X + r.Width/2, r.Y + r.Height/2));

    Test it again.

    In addition, the real issue is that whether you could see the specific control in your app UI when you playback the coded UI test, I mean that you will see that the recorded action play backed in your app UI, but if the specific control is hidden now, it would be failed, so we need to call the  Mouse.MoveScrollWheel(UITestControl, Int32) to scroll an UIElement to the desired position, I mean that we have to make sure that the specific control is not hidden in your app UI, and then it could capture and find the control.

    But if you make sure that the control is visible in your app UI when you playback the coded UI test, maybe it couldn't find the control with your search properties or it requires a specific location point for this control like the about step3. Hope it could help.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 19, 2014 5:59 AM