This is a migrated thread and some comments may be shown as answers.

Silverlight drag and drop issue

3 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Paul Ricco
Top achievements
Rank 1
Paul Ricco asked on 21 May 2010, 09:46 AM
I have an issue with some drag and drop functionality in our Silverlight application.

The problem is that we have an actions menu that appears when you drag an object onto the apps desktop area and hover there (without releasing the mouse).  Then, with the mouse button still held down, you need to drag onto the actions menu and release it on the desired option.  I've attached an image to help explain this situation.

WebUI will not recognise this menu at all and it's impossible to access it in the DOM because I need to have the mouse button held down to show it so I can't access WebUI's features and have this menu displayed.

When using the record functionality and performing this action the step looks as follows:

Drag PARTObjectNameTextblock to application at (234,326) from TopLeftCorner

When played back this doesn't perform the correct functionality, rather it just drops it directly on the desktop.

Is there anything that WebUI can do to get around this issue?  I'm currently in my trial at the moment and I'm using the build 2010.1.4.29.  If this can be solved it would go a long way in proving that this tool is the right one for our company.

3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 21 May 2010, 09:56 PM
Hello Paul Ricco,

Great automation scenario. It can be done but requires some magic implemented in code. I've attached an example test that runs agains the Yahoo Drag & Drop sample website. The real magic is in the code behind step:

[CodedStep("MyCustom Step Description")]
public void MyCustomStep()
{
    System.Drawing.Rectangle startRect = Pages.BasicDragAndDrop.DdDemo1Div.GetRectangle();
    System.Drawing.Rectangle midRect = startRect;
    midRect.Offset(200, 150);
    System.Drawing.Rectangle endRect = midRect;
    endRect.Offset(0, -150);
    Manager.Desktop.Mouse.Move(startRect, midRect);
    Manager.Desktop.Mouse.Move(midRect, endRect);
    Manager.Desktop.Mouse.Click(MouseClickType.LeftUp, endRect);
}

The above code assumes that the Mouse Down has already happened on the element you want to drag. This happens in step 2 of the sample test. The above code runs as step 3. It then calculates the offsets for the drag operation, then performs the drag (simple mouse moves) and ends with the mouse up which ends the drag & drop operation.

The Pages.BasicDragAndDrop.DdDemo1Div refers to the element to be dragged on the Yahoo website. You'll want to substitute your element you actually want dragged.

Hope that gives you an idea how to implement this for your real application.

Regards,
Cody
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Paul Ricco
Top achievements
Rank 1
answered on 24 May 2010, 10:38 AM
Whilst this is a start to the solution, the problem that I'm having is that the drop locations are elements that only appear when the mouse is down.  I would like to be able to drop onto these elements rather than rely on coordinates (to make the tests more maintainable).  WebUI seems to have no way of grasping these elements in order to use in the tests.  So whilst I could use your method (I can't open your attachment by the way) it still isn't the desired solution due to maintainability issues.

What would you suggest for elements that are not viewable in the DOM because they only appear when a certain menu is displayed?  Will I need to get some more information from the development team in order to automate these elements?
0
Cody
Telerik team
answered on 24 May 2010, 07:27 PM
Hi Paul Ricco,

That is a tough automation scenario. Unfortunately there is no method to capture elements that are so transient in nature. Are you sure they're actually being added & removed from the Visual Tree instead of just being made visible and then hidden? If they are present but hidden then it would be possible to locate them in DOM Explorer, though it may take some serious hunting.

Could your developers help out by adding a special hot key just to make your Actions menu appear for you? For example, hit Alt/F10 to make the Actions menu visible so you can capture it. Once visible in a static state you can manually add the element to Elements Explorer. Then, using the same code behind method, make your third step (the second mouse move) move the element being dragged onto your target element.

Would that work for you?

Best wishes,
Cody
the Telerik team

P.S. You are right about the attachment. Looks like it was a bad attachment. I've attached a good copy of it for you.

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Paul Ricco
Top achievements
Rank 1
Answers by
Cody
Telerik team
Paul Ricco
Top achievements
Rank 1
Share this question
or