Skip to content

Instantly share code, notes, and snippets.

@ederign
Created December 16, 2014 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ederign/49fe3bc2be617dcd247e to your computer and use it in GitHub Desktop.
Save ederign/49fe3bc2be617dcd247e to your computer and use it in GitHub Desktop.
import java.io.IOException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import static java.nio.file.Files.readAllBytes;
import static java.nio.file.Paths.get;
public class Test {
public static void main( String[] args ) throws IOException {
WebDriver driver = null;
try {
//for Chrome
System.setProperty( "webdriver.chrome.driver", "/Users/ederign/Downloads/chromedriver" );
//driver = new ChromeDriver();
driver = new FirefoxDriver();
// DND JS LIB
//https://gist.github.com/rcorreia/2362544
//https://gist.githubusercontent.com/rcorreia/2362544/raw/3319e506e204af262d27f7ff9fca311e693dc342/drag_and_drop_helper.js
String js = new String( readAllBytes( get( "/Users/ederign/Downloads/drag_and_drop_helper.js" ) ) );
//Jquery
String jquery = new String( readAllBytes( get( "/Users/ederign/Downloads/jquery-1.11.1.min.js" ) ) );
driver.navigate().to( "http://localhost:8080/kie/" );
// driver.navigate().to( "http://127.0.0.1:8888/kie-wb.html" );
String dnd1 = "$('#a').simulateDragDrop({ dropTarget: '#c'});";
String dnd2 = "$('#b').simulateDragDrop({ dropTarget: '#c'});";
((JavascriptExecutor) driver)
.executeScript(jquery);
((JavascriptExecutor) driver)
.executeScript(js);
((JavascriptExecutor) driver )
.executeScript( dnd1 );
((JavascriptExecutor) driver )
.executeScript( dnd2 );
System.out.println("");
} finally {
driver.close();
driver.quit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment