"Drag and Drop" function not supported in selenium2library ? #60

Closed
mamathanag opened this Issue Jun 5, 2012 · 13 comments

Projects

None yet

6 participants

@mamathanag

Guys,

I have a requirement to automate Dragging one element from source and dropping it into a target element. I see that drag and drop is not supported in selenium2library. Any alternatives? I am thinking of copying the same from Selenium1.

-Mamatha

@emanlove

This functionality is supported under Selenium 2 / WebDriver (using action_chains). It's easy enough to create a keyword for it with the only question should we keep the function call the same as the old selenium library,

drag_and_drop(self, locator, movement=None, target=None)

or should it directly correspond with selenium call, such as

drag_and_drop(self, source, target) *

which I think is cleaner but might break what people are used to. We could leave the drag and drop call as is and add functions like

drag_and_drop_on_target(self, source, target)
drag_and_drop_by_offset(self, source, xoffset, yoffset)

for which the new selenium2library keyword, 'Drag and Drop', could call depending on the movement/target parameters or could be called directly.

* where source is the same as locator

@j1z0
@mamathanag

@emanlove @j1z0,

Just to bring this issue to closure, documenting what we have implemented in our project and works fine.

Edited element.py and added the following keyword(function)

def drag_and_drop(self, source, target):
"""Drags element identified with locator by movement

    `movement is a string in format "+70 -300" interpreted as pixels in
    relation to elements current position.
    """
    actionChains = ActionChains(self)
    element = self._element_find(source,True,True)
    target =  self._element_find(target,True,True)
    ActionChains(self._current_browser()).drag_and_drop(element, target).perform()
@j1z0 j1z0 was assigned Jun 30, 2012
@j1z0

I believe we should just follow what is in webdriver, which is different from what was in selenium. In web driver it is:

drag_and_drop(self, source, target)
drag_and_drop_by_offset(self, source, xoffset, yoffset)

in such a way it would break for existing selenium users that were using offsets, but it keep things in line with web driver and will be easier for new users coming from web driver.

@j1z0 j1z0 closed this in 19b809b Jun 30, 2012
@dkoudrin

Drag and Drop in Selenium2Library is NOT working for me... It used to work fine in SeleniumLibrary.

@daluu

FYI, for issues with drag & drop, it would help if one indicates which browser. There are some browser specific issues with WebDriver drag & drop, and SafariDriver has no support for it natively (one would have to use javascript fallback).

@dkoudrin

Hi, sorry, firefox 21 is the browser.

@daluu

Also forgot to mention, any specific public site (or custom HTML file(s)) for testing the issue against? Or is it generally reproducible for any given site using the library and FF 21? It would help to provide the test site or files to reproduce the issue against.

And also, if one is able to use Selenium 2 / WebDriver directly outside of Robot Framework, it also helps to see if issue reproduces there as well to narrow down the problem of whether it is with this library or Selenium itself (or the Python bindings to it). If it is the latter than the former, you'd then have to raise the issue with the Selenium team itself (submit Selenium issue or post to their Google discussion groups).

@dkoudrin

Nah sorry, it is an internal only website, cannot provide it outside the company :(

I use selenium2library in a robot test (run through RIDE). All I've changed is upgraded from importing seleniumlibrary to selenium2library. Now drag and drop fails (and A LOT of other keywords but I am slowly fixing those up).

@ahitrin

@dkoudrin try to run your tests with older version of Firefox (19 or 20). The problem is that Firefox 21 currently is not fully supported by Selenium (see https://code.google.com/p/selenium/source/browse/py/CHANGES for more info).

@dkoudrin

Oh really? Well that's bad news, the whole point of me upgrading to selenium2 was so I could run tests on the latest firefox.

@ahitrin

@dkoudrin You can use the almost latest version, so the news are no so bad :)

@dkoudrin

Yes, but 'almost' doesn't satisfy my boss's requirements...

@j1z0 j1z0 was unassigned by mamathanag Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment