Robotframework / Selenium2Library: Why does Drag And Drop not work with draggable elements?

痞子三分冷 提交于 2019-12-06 12:16:33

问题


If you have python (v2.7), robotframework (v2.8.7) and Selenium2Library (v1.6.0) installed, you could run the following test case to get the idea of the problem, e.g. using: pybot -L TRACE

*** Settings ***
Library           Selenium2Library

*** Variables ***

*** Test Cases ***
DragDemo
    Open Browser    http://www.w3schools.com/html/html5_draganddrop.asp    firefox    
    # NO VISIBLE ACTION HERE, BUT COMMANDS TAKE SOME MINUTES TO EXECUTE WITHOUT FAILURE
    Wait Until Page Contains Element    //img[@id='drag1']
    Drag And Drop   //img[@id='drag1']  //div[@id='div2']
    Drag And Drop By Offset     //img[@id='drag1']  50  0
    Drag And Drop By Offset     //img[@draggable='true']    100     0
    Drag And Drop By Offset     //img[@alt='W3Schools']    10     -10
    Mouse Down  //img[@id='drag1']
    Mouse Over  //div[@id='div2']
    Mouse Up    //div[@id='div2']
    # DRAG AND DROP ACTION HERE
    Drag And Drop By Offset     //span[contains(text(),'Drag and Drop')]    500     -500
    Sleep   5

*** Keywords ***    

The test navigates to a public web site and tries to drag and drop a draggable element in various ways. As mentioned in the inline comments, the commands are executed without failure but without visible effect. The last drag and drop command, however, is executed on a non-draggable element and, oddly enough, there is some action (text is marked). The testlog reveals that POST is executed in either case. How come, the other DnD commands do not work as expected?

来源:https://stackoverflow.com/questions/28855266/robotframework-selenium2library-why-does-drag-and-drop-not-work-with-draggabl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!