locked
Coded UI: Mouse does not drag an object from given specified location RRS feed

  • Question

  •           

    when I run this code, the dragging point is not picking as it specified, it starts from top left corner of the machine and stops at right location as it specified. So it's fine in terms of dropping location but I wonder how do I make it to pick right object to drag. My test case running browser is Firefox, other steps run fine only having an issue with Drag/Drop action.

    I have tried different posted available in other threads in MSDN but haven't had luck yet.

                //To be dragged
                HtmlEdit kmName = new HtmlEdit(_browser);
                kmName.SearchProperties[HtmlEdit.PropertyNames.ControlType] = "Pane";
                kmName.SearchProperties[HtmlEdit.PropertyNames.TagName] = "SPAN";
                kmName.SearchProperties[HtmlEdit.PropertyNames.Class] = "fancytree-title";      
                kmName.SearchProperties[HtmlEdit.PropertyNames.InnerText]  = "TestKM";
                kmName.SearchProperties[HtmlEdit.PropertyNames.TagInstance] = "47"; 
                Mouse.Hover(kmName);

                //Drop location
                HtmlEdit kmDropLocaiton = new HtmlEdit(_browser);
                kmDropLocaiton.SearchProperties[HtmlEdit.PropertyNames.ControlType] = "Edit";
                kmDropLocaiton.SearchProperties[HtmlEdit.PropertyNames.Type] = "SINGLELINE";
                kmDropLocaiton.SearchProperties[HtmlEdit.PropertyNames.TagName] = "INPUT";
                kmDropLocaiton.SearchProperties[HtmlEdit.PropertyNames.Class] = "ng-isolate-scope ui-droppable dropTarget";
                kmDropLocaiton.SearchProperties[HtmlEdit.PropertyNames.TagInstance] = "2";

                Mouse.StartDragging(kmName, new Point(44, 23));
                Mouse.StopDragging(kmDropLocaiton);


    Many thanks in advance for help.

          
    • Edited by JK_07 Friday, September 4, 2015 2:00 AM
    Wednesday, September 2, 2015 7:44 PM

Answers

  • Hi JK_07,

    >>When I playback test case, it just get passed, there is no error log for it; what happens is mouse goes top left corner of machine and moving to the end point and moves to another step so it acts like that step is executed but not happens actual dragging event. 

    One possible reason is that it really has the specific requirement for the location point, sorry for that if I couldn't describe it clearly, but I can share you a simple sample.

    I remember I met an issue before. For example, there are two columns' table/text data in a page of a customer's app.

    A          B

    If we click A with mouse down(not up), and then move the mouse to B, and then it would change the location like:

    B          A

    Could you understand the above sample?

    The member really could see the changes when he recorded the coded UI test manually for this page. But the localtion doesn't be changed between A and B when he palybacked the coded UI tests.

    I'm not very sure that whether it is simliar to your controls, but one workaround for this issue is that:

    Add assertaions on the two controls, I think you could get the location point for the two control.

    So we have to know the real location distance between two controls, and then we use the real value for them and move the A to the new location to B. But if you run it in different desktop or different browsers, I doubt that it would have certain issue since the location was changed.

    If I don't describe it clearly, please feel free to let me know.

    Maybe you could share me a simple sample or UI you test with one drive, I will test it in my side.

    Sincerely,

    Jack


    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, September 9, 2015 8:22 AM

