Created
December 12, 2014 17:03
-
-
Save ederign/f7662e1e3cc558c698ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://html5demos.com/drag" ); | |
String dnd1 = "$('#one').simulateDragDrop({ dropTarget: '#bin'});"; | |
String dnd2 = "$('#two').simulateDragDrop({ dropTarget: '#bin'});"; | |
((JavascriptExecutor) driver) | |
.executeScript(jquery); | |
((JavascriptExecutor) driver) | |
.executeScript(js); | |
((JavascriptExecutor) driver ) | |
.executeScript( dnd1 ); | |
((JavascriptExecutor) driver ) | |
.executeScript( dnd2 ); | |
System.out.println(""); | |
driver.navigate().to( "http://the-internet.herokuapp.com/drag_and_drop" ); | |
((JavascriptExecutor) driver) | |
.executeScript(jquery); | |
((JavascriptExecutor) driver) | |
.executeScript(js); | |
String dnd11 = "$('#column-a').simulateDragDrop({ dropTarget: '#column-b'});"; | |
((JavascriptExecutor) driver ) | |
.executeScript( dnd11 ); | |
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