use of org.openqa.selenium.interactions.Sequence in project dollarx by loyada.
the class SingleBrowserPathIntegrationTest method DragAndDropToElement.
@Test
public void DragAndDropToElement() throws Operations.OperationFailedException {
div.dragAndDrop().to(span);
verify(((Interactive) driverMock)).perform(captor.capture());
Object[] actions = captor.getAllValues().get(0).toArray();
Sequence firstSequence = (Sequence) actions[0];
Map<String, Object> keysActions = firstSequence.toJson();
assertThat(keysActions.get("type"), equalTo("pointer"));
List<Map<String, Object>> ops = (List<Map<String, Object>>) keysActions.get("actions");
assertThat(ops.get(0).get("type"), equalTo("pointerMove"));
assertThat(ops.get(0).get("origin"), is(webElement));
assertThat(ops.get(1).get("type"), equalTo("pointerDown"));
assertThat(ops.get(2).get("type"), equalTo("pointerMove"));
assertThat(ops.get(2).get("origin"), is(webElement2));
assertThat(ops.get(ops.size() - 1).get("type"), equalTo("pointerUp"));
}
use of org.openqa.selenium.interactions.Sequence in project dollarx by loyada.
the class SingleBrowserPathIntegrationTest method sendKeysToElement.
@Test
public void sendKeysToElement() throws Operations.OperationFailedException {
div.sendKeys("abc", "d");
verify(((Interactive) driverMock)).perform(captor.capture());
Object[] actions = captor.getAllValues().get(0).toArray();
Sequence firstSequence = (Sequence) actions[0];
final int keyboardInd = firstSequence.toJson().get("type").equals("key") ? 0 : 1;
List<Map<String, Object>> ops = (List<Map<String, Object>>) ((Sequence) actions[keyboardInd]).toJson().get("actions");
// first 3 actions are with pointer: move, clickdown, clickup
List<Map<String, Object>> keysOps = ops.subList(3, ops.size());
List<Object> keys = keysOps.stream().map(op -> op.get("value")).collect(Collectors.toList());
assertEquals(keys, Arrays.asList("a", "a", "b", "b", "c", "c", "d", "d"));
List<Object> opsTypesWithKeys = keysOps.stream().map(op -> op.get("type")).collect(Collectors.toList());
assertEquals(opsTypesWithKeys, Arrays.asList("keyDown", "keyUp", "keyDown", "keyUp", "keyDown", "keyUp", "keyDown", "keyUp"));
}
use of org.openqa.selenium.interactions.Sequence in project dollarx by loyada.
the class BrowserActionsIntegrationTest method DragAndDropToOffset.
@Test
public void DragAndDropToOffset() throws Operations.OperationFailedException {
browser.dragAndDrop(BasicPath.div).to(10, 10);
verify(((Interactive) driverMock)).perform(captor.capture());
Object[] actions = captor.getAllValues().get(0).toArray();
Sequence firstSequence = (Sequence) actions[0];
Map<String, Object> keysActions = firstSequence.toJson();
assertThat(keysActions.get("type"), equalTo("pointer"));
List<Map<String, Object>> ops = (List<Map<String, Object>>) keysActions.get("actions");
assertThat(ops.get(0).get("type"), equalTo("pointerMove"));
assertThat(ops.get(0).get("origin"), is(webElement));
assertThat(ops.get(1).get("type"), equalTo("pointerDown"));
assertThat(ops.get(2).get("type"), equalTo("pointerMove"));
assertThat(ops.get(2).get("x"), is(10));
assertThat(ops.get(2).get("y"), is(10));
assertThat(ops.get(ops.size() - 1).get("type"), equalTo("pointerUp"));
}
use of org.openqa.selenium.interactions.Sequence in project dollarx by loyada.
the class BrowserActionsIntegrationTest method scroll.
@Test
public void scroll() {
browser.scrollTo(BasicPath.div);
verify(((Interactive) driverMock)).perform(captor.capture());
Object[] actions = captor.getAllValues().get(0).toArray();
Sequence firstSequence = (Sequence) actions[0];
Map<String, Object> firstActions = firstSequence.toJson();
assertThat(firstActions.get("type"), equalTo("pointer"));
Map<String, Object> op = ((List<Map<String, Object>>) firstActions.get("actions")).get(0);
assertThat(op.get("type"), equalTo("pointerMove"));
assertThat(op.get("origin"), is(webElement));
}
use of org.openqa.selenium.interactions.Sequence in project dollarx by loyada.
the class BrowserActionsIntegrationTest method sendKeysToBrowser.
@Test
public void sendKeysToBrowser() {
browser.sendKeys("x", "yz").toBrowser();
verify(((Interactive) driverMock)).perform(captor.capture());
Object[] actions = captor.getAllValues().get(0).toArray();
Sequence firstSequence = (Sequence) actions[0];
assertThat(firstSequence.toJson().get("type"), equalTo("key"));
List<Map<String, Object>> ops = (List<Map<String, Object>>) firstSequence.toJson().get("actions");
List<Object> keys = ops.stream().map(op -> op.get("value")).collect(Collectors.toList());
assertEquals(keys, Arrays.asList("x", "x", "y", "y", "z", "z"));
}
Aggregations