Syntax for drag and drop.
The Actions class has two methods that support Drag and Drop. Let's study them-
Actions.dragAndDrop(Sourcelocator, Destinationlocator)
In some applications, we may face a situation to automate drag and drop an item from one location to another location. We could not achieve these using basic elements. Selenium has provided an “Actions” class to handle this kind of scenarios. We overcome this kind of scenarios such as drag and drop using Actions Class.
Action Class in Selenium
In dragAndDrop method, we pass the two parameters -
First parameter "Sourcelocator" is the element which we need to drag.
Second parameter "Destinationlocator" is the element on which we need to drop the first element
Actions.dragAndDropBy(Sourcelocator, x-axis pixel of Destinationlocator, y-axis pixel of Destinationlocator)
dragAndDropBy method we pass the 3 parameters -
- First parameter "Sourcelocator" is the element which we need to drag.
- The second parameter is x-axis pixel value of the 2nd element on which we need to drop the first element.
- The third parameter is y-axis pixel value of the 2nd element on which we need to drop the first element.
You also get more information from this site.
Try This:-
WebDriver driver= new FirefoxDriver();
driver.get("https://www.bryntum.com/examples/scheduler/animations/");
//driver.get("https://demoqa.com/droppable/");
WebElement From=driver.findElement(By.xpath("//*[@id=\"b-scheduler-8-1-1-x\"]/div"));
WebElement To=driver.findElement(By.xpath("//*[@id=\"b-subgrid-14\"]/div[2]/div"));
Actions act=new Actions(driver);
//Dragged and dropped.
act.dragAndDrop(From, To).build().perform();
Hope it will work for you..
And for no such element go throgh this link.