Created
January 25, 2019 09:31
-
-
Save redcatsec/5ef44f7f3ddb176415d492292f405784 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
// ich verstehe nicht warum hier die perform() funktioniert nicht fehlt was im Code oder was ? | |
package MyTestPakage; | |
//this Code made by Almo | |
import org.openqa.selenium.*; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.interactions.Action; | |
import org.openqa.selenium.interactions.Actions; | |
public class Test { | |
public static void main(String[] args) throws InterruptedException { | |
//Creating a driver object referencing WebDriver interface | |
WebDriver driver; | |
//Setting webdriver.gecko.driver property | |
System.setProperty("webdriver.gecko.driver", "library/geckodriver"); | |
//Instantiating driver object and launching browser | |
driver = new FirefoxDriver(); | |
//Using get() method to open a webpage | |
driver.navigate().to("https://artoftesting.com/sampleSiteForSelenium.html"); | |
//findig a Elements that we want apply the action on it | |
WebElement sourceImage = driver.findElement(By.id("sourceImage")); | |
WebElement targetDiv = driver.findElement(By.id("targetDiv")); | |
try{ | |
JavascriptExecutor js = (JavascriptExecutor) driver; | |
js.executeScript("scrollBy(0,2500)"); | |
}catch (JavascriptException jse){ | |
System.out.println(jse.getMessage()); | |
} | |
// building an Action or Event to apply | |
Actions action = new Actions(driver); | |
// building an action | |
Action dargAndDropAction = action | |
.clickAndHold(sourceImage) | |
.moveToElement(targetDiv) | |
.release(targetDiv) | |
.build(); | |
//performing the Action Event on the Element | |
dargAndDropAction.perform(); | |
//sleep to see the Result | |
Thread.sleep(3000); | |
//quit the Browser and end the Program | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment