Sunday, January 26, 2020

Drag and Drop Example

0 comments

Drag and Drop is can be performed by using the Actions Class




********************CODE*********************

package aveditor;
import java.util.List;

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;
import org.openqa.selenium.support.ui.Select;



public class NewTest {
public static void main(String []args) throws Exception
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", ".\\ChromeDriverPath\\chromedriver.exe");
driver=new ChromeDriver();
driver.get("https://automaticselenium.blogspot.com/p/example-drag-and-drop.html");
driver.manage().window().maximize(); //Maximize the Window after Opening the Links
// Actions Class
Actions actions=new Actions(driver);
// Select the Dragging object
WebElement drag= driver.findElement(By.id("draggable"));
// Select the droping Position
WebElement drop= driver.findElement(By.id("droppable"));
// Perform the Action 
actions.dragAndDrop(drag, drop).build().perform();
}
}


----------------------------------------------------------------------------------
Refer this link to see all the methods in the Actions Class
Link:https://automaticselenium.blogspot.com/2020/01/actions-class-list-of-all-methods.html

No comments:

Post a Comment