How to do mouse down, mouse move in Selenium2Library?

3,983 views
Skip to first unread message

Mohan R

unread,
Sep 11, 2012, 3:49:58 PM9/11/12
to robotframe...@googlegroups.com
I want to interact with a slider in my test. Seems like Action Chains in Selenium are the way to do that.

[How to mouseover in python Webdriver - Google Groups](https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/fj1RVXKvAew)

But how do I do this with Selenium2Library?
There seems to be no mouse down and mouse move functions in  Selenium2Library.

Or as a fallback, how do I access the underlying selenium library via Selenium2Library instance ?
Seems like there is a way to do it in SeleniumLibrary (via "Call Selenium Api" function and class attribute  seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary'), self.selenium = seleniumlib.selenium).

Thanks,

Mohan Raj Rajamanickam

unread,
Sep 13, 2012, 3:21:21 PM9/13/12
to robotframe...@googlegroups.com
Figured out how to do it with RF - Selenium library

using the (undocumented) function drag_and_drop_by_offset

Just in case anyone else needs it..

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/robotframework-users/-/ecycpjCucCgJ.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.



--
Mohan Raj

Christian Rudolf Tan

unread,
May 13, 2015, 12:08:51 AM5/13/15
to robotframe...@googlegroups.com
 Thanks! it worked!
To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.



--
Mohan Raj

henric...@gmail.com

unread,
Nov 27, 2015, 9:50:47 AM11/27/15
to robotframework-users
I am trying to drag an element to a specific location but no luck so far. I want to do it with

Drag And Drop By Offset    xpath=//*[@id="elementSource"]    450    0

elementSource is  <div id="elementSource" class="item ng-binding ng-scope" id="elementSource" ng-class="{onhover: hover}" ng-mouseenter="hover = true" ng-mouseleave="hover = false"> </div>.

When the test comes to this point elementSource is visibly selected by mouse hover but there is no horizontal drag performed. ElementSource should be placed to a placeholder but it is not?? I have also tried with Keyword Drag And Drop  xpath=//*[@id="elementSource"]    xpath=//*[@id="dropArea"] where dropArea is ul element with id="dropArea".

I am using the latest version of RF, Selenium lib, Firefox and Chrome. What am I doing so wrong???

I am trying to drag an element to a specific location but no luck so far. I want to do it with

Drag And Drop By Offset    xpath=//*[@id="elementSource"]    450    0

elementSource is  <div id="elementSource" class="item ng-binding ng-scope" id="elementSource" ng-class="{onhover: hover}" ng-mouseenter="hover = true" ng-mouseleave="hover = false"> </div>.

When the test comes to this point elementSource is visibly selected by mouse hover but there is no horizontal drag performed. ElementSource should be placed to a placeholder but it is not?? I have also tried with Keyword Drag And Drop  xpath=//*[@id="elementSource"]    xpath=//*[@id="dropArea"] where dropArea is ul element with id="dropArea".

I am using the latest version of RF, Selenium lib, Firefox and Chrome. What am I doing so wrong???

Dne četrtek, 13. september 2012 21.21.21 UTC+2 je oseba Mohan R napisala:
To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.



--
Mohan Raj

Tatu Aalto

unread,
Nov 27, 2015, 10:19:03 AM11/27/15
to henric...@gmail.com, robotframework-users

Ugh

The underlying selenium is really picky which element it is able to drag and drop. The more complex the DOM is, the harder it is find the right element to drag. Also not all elements can be dragged by selenium.

-Tatu
Send from my mobile

To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.



--
Mohan Raj

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.

henric...@gmail.com

unread,
Nov 29, 2015, 2:47:28 PM11/29/15
to Tatu Aalto, robotframework-users
So what concrete suggestions do you have? The DOM structure in my case
is guite complex, for example the xpath or css path is "long".

The mouse is moved to the element, the element is clicked, but no way to
be moved.... I don't really know if it is even dragable by Selenium??

Any suggestions by others?

On 27.11.2015 16:18, Tatu Aalto wrote:
> Ugh
>
> The underlying selenium is really picky which element it is able to drag
> and drop. The more complex the DOM is, the harder it is find the right
> element to drag. Also not all elements can be dragged by selenium.
>
> -Tatu
> Send from my mobile
>
> On 27 Nov 2015 4:50 p.m., <henric...@gmail.com
> <mailto:henric...@gmail.com>> wrote:
>
> I am trying to drag an element to a specific location but no luck so
> far. I want to do it with
>
> Drag And Drop By Offset xpath=//*[@id="elementSource"] 450 0
>
> elementSource is <div id="elementSource" class="item ng-binding
> ng-scope" id="elementSource" ng-class="{onhover: hover}"
> ng-mouseenter="hover = true" ng-mouseleave="hover = false"> </div>.
>
> When the test comes to this point elementSource is visibly selected
> by mouse hover but there is no horizontal drag performed.
> ElementSource should be placed to a placeholder but it is not?? I
> have also tried with Keyword Drag And Drop
> xpath=//*[@id="elementSource"] xpath=//*[@id="dropArea"] where
> dropArea is ul element with id="dropArea".
>
> I am using the latest version of RF, Selenium lib, Firefox and
> Chrome. What am I doing so wrong???
>
> I am trying to drag an element to a specific location but no luck so
> far. I want to do it with
>
> *Drag And Drop By Offset xpath=//*[@id="elementSource"] 450 0*
>
> elementSource is <div id="elementSource" class="item ng-binding
> ng-scope" id="elementSource" ng-class="{onhover: hover}"
> ng-mouseenter="hover = true" ng-mouseleave="hover = false"> </div>.
>
> When the test comes to this point elementSource is visibly selected
> by mouse hover but there is no horizontal drag performed.
> ElementSource should be placed to a placeholder but it is not?? I
> have also tried with Keyword *Drag And Drop
> xpath=//*[@id="elementSource"] xpath=//*[@id="dropArea"]* where
> dropArea is ul element with id="dropArea".
>
> I am using the latest version of RF, Selenium lib, Firefox and
> Chrome. What am I doing so wrong???
>
> Dne četrtek, 13. september 2012 21.21.21 UTC+2 je oseba Mohan R
> napisala:
>
> Figured out how to do it with RF - Selenium library
>
> using the (undocumented) function drag_and_drop_by_offset
>
> Just in case anyone else needs it..
>
> On Tue, Sep 11, 2012 at 3:49 PM, Mohan R <mohanr...@gmail.com>
> wrote:
>
> I want to interact with a slider in my test. Seems like
> Action Chains in Selenium are the way to do that.
>
> [selenium.webdriver.common.action_chains.ActionChains](http://goldb.org/sst/selenium2_api_docs/html/selenium.webdriver.common.action_chains.ActionChains-class.html)
> [How to mouseover in python Webdriver - Google
> Groups](https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/fj1RVXKvAew)
>
> But how do I do this with Selenium2Library?
> There seems to be no mouse down and mouse move functions in
> Selenium2Library.
>
> Or as a fallback, how do I access the underlying selenium
> library via Selenium2Library instance ?
> Seems like there is a way to do it in SeleniumLibrary (via
> "Call Selenium Api" function and class attribute
> seleniumlib =
> BuiltIn().get_library___instance('SeleniumLibrary'), self.selenium
> = seleniumlib.selenium).
>
> Thanks,
>
> --
> You received this message because you are subscribed to the
> Google Groups "robotframework-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/robotframework-users/-/ecycpjCucCgJ.
> To post to this group, send email to
> robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to
> robotframework-u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/robotframework-users?hl=en.
>
>
>
>
> --
> Mohan Raj
>
> --
> You received this message because you are subscribed to the Google
> Groups "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to robotframework-u...@googlegroups.com
> <mailto:robotframework-u...@googlegroups.com>.
> To post to this group, send email to
> robotframe...@googlegroups.com
> <mailto:robotframe...@googlegroups.com>.
---
Ta e-pošta je bila pregledana z Avast protivirusnim programom.
https://www.avast.com/antivirus

Ed Manlove

unread,
Dec 1, 2015, 9:20:03 PM12/1/15
to robotframe...@googlegroups.com
You might try a selenium only test to see if it work with just selenium.
Something like

import unittest
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

class DragAndDropTestCase(unittest.TestCase):

def setUp(self):
self.driver = webdriver.Firefox()

def test_drag_and_drop(self):
driver = self.driver
driver.get("http://www.my.sample.site.com")
el = driver.find_element_by_id("")
ActionChains(driver).drag_and_drop_by_offset(el, 450, 0).perform()
sleep(10)

def tearDown(self):
self.driver.close()

if __name__ == "__main__":
unittest.main()


Not I have not run this code and it may have bugs. If this works then
there could be an issue in the Selenium2Library code. It might also be
hepful if you have a sample test page that you can share. There is some
more information with the developers documentation [1] of the
Selenium2Library on how to do such tests with just selenium.

Ed

[1]
https://github.com/robotframework/Selenium2Library/blob/master/BUILD.rst#testing-selenium
Reply all
Reply to author
Forward
0 new messages