All replies

  • Hi JK_07,

    >> other steps run fine only having an issue with Drag/Drop action.

    Could you share us the UI about the controls you want to test?

    Generally the Point argument doesn't impact the test results(mouse click action).

    Of course, for the specific drop down action, the most important issue is that we have to click one the coordinates point.

    http://blogs.msdn.com/b/mathew_aniyan/archive/2012/03/16/faq-why-are-we-using-coordinate-based-actions-in-coded-ui-test.aspx

    If it doesn't work for you, we have to make sure that whether it really finds the drop control firstly using the DrawHighlight() method.

    http://blogs.msdn.com/b/mathew_aniyan/archive/2010/04/29/faq-some-minutiae-on-drawhighlight.aspx

    Do you get any error messages when you playback your recorded test?

    Maybe you could use this way here:

    Mouse.Click(new Point(oChk.BoundingRectactangle.X
     + oChk.BoundingRectangle.Width/2, oChk.BoundingRectangle.Y +
    oChkBoundingRectangle.Height/2));

    Reference:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/e625dfeb-137b-4da0-a0ee-f406675504d1/coded-ui-test-hi-i-am-facing-issue-in-clicking-on-hidden-controls-the-following-error-is?forum=vstest

    Best Regards,

    Jack


    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.


    Friday, September 4, 2015 7:24 AM
  • Hi Jack-Zack, 

    Thanks for taking look into my issue and respond.

    But this issue is not related with "Drop Down" action, it is related with "Drag and Drop" action. So it finds both drag and droplocation object and issue with grabbing object and dropping to specified location. So What happens is tool-tip goes over drag object then mouse moves over to top left corner(instead of dragging object) and mouse moves down to drop location. 

    I've also tried following for drag &drop:

    Rectangle _Rec = kmName.BoundingRectangle;
    Rectangle _Rec1 = kmDropLocaiton.BoundingRectangle
    Mouse.Hover(new Point(_Rec.X + _Rec.Width / 2, _Rec.Y + _Rec.Height / 2));
    kmName.DrawHighlight();
    Mouse.StartDragging(kmName, new Point(_Rec.X + _Rec.Width / 2, _Rec.Y + _Rec.Height / 2));
    Mouse.StopDragging(kmDropLocaiton, new Point(_Rec1.X + _Rec1.Width / 2, _Rec1.Y + _Rec1.Height / 2));

    

    Friday, September 4, 2015 1:24 PM
  • Hi JK_07,

    Could you share us the detailed log message?

    https://msdn.microsoft.com/en-us/library/jj159363.aspx?f=255&MSPPError=-2147217396

    >>My test case running browser is Firefox, other steps run fine only having an issue with Drag/Drop action.

    Since you run it with third party browser, I doubt the you install the browser extension tool for coded UI tests here, am I right?

    But one issue is that how about the result if you run it in IE browser.

    Based on your description, my understanding is that it has the specific requirement for the local point for the control.

    http://blogs.msdn.com/b/siddharthapandey/archive/2009/12/20/does-dragging-action-on-wpf-controls-hangs.aspx

    Or it is related to the Playback settings:

    https://social.msdn.microsoft.com/Forums/en-US/073b121c-7b21-4901-97ea-556bee7df056/automating-drag-and-drop-functionality-using-coded-ui-test?forum=vsautotest

    Best Regards,

    Jack


    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.

    Monday, September 7, 2015 7:55 AM
  • Hi Jack, 

    When I playback test case, it just get passed, there is no error log for it; what happens is mouse goes top left corner of machine and moving to the end point and moves to another step so it acts like that step is executed but not happens actual dragging event. 

    I have already got "Selenium components for Coded UI Cross Browser Testing", otherwise I wouldn't be able to run Coded UI Test over cross browsing.

    For IE; I have other issues which hinders me to get "Drag and Drop" action step so that reason I'have using Firefox browser for running test cases. And I've already posted that IE issue here: 

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/33af29c6-a95b-486d-8d1d-3fa2cf6ce469/vs-2013-coded-ui-internet-explorer-browsers-fail-test-cases-whereas-firefox-runs-fine?forum=vstest#33af29c6-a95b-486d-8d1d-3fa2cf6ce469

    And I don't see there is playback issue as well. I have tried different way for it but no luck yet. 

    Thanks!

    Tuesday, September 8, 2015 2:03 PM
  • Hi JK_07,

    >>When I playback test case, it just get passed, there is no error log for it; what happens is mouse goes top left corner of machine and moving to the end point and moves to another step so it acts like that step is executed but not happens actual dragging event. 

    One possible reason is that it really has the specific requirement for the location point, sorry for that if I couldn't describe it clearly, but I can share you a simple sample.

    I remember I met an issue before. For example, there are two columns' table/text data in a page of a customer's app.

    A          B

    If we click A with mouse down(not up), and then move the mouse to B, and then it would change the location like:

    B          A

    Could you understand the above sample?

    The member really could see the changes when he recorded the coded UI test manually for this page. But the localtion doesn't be changed between A and B when he palybacked the coded UI tests.

    I'm not very sure that whether it is simliar to your controls, but one workaround for this issue is that:

    Add assertaions on the two controls, I think you could get the location point for the two control.

    So we have to know the real location distance between two controls, and then we use the real value for them and move the A to the new location to B. But if you run it in different desktop or different browsers, I doubt that it would have certain issue since the location was changed.

    If I don't describe it clearly, please feel free to let me know.

    Maybe you could share me a simple sample or UI you test with one drive, I will test it in my side.

    Sincerely,

    Jack


    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, September 9, 2015 8:22 AM