Robotframework / Selenium2Library: Why does Drag A

2020-07-30 00:53发布

问题:

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?