drag and drop using selenium

package SeleniumWebDriver;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class DraganddropSqure {
    WebDriver driver;
    
     @Test
      public void draganddropSqure() throws Exception {
          driver.get("http://www.seleniumlearn.com/drag-and-drop-html");
         driver.manage().timeouts().implicitlyWait(39, TimeUnit.SECONDS);
          
          Actions act=new Actions(driver);
          WebElement source=driver.findElement(By.id("draggable")); // Find the first WebElement using the given method.
          WebElement target=driver.findElement(By.id("droppable"));
          act.dragAndDrop(source,target).perform();
          
      }
  @BeforeTest
  public void beforeTest() {
      driver=new FirefoxDriver();
      driver.manage().window().maximize();
  }

  @AfterTest
  public void afterTest() {
  }

}

Tags: