Skip to content

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

Closed

Description

@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

Activity

  1. emanlove commented on Jun 5, 2012

    @emanlove
    Member

    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

  2. j1z0 commented on Jun 5, 2012

    @j1z0
    Contributor

    Yeah I think copying from selenium 1 library wound be the best way to go. However im not sure if the action chains API is the same between selenium 1 and webdriver.

    Cheers,
    Jeremy

    On Jun 5, 2012, at 15:53, mamathanagreply@reply.github.com wrote:

    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


    Reply to this email directly or view it on GitHub:
    #60

  3. mamathanag commented on Jun 12, 2012

    @mamathanag
    Author

    @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()
    
  4. ghost assigned on Jun 30, 2012
  5. j1z0 commented on Jun 30, 2012

    @j1z0
    Contributor

    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.

  6. dkoudrin commented on Jun 5, 2013

    @dkoudrin

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

  7. daluu commented on Jun 6, 2013

    @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).

  8. dkoudrin commented on Jun 6, 2013

    @dkoudrin

    Hi, sorry, firefox 21 is the browser.

  9. daluu commented on Jun 6, 2013

    @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).

  10. dkoudrin commented on Jun 6, 2013

    @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).

  11. ahitrin commented on Jun 6, 2013

    @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).

  12. dkoudrin commented on Jun 6, 2013

    @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.

  13. ahitrin commented on Jun 6, 2013

    @ahitrin

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

  14. dkoudrin commented on Jun 6, 2013

    @dkoudrin

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions