Skip to main content

Posts

Showing posts with the label drag drop dragAndDrop dragAndDropBy selenium

Selenium - Drag and Drop Operation

The inbuilt dragAndDrop function provided by selenium RC classes will do the expected operation well easily. Some times its difficult to do drag and drop operations like drop on particular element, etc. Here is the approach. 1. Drag an element to drop on to another element: driver. get ( "myURL" ) ; var from  =  driver. findElement ( By. xpath ( "fromElement" ) ) ; var to  =  driver. findElement ( By. xpath ( "toElement" ) ) ; new Actions ( driver ) . dragAndDrop ( from, to ) . build ( ) . perform ( ) ; 2. Drag an element to an offset: driver. get ( "myURL" ) ; var dragElement  =  browser. findElement ( By. id ( "ElementToDrag" ) ) ; new Actions ( driver ) . dragAndDropBy ( dragElement ,  200 ,  10 ) . build ( ) . perform ( ) ;