Reputation: 11
"WebElement baseElement = driver.findElement(By.xpath("Element ID");
Actions clicker = new Actions(driver);
The element is not being moved to offset position given, instead dragging till the possible end whatever the offset value is like (0,0,), (2,0) etc.
But the element dragged is moving to its orginal position after a second.
Manually this is not happening, and able to drag till the position I wish within the limit.
This is just drag element on a bar, not a drag a drop element.
Also tried different drag related methods but nothing is working and facing the same situation.
Please help me out if any one has faced the same situation.
Tried with Selenium 2.27 to 2.40 on FF 17ESR, 20 and 24ESR and the issue repeats.
Upvotes: 0
Views: 587
Reputation: 1
Please find the below options.
Option 1:
WebElement eleFrom = driver.findElement(By.xpath("//*[@id='draggable']"));
WebElement eleTo = driver.findElement(By.xpath("//*[@id='droppable']"));
Actions action = new Actions(driver);
action.dragAndDrop(eleFrom, eleTo).perform();
Option 2:
Actions builder = new Actions(dr);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();
Option 3: We can use the below function in Actions class.
dragAndDropBy(WebElement source, int xOffset, int yOffset)
A convenience method that performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse.
Hope it helps, else feel free to revert.
Upvotes: 0