-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex5_MoveThings.java
54 lines (39 loc) · 1.58 KB
/
ex5_MoveThings.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package examples;
import java.util.logging.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import utils.Config;
public class ex5_MoveThings {
private static final Logger logger = Config.getLogger(ex5_MoveThings.class);
public static void main(String[] args) {
new ex5_MoveThings();
}
public ex5_MoveThings() {
Config cfg = new Config();
// Look at util.Config.createInstance for details
WebDriver drv = cfg.createInstance();
drv.navigate().to(cfg.get("site_url"));
logger.info("At the test site...");
this.moveStuff(drv);
drv.close();
}
public void moveStuff(WebDriver drv) {
Actions act = new Actions(drv);
logger.info("Showing kitty");
WebElement button = drv.findElement(By.cssSelector(".kittyStart input"));
act.click(button).perform();
logger.info("Moving kitty");
WebElement kitty = drv.findElement(By.id("kitty"));
act.moveToElement(kitty).clickAndHold().moveByOffset(200, 0).release().perform();
logger.info("Slowly moving kitty");
for (int i = 0; i < 10; i++) {
act.moveToElement(kitty).clickAndHold().moveByOffset(20, 0).release().perform();
}
logger.info("Feeding kitty");
WebElement bowl = drv.findElement(By.cssSelector(".kittyBowl"));
act.clickAndHold(kitty).moveToElement(bowl, -120, -60).release().perform();
logger.info("Bon Appétit Kitty ");
}
}