Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium hangs when using actionchain().move then actionchain.click or mouse_up

I'm using selenium2library for automation testing for drag drop action. I'm running on windows 8 64bit, selenium 2.48.0, ride.py. Browser used to test: firefox and chrome latest stable version

what I did was to create a dummy html page with input text and a link, and try drag that link into the input text

Here is the html:

<div id="wrapper">

<input id="target" type="text" style="width:200px; height:50px" />
</div>
<a id="source" href="http://google.com" >drag me </a>

And here is my python code for automation:

class CustomSeleniumLibrary(Selenium2Library):
...
    def test_drag(self):
        self.open_browser("http://localhost:8080/a.html", "firefox")
        source = self._element_find("//a[@id='source']", True, True)
        target = self._element_find("//input[@id='target']", True, True)
        drag = ActionChains(self._current_browser()).click_and_hold(source)
        moveDum = ActionChains(self._current_browser()).move_by_offset(1,1)
        move = ActionChains(self._current_browser()).move_to_element_with_offset(target,1,1)
        #I have also tried ActionChains().drag_and_drop().perform() or make a dummy move move_by_offset followed by move_to_element_with_offset but no use
        drag.perform()
        moveDum.perform()
       move.perform()

What I found is when the move finish or mouse_down() finish, the next action is not performed, I can see the link get holded, but no move action performs until I manually move my mouse on the browser. ride.py UI flicks at that time and the request: 16:24:47.042 : DEBUG : POST http://127.0.0.1:58095/hub/session/fa7590b6-396f-4cb5-a08a-e35138a9216e/moveto {"sessionId": "fa7590b6-396f-4cb5-a08a-e35138a9216e", "element": "{6586b4ae-3c51-4e18-bb40-e006af369768}", "xoffset": 1, "yoffset": 1}

hangs forever until I move the mouse manually on the browser

Do anyone of you got the same problem, or did I do something wrong? And do you have any suggestion for using draganddrop feature using robotframework selenium2library?

Best regards, Dan

like image 716
Dan Le Avatar asked Jan 12 '16 03:01

Dan Le


1 Answers

I cannot check it, but as I remember ActionChains works in this way:

actions = ActionChains(self._current_browser())
actions.click_and_hold(source)
actions.move_by_offset(1,1)
actions.move_to_element_with_offset(target,1,1)
actions.perform()

Let me know if this code works incorrectly

like image 166
Andersson Avatar answered Oct 15 '22 04:10

Andersson