I also noted the on mouseenter event drag-able issue and made a local
change in Rajeenthini's checkout.
Rajeenthini, were you able to test it with that change?

On Mon, Nov 2, 2015 at 7:16 PM, Nipuna Chandradasa <[email protected]> wrote:

> Hi Rajeenthini,
>
> I tried one of your references which uses jquery.simulate.js to test the
> jquery UI functionality. It worked.
> Only thing that it didnt work with out product is we only make the element
> draggable when the mouseenter event. I progamatically made it draggable.
> Then using jquery simulator i simulate the drag and drop.
>
> this is the link i refer ( it's 6th reference in your list :D )
>
>
> http://stackoverflow.com/questions/16848165/programmatically-drag-and-drop-element-onto-another-element
>
> Following is what i did:
>
> ((JavascriptExecutor)getDriver()).executeScript(" var draggableElement = 
> $('#ues-store-gadget > div > div.row.ues-thumbnails > div:nth-child(1) > 
> div').draggable({"+
>
>         "cancel: false," +
>
>         "appendTo: 'body'," +                             // These are the 
> options we gave when writing the draggable element.
>
>         "helper: 'clone'," +
>
>         "start: function (event, ui) {" +
>
>         "ui.helper.addClass('ues-store-thumbnail');}," +
>
>         "stop: function (event, ui) {" +
>
>         "ui.helper.removeClass('ues-store-thumbnail');" +
>
>         "}})," +
>
>         "dropableElement=$('#a');"+   // Defining Dropable element
>
>         "var droppableOffset = dropableElement.offset()," +  // Get the 
> Offset from droppable element
>
>         "draggableOffset = draggableElement.offset()," +     // Get the 
> Offset from draggable element
>
>         "dx = droppableOffset.left - draggableOffset.left," +
>
>         "dy = droppableOffset.top - draggableOffset.top;" +
>
>         "draggableElement.simulate('drag', {" + // Call the simulate method 
> provided by jqeury.simulate.js
>
>         "dx: dx," +
>
>         "dy: dy" +
>
>         "});");
>
> Hope you find this helpful.
>
> Regards,
>
>
> On Thu, Oct 22, 2015 at 10:54 AM, Rajeenthini Satkunam <
> [email protected]> wrote:
>
>> Hi All,
>>
>> I have resolved the previous issue mentioned above through lasantha's
>> solution which he was mentioned. @lasantha Thank you for your prompt reply.
>> Even though I could not do this drag and drop Action successfully to
>> selenium UI test case Java.I would like to share what kind of try I have
>> made for get this work out. I am not getting any errors while I am doing
>> the build.Test case has been passed consistently.
>>
>> Using Action come up with selenium Automation frame work
>> ==============================================
>>
>> Selenium Action[1] class used to interactions using selenium.I have tried
>> in 3 ways that has proposed by selenium to do drag and drop Action.
>>
>> 1)  By Selected Action class
>>
>> Actions builder = new Actions(getDriver());
>>         Action dragAndDrop = builder.clickAndHold(gadget)
>>                .moveToElement(targetPane)
>>                .release(targetPane)
>>                .build();
>>        dragAndDrop.perform();
>>        Thread.sleep(2000);
>>
>> here the gadget is draggable, targetPane is droppable target element
>> which are find by selenium web driver using method
>>
>> WebElement gadget = getDriver().findElement(By.id("g1"));
>> WebElement targetPane = getDriver().findElement(By.id("a"));
>>
>>
>> 2) Using x y by dragAndDrop()
>>
>>         Actions dragAndHold = 
>> builder.clickAndHold(gadget).moveToElement(targetPane,-5,-5).release(targetPane);
>>         builder.perform();
>>
>> 3) Using dragAndDropBy method
>>
>> Point pointLast = gadget.getLocation();
>>         int xcordLast = point.getX();
>>         int ycordLast = point.getY();
>>         System.out.println(xcordLast + " " +
>>                 
>> "===============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.."
>>  + ycordLast);
>>         Dimension d = gadget.getSize();
>>         System.out.println(d.getHeight() + " " +
>>                 
>> "===============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.."
>>  + d.getWidth());
>>         int obj1MiddleX = (int) (xcord + (d.getWidth() * 0.5));
>>         int obj1MiddleY = (int) (ycord + d.getHeight() * 0.5);
>>
>>         System.out.println(obj1MiddleX + " " +
>>                 
>> "===============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.."
>>  + obj1MiddleY);
>>
>>         Point point1 = targetPane.getLocation();
>>         int xcordpane = point1.getX();
>>         int ycordpane = point1.getY();
>>         System.out.println(xcordpane + " " +
>>                 
>> "===============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.."
>>  + ycordpane);
>>         Dimension dPane = gadget.getSize();
>>         System.out.println(dPane.getHeight() + " " +
>>                 
>> "===============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.."
>>  + dPane
>>  .getWidth());
>>         int obj2MiddleX = (int) (xcordpane + (dPane.getWidth() * 0.5));
>>         int obj2MiddleY = (int) (ycordpane + dPane.getHeight() * 0.5);
>>
>>         System.out.println(obj2MiddleX + " " +
>>                 
>> "===============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.."
>>  + obj2MiddleY);
>>
>>         int XoffSet = Math.abs(obj1MiddleX - obj2MiddleX);
>>         int YoffSet = Math.abs(obj1MiddleY - obj2MiddleY);
>>
>>         builder.dragAndDropBy(gadget,XoffSet,YoffSet);
>>
>> But none of these methods did not give me any successful drag and drop
>> Action.
>>
>>
>> Using EcecuteScript method
>>
>> ===========================
>>
>> So I have discussed with team and come up with a idea that writing a script 
>> for drag and drop Action on UI and exceute that script using method of 
>> selenium framework executeScript().
>>
>> I have search for the solutions that can be trigger the drag and drop Action 
>> using script.And we are using JQueryUI to do drag and drop.I have shared 
>> those links that I have follwed below.It also does not give any positive 
>> impact to do this task.
>>
>> String filePath = 
>> FrameworkPathUtil.getReportLocation()+"/../src/test/resources/dragAndDropJs/dnd.js";
>> StringBuffer buffer = new StringBuffer();
>> String line;
>> BufferedReader br = new BufferedReader(new FileReader(filePath));
>> while((line = br.readLine())!=null)
>>     buffer.append(line);
>> String javaScript = buffer.toString();
>> String cssSource = "#g1";
>> String cssTarget = "#a";
>>
>> javaScript = javaScript + "$('" + cssSource + "').simulateDragDrop({ 
>> dropTarget: '" + cssTarget + "'});";
>> (getDriver()).executeScript(javaScript);
>>
>>
>> And the javascript file dnd.js
>>
>> (function ($) {
>>     $.fn.simulateDragDrop = function (options) {
>>         return this.each(function () {
>>             new $.simulateDragDrop(this, options);
>>         });
>>     };
>>     $.simulateDragDrop = function (elem, options) {
>>         this.options = options;
>>         this.simulateEvent(elem, options);
>>     };
>>     $.extend($.simulateDragDrop.prototype, {
>>         simulateEvent: function (elem, options) {
>>             /*Simulating drag start*/
>>             var type = 'dragstart';
>>             var event = this.createEvent(type);
>>             this.dispatchEvent(elem, type, event);
>>
>>             /*Simulating drop*/
>>             type = 'drop';
>>             var dropEvent = this.createEvent(type, {});
>>             dropEvent.dataTransfer = event.dataTransfer;
>>             this.dispatchEvent($(options.dropTarget)[0], type, dropEvent);
>>
>>             /*Simulating drag end*/
>>             type = 'dragend';
>>             var dragEndEvent = this.createEvent(type, {});
>>             dragEndEvent.dataTransfer = event.dataTransfer;
>>             this.dispatchEvent(elem, type, dragEndEvent);
>>         },
>>         createEvent: function (type) {
>>             var event = document.createEvent("CustomEvent");
>>             event.initCustomEvent(type, true, true, null);
>>             event.dataTransfer = {
>>                 data: {
>>                 },
>>                 setData: function (type, val) {
>>                     this.data[type] = val;
>>                 },
>>                 getData: function (type) {
>>                     return this.data[type];
>>                 }
>>             };
>>             return event;
>>         },
>>         dispatchEvent: function (elem, type, event) {
>>             if (elem.dispatchEvent) {
>>                 elem.dispatchEvent(event);
>>             } else if (elem.fireEvent) {
>>                 elem.fireEvent("on" + type, event);
>>             }
>>         }
>>     });
>>
>> })(jQuery);
>>
>>
>> above code is not giving any errors like previous one.Tests has been passed 
>> But the Action drag and drop is not happened.
>>
>>
>> [1] - 
>> https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html
>>
>> [2] - 
>> http://www.nishantverma.com/2011/07/using-drag-and-drop-in-webdriver.html
>>
>> [3] - http://elementalselenium.com/tips/39-drag-and-drop
>>
>> [4] - 
>> http://stackoverflow.com/questions/14210051/how-to-automate-drag-drop-functionality-using-selenium-web-driver
>>
>> [5] - 
>> https://github.com/jquery/jquery-ui/blob/1-11-stable/tests/unit/droppable/droppable_events.js#L21-L33
>>
>> [6] - 
>> http://stackoverflow.com/questions/16848165/programmatically-drag-and-drop-element-onto-another-element
>>
>> [7] - 
>> https://github.com/jquery/jquery-ui/blob/9e8e339648901899827a58e5bf919f7dda03b88e/tests/jquery.simulate.js
>>
>> And I have discussed about this at stackoverflow and linkedin as well
>>
>> you can get by these following links
>>
>> stackoverflow - 
>> http://stackoverflow.com/questions/33146808/executing-javascript-for-selenium-ui-integration-test-of-drag-and-drop-java
>>
>> Linkedin - 
>> https://www.linkedin.com/groups/961927/961927-6060654701249060868#commentID_6062515331736305664
>>
>> I did not get any replies for stackoverflow ,But  I got some points on 
>> linkedin selenium group. I have followed all those steps that has mentioned 
>> their replies.
>>
>> So can anyone please tryout this scenario and advice me to do this 
>> task?.Your help is appreciated mostly.
>>
>>
>>
>>
>>
>>
>>
>> On Fri, Oct 9, 2015 at 3:25 PM, Lasantha Samarakoon <[email protected]>
>> wrote:
>>
>>> Hi Rajeenthini,
>>>
>>> You are getting this exception because you can't cast the UESWebDriver
>>> into HasInputDevices interface. That is because unlike other drivers
>>> such as FirefoxDriver and ChromeDriver the UESWebDriver only implements
>>> the WebDriver interface.
>>>
>>> Therefore you need to implement the HasInputDevices interface in
>>> UESWebDriver in order to use those mouse and keyboard actions.
>>>
>>>
>>> Regards,
>>>
>>> *Lasantha Samarakoon* | Software Engineer
>>> WSO2, Inc.
>>> #20, Palm Grove, Colombo 03, Sri Lanka
>>> Mobile: +94 (71) 214 1576
>>> Email:  [email protected]
>>> Web:    www.wso2.com
>>>
>>> lean . enterprise . middleware
>>>
>>> On Thu, Oct 8, 2015 at 4:55 PM, Madusanka Premaratne <
>>> [email protected]> wrote:
>>>
>>>> Hi Rajinthini,
>>>> It seems like you have to change the test case. Did you record the test
>>>> case using selenium plugin? The best approach is write is yourself in this
>>>> kind of scenarios. You can refer to the links[1] and [2] to get an idea.
>>>> [1] -
>>>> http://stackoverflow.com/questions/14210051/how-to-automate-drag-drop-functionality-using-selenium-web-driver
>>>> [2] - http://www.toolsqa.com/selenium-webdriver/drag-drop/
>>>>
>>>> Thanks,
>>>> Madusanka
>>>>
>>>> On Thu, Oct 8, 2015 at 3:48 PM, Rajeenthini Satkunam <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I am currently working on writing UI test-cases using selenium for
>>>>> Dashboard Server(DS)/User Engagement Server.I have a test Case which needs
>>>>> to do a action that drag one element to a place and drop it in that
>>>>> place(drag and drop).So I have tried the below approach to do this task.
>>>>>
>>>>> public void testAddGadgetToDashboard() throws Exception {
>>>>>     webElement = getDriver().findElement(By.id(dashboardTitle));
>>>>>     webElement.findElement(By.cssSelector("a[href=\"dashboards/" + 
>>>>> dashboardTitle + "?editor=true\"]")).click();
>>>>>     WebElement draggable = getDriver().findElement(By.id("g1"));
>>>>>     WebElement to = getDriver().findElement(By.id("a"));
>>>>>     Actions builder = new Actions(getDriver());
>>>>>     Action dragAndDrop = builder.clickAndHold(draggable)
>>>>>             .moveToElement(to)
>>>>>             .release(to)
>>>>>             .build();
>>>>>     dragAndDrop.perform();
>>>>>
>>>>> }
>>>>>
>>>>> But I am getting an exception when running the test-case,
>>>>>
>>>>> FAILED: testAddGadgetToDashboard
>>>>>         Adding gadgets to existing dashboard from dashboard server
>>>>> java.lang.ClassCastException:
>>>>> org.wso2.ues.ui.integration.util.UESWebDriver cannot be cast to
>>>>> org.openqa.selenium.interactions.HasInputDevices
>>>>> at org.openqa.selenium.interactions.Actions.<init>(Actions.java:41)
>>>>> at
>>>>> org.wso2.ues.ui.integration.test.dashboard.AddgadgetToDashboardtest.testAddGadgetToDashboard(AddgadgetToDashboardtest.java:86)
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>> at
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>> at
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>> at java.lang.reflect.Method.invoke(Method.java:601)
>>>>> at
>>>>> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
>>>>> at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
>>>>> at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
>>>>> at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
>>>>> at
>>>>> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
>>>>> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
>>>>> at org.testng.TestRunner.privateRun(TestRunner.java:767)
>>>>> at org.testng.TestRunner.run(TestRunner.java:617)
>>>>> at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
>>>>> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
>>>>> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
>>>>> at org.testng.SuiteRunner.run(SuiteRunner.java:240)
>>>>> at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
>>>>> at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
>>>>> at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
>>>>> at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
>>>>> at org.testng.TestNG.run(TestNG.java:1057)
>>>>> at
>>>>> org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:177)
>>>>> at
>>>>> org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
>>>>> at
>>>>> org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:105)
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>> at
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>> at
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>> at java.lang.reflect.Method.invoke(Method.java:601)
>>>>> at
>>>>> org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
>>>>> at
>>>>> org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
>>>>> at
>>>>> org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
>>>>> at
>>>>> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
>>>>> at
>>>>> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
>>>>>
>>>>> Can anyone please advice me on how this has gone wrong and Is selenium
>>>>> version or Firefox version are depends on this error thrown?
>>>>>
>>>>> Note: I am using Firefox version 27 and selenium version is automation
>>>>> selenium version.
>>>>> --
>>>>>
>>>>> *Thank You.*
>>>>>
>>>>> *Rajeenthini Satkunam*
>>>>>
>>>>> *Associate Software Engineer | WSO2*
>>>>>
>>>>>
>>>>> *E:[email protected] <[email protected]>*
>>>>>
>>>>> *M :+94770832823 <%2B94770832823>   *
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [email protected]
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Madusanka Premaratne* | Associate Software Engineer
>>>> WSO2, Inc | lean. enterprise. middleware.
>>>> #20, Palm Grove, Colombo 03, Sri Lanka
>>>> Mobile: +94 71 835 70 73| Work: +94 112 145 345
>>>> Email: [email protected] | Web: www.wso2.com
>>>>
>>>> [image: Facebook] <https://www.facebook.com/maduzanka> [image: Twitter]
>>>> <https://twitter.com/rmmpremaratne> [image: Google Plus]
>>>> <https://plus.google.com/u/0/+MadusankaPremaratnemaduz/about/p/pub> [image:
>>>> Linkedin] <http://lk.linkedin.com/in/madusanka/> [image: Instagram]
>>>> <http://instagram.com/madusankapremaratne> [image: Skype]
>>>> <http://@rmmpremaratne>
>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [email protected]
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>
>>
>> --
>>
>> *Thank You.*
>>
>> *Rajeenthini Satkunam*
>>
>> *Associate Software Engineer | WSO2*
>>
>>
>> *E:[email protected] <[email protected]>*
>>
>> *M :+94770832823 <%2B94770832823>   *
>>
>>
>
>
> --
> Nipuna Marcus
> *Software Engineer*
> WSO2 Inc.
> http://wso2.com/ - "lean . enterprise . middleware"
> Mobile : +94 (0) 713 667906
> [email protected]
>



-- 
With regards,
*Manu*ranga Perera.

phone : 071 7 70 20 50
mail : [email protected]
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to