Automation Using Selenium Webdriver
Showing posts with label DragandDrop. Show all posts
Showing posts with label DragandDrop. Show all posts

Monday 1 August 2016

DrogandDrop Best Example

package com.Test.web;

import java.util.concurrent.TimeUnit;

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 DragandDrop {

public static void main(String[] args) {
/*
* ##########################################################
* ComponentName : DragandDrop
* Description   : It Action on WebElement DragandDrop Oparation
*  Created By   : Team
* Creation Date : 1th Aug 2016
* Author        : T Jagan
* ##########################################################
   */

System.out.println("*************************************************");
        System.out.println("Execution is started");

System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
Actions action=new Actions(driver);

        driver.get("http://www.dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html");
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
     
        WebElement source=driver.findElement(By.id("box1"));
        WebElement target=driver.findElement(By.id("box101"));
     
        if (source.isDisplayed() && source.isEnabled() && target.isDisplayed() && target.isEnabled())
     
             {
System.out.println("Element is Present");
action.dragAndDrop(source, target);
action.build().perform();
}
             else
             {
            System.out.println("Element not Present");
             }

    }  
     
}