Drag n Drop

Class library usage, coding and language questions.
ki2_23
Posts: 6
Joined: Mon Jul 21, 2014 7:58 am

Drag n Drop

Post by ki2_23 » Mon May 04, 2015 3:03 am

Hi Guys,

I've been through previous threads on Drag n Drop and tried options suggested but no luck :(
My Final option is to check with Support team.

Below is the code snippet i am using for drag n drop .
Same old Logic of buttonDown,Mouse.MoveTo and ButtonUp

public void RemoveBlockFromDesignCanvas(string blockName)
{
WaitforDesignSpaceResults();
Mouse.Click(FindElementV2_x("RxPathDesignSpaceUpperDesignCanvas"));
ScrollHorizontalOnDesignCanvas();
Mouse.MoveTo(FindElementV2_x("RxPathDesignSpaceDesignCanvasBlockName",blockName));
Mouse.ButtonDown(MouseButtons.Left);
Mouse.MoveTo(FindElementV2_x("RxPathDesignSpaceDesignLabel"));
Mouse.ButtonUp(MouseButtons.Left);
designPageMethods.ClickUpperDesignCanvas();
}


This code is throwing me an exception at Mouse.MoveTo(FindElementV2_x("RxPathDesignSpaceDesignLabel")); as it is unable to find the element, when manually checked through spy i am able to find the element :o

I am using drag n drop across the application but it is only failing in this method. I am attaching the snapshot for those 2 elements Source(Element) and destination(Element). I have observed that draggable attribute is set to False but i am still able to drag manually :lol:

Hope i have provided enough information for you to suggest.
You do not have the required permissions to view the files attached to this post.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Drag n Drop

Post by krstcs » Mon May 04, 2015 4:33 pm

Please post the following information when raising issues:

Ranorex version
Windows version
Technology of system under test (Flash/Flex, HTML, Java, WPF, etc.)

Please also post the RanoreXPath you are using for each element. It could be that something that you are using in the path is not correct at the time of the drag-and-drop.
Shortcuts usually aren't...

ki2_23
Posts: 6
Joined: Mon Jul 21, 2014 7:58 am

Re: Drag n Drop

Post by ki2_23 » Tue May 05, 2015 12:24 am

Ranorex version : 5.1.3.19973
Windows version : Windows 8.1
Technology of system under test : JAVA

Source: /dom[@caption='Hubble: Design']//div[#'design_canvas']/div[1]//label[@innertext='billingcity']
Destination : /dom[@caption='Hubble: Design']/body/div[3]/div[2]/div/div[1]/div[2]/div/div[2]/div[2]/div[@innertext='DESIGN']

Note: I am able to drag n drop from other areas onto Design canvas (Source) but cannot drag out from Design canvas to any other area.

just to remind attached snapshot in the main post if that helps.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Drag n Drop

Post by odklizec » Tue May 05, 2015 7:06 am

ki2_23 wrote: This code is throwing me an exception at Mouse.MoveTo(FindElementV2_x("RxPathDesignSpaceDesignLabel")); as it is unable to find the element, when manually checked through spy i am able to find the element :o
Hi,

Could you please post the exact error you are getting (enable Debug report level)?

Also, I would suggest to add a line of code, that would save the actual state of your app to snapshot (before or after the failing line of code). There is plenty of indexes in the destination path you provided and I guess one of them (or something else in the path) is not valid during the failure?

Another thing you might try is to use this destination path:

Code: Select all

/dom[@caption='Hubble: Design']/body//div[@innertext='DESIGN']
It may take longer to find such path, but at least you will test the code behavior without all nested divs and their indexes.

BTW, I suppose this FindElementV2_x is your method? Could you please post the code behind this method?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ki2_23
Posts: 6
Joined: Mon Jul 21, 2014 7:58 am

Re: Drag n Drop

Post by ki2_23 » Tue May 05, 2015 7:42 am

odklizec wrote: Could you please post the exact error you are getting (enable Debug report level)?
we are not using Ranorex Studio :) we are coding at API level

Error: No element found for path '/dom[@caption='Hubble: Design']/body/div[3]/div[2]/div/div[1]/div[2]/div/div[2]/div[2]/div[@innertext='DESIGN']'.

odklizec wrote:BTW, I suppose this FindElementV2_x is your method? Could you please post the code behind this method?
just to give you an overview this will literally do a tryFindSingle.
we have customized to our framework by getting RxPath From DB and apply tryFindSingle to the RxPath and return us Element :)

Code: Select all

 public Element FindElementV2_x(string rxPathName, Duration dur = null, params object[] parameters)
        {
            if (dur != null)
            {
                DurationForFindElement = dur;
            }

            var resolvedPath = RxPathOfTheObjectVersion2_x(rxPathName).Trim();
            if (parameters.Any())
            {
                resolvedPath = String.Format(RxPathOfTheObjectVersion2_x(rxPathName).Trim(), parameters);
            }

            webDocument.Element.TryFindSingle(resolvedPath, DurationForFindElement, out element);
            element = webDocument.Element.FindSingle(resolvedPath);
            DurationForFindElement = TimeSpan.FromSeconds(10);
            return element;
        }

ki2_23
Posts: 6
Joined: Mon Jul 21, 2014 7:58 am

Re: Drag n Drop

Post by ki2_23 » Tue May 05, 2015 7:57 am

odklizec wrote: Another thing you might try is to use this destination path:

Code: Select all

/dom[@caption='Hubble: Design']/body//div[@innertext='DESIGN']
Strange this worked :? but how ?

Well the RxPath i am previously using is working at other parts of the code , what is the underlying logic ?

Thanks for the Magic 8) :D

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Drag n Drop

Post by odklizec » Tue May 05, 2015 8:22 am

Hi,

OK, this supports my idea that the path is really different during runtime? The question is, why it works somewhere else in your code?

I don't know much about working at API level, but it should still be possible to save the actual application state to snapshot or set the report level to debug? I think the snapshot will show you the difference in destination path. This code should save the DOM to snapshot:

Code: Select all

Report.Snapshot(ReportLevel.Debug, "User", "", repo.AppDOM.Self);
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration