In this session you will learn how to handle drag and drop on a web page
we used Actions class to handle this scenario
You can download this example program by scrolling to the bottom on the description and also you can import the complete example programs from below GitHub Repository
https://github.com/knowledgeshare-tec...
*******************************************************************
You can see step by step selenium sessions from below playlist
*******************************************************************
• How to handle WebTables using Selenium Web...
***********************************************
For regular updates you can join this Group
***********************************************
/ 4754296501308288
****************************************************
Overview on Drag and Drop
****************************************************
What is Drag and Drop
Dragging a an element or list from once space to another space with in a webpage
Example : Website builders
What test we perform on this Drag and Drop
Adding a list from one hand to other hand in few applications
How to Handle Drag and Drop
Actions class is required to handle drag and drop
Methods available to handle drag and drop
Method _ 1
.dragAndDrop(From, To).build().perform();
Method_2
.clickAndHold(From)
.release(To)
.dragAndDrop.perform()
***************************************************************
Example program for Handling Drag and Drop
( Using Actions class and single method )
***************************************************************
package com.seleniumbasics;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class Drag_and_Drop_Example {
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", ".\\drivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://demo.guru99.com/test/drag_drop...");
driver.manage().window().maximize();
WebElement From=driver.findElement(By.xpath("//*[@id=\"credit2\"]/a"));
WebElement To=driver.findElement(By.xpath("//*[@id=\"bank\"]/li"));
Actions actions=new Actions(driver);
actions.dragAndDrop(From, To).build().perform();
}
}
コメント