to perform drag and drop in selenium.

Solved 1 Answers 54 Views Selenium
0 1
i am using this url  "http://www.dhtmlgoodies.com/submitted-scripts/i-google-like-drag-drop/index.html", apart form that url i need to perform on block 3,it should be moved  below block4.i had writeen the script but it is not working properly  could you please update me as early as possible where i need to change.
package practise;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class Draganddrop {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement src=driver.findElement(By.xpath("//div/div[@id='column-3']"));//div[@id='column-3']
WebElement dest=driver.findElement(By.xpath("//h1[text()='Block 3']"));
Actions act=new Actions(driver);
//act.dragAndDrop(src, dest).perform();


1 Answer

Best answer

I guess swaping elements should work for you. It should be.

WebElement src=driver.findElement(By.xpath("//h1[text()='Block 3']"));

WebElement dest=driver.findElement(By.xpath("//div/div[@id='column-3']"));
Let me know how it goes.
answered by
selected by
commented by
moved by
now it is being worked successfully thank you so much to given correct answer
commented by
Welcome! I am glad it worked for you. Feel free to drop more questions here.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.