类org.openqa.selenium.interactions.Interactive源码实例Demo

下面列出了怎么用org.openqa.selenium.interactions.Interactive的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: vividus   文件: DragAndDropStepsTests.java
@Test
void shouldDragAndDropToTargetAtLocation()
{
    WebElement draggable = mockWebElementWithRect(100, 100, 50, 50);
    WebElement target = mockWebElementWithRect(200, 200, 50, 50);
    WebDriver driver = mock(WebDriver.class, withSettings().extraInterfaces(Interactive.class));
    when(webDriverProvider.get()).thenReturn(driver);
    testDragAndDropToTargetAtLocation(draggable, Location.TOP, target);
    String actionsSequence = String.format(
            "{id=default mouse, type=pointer, parameters={pointerType=mouse}, "
            + "actions=["
            + "{duration=100, x=0, y=0, type=pointerMove, origin=Mock for WebElement, hashCode: %s}, "
            + "{button=0, type=pointerDown}, "
            + "{duration=200, x=10, y=0, type=pointerMove, origin=pointer}, "
            + "{duration=200, x=-10, y=0, type=pointerMove, origin=pointer}, "
            + "{duration=200, x=100, y=50, type=pointerMove, origin=pointer}, "
            + "{button=0, type=pointerUp}, "
            + "{duration=1000, type=pause}]}", draggable.hashCode());
    verify((Interactive) driver).perform(
            argThat(arg -> arg.iterator().next().encode().toString().equals(actionsSequence)));
}
 
源代码2 项目: vividus   文件: DelegatingWebDriver.java
@Override
public void perform(Collection<Sequence> actions)
{
    if (wrappedDriver instanceof Interactive)
    {
        ((Interactive) wrappedDriver).perform(actions);
        return;
    }
    throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);
}
 
源代码3 项目: vividus   文件: DelegatingWebDriver.java
@Override
public void resetInputState()
{
    if (wrappedDriver instanceof Interactive)
    {
        ((Interactive) wrappedDriver).resetInputState();
        return;
    }
    throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);
}
 
源代码4 项目: vividus   文件: DelegatingWebDriverTests.java
@Test
void testPerform()
{
    WebDriver interactiveDriver = Mockito.mock(WebDriver.class, withSettings().extraInterfaces(Interactive.class));
    DelegatingWebDriver interactiveDelegatingDriver = new DelegatingWebDriver(interactiveDriver);
    interactiveDelegatingDriver.perform(List.of());
    verify((Interactive) interactiveDriver).perform(List.of());
}
 
源代码5 项目: vividus   文件: DelegatingWebDriverTests.java
@Test
void testResetInputState()
{
    WebDriver interactiveDriver = Mockito.mock(WebDriver.class, withSettings().extraInterfaces(Interactive.class));
    DelegatingWebDriver interactiveDelegatingDriver = new DelegatingWebDriver(interactiveDriver);
    interactiveDelegatingDriver.resetInputState();
    verify((Interactive) interactiveDriver).resetInputState();
}
 
源代码6 项目: vividus   文件: ActionStepsTests.java
@Test
void testExecuteActionsSequenceElementIsNull()
{
    SearchAttributes searchAttributes = new SearchAttributes(ActionAttributeType.XPATH, SIGNATURE_FIELD_XPATH);

    when(baseValidations.assertIfElementExists(ELEMENT_EXISTS_MESSAGE, searchAttributes)).thenReturn(null);

    List<SequenceAction> actions = List.of(
            new SequenceAction(SequenceActionType.DOUBLE_CLICK, searchAttributes),
            new SequenceAction(SequenceActionType.ENTER_TEXT, TEXT)
            );
    actionSteps.executeSequenceOfActions(actions);
    verify((Interactive) webDriver, never()).perform(any());
}
 
源代码7 项目: healenium-web   文件: ProxyFactory.java
public static <T extends WebDriver> SelfHealingDriver createDriverProxy(ClassLoader loader, InvocationHandler handler, Class<T> clazz) {
    Class<?>[] interfaces = Stream.concat(
        Arrays.stream(clazz.getInterfaces()),
        Stream.of(JavascriptExecutor.class, SelfHealingDriver.class, HasInputDevices.class, Interactive.class)
    ).distinct().toArray(Class[]::new);

    return (SelfHealingDriver) Proxy.newProxyInstance(loader, interfaces, handler);
}
 
源代码8 项目: selenium   文件: EventFiringWebDriver.java
@Override
public void perform(Collection<Sequence> actions) {
  if (driver instanceof Interactive) {
    ((Interactive) driver).perform(actions);
    return;
  }
  throw new UnsupportedOperationException("Underlying driver does not implement advanced"
                                          + " user interactions yet.");

}
 
源代码9 项目: selenium   文件: EventFiringWebDriver.java
@Override
public void resetInputState() {
  if (driver instanceof Interactive) {
    ((Interactive) driver).resetInputState();
    return;
  }
  throw new UnsupportedOperationException("Underlying driver does not implement advanced"
                                          + " user interactions yet.");

}
 
源代码10 项目: vividus   文件: ActionStepsTests.java
@SuppressWarnings("LineLength")
@Test
void testExecuteSequenceOfActions()
{
    SearchAttributes searchAttributes = new SearchAttributes(ActionAttributeType.XPATH, SIGNATURE_FIELD_XPATH);
    Point point = mock(Point.class);
    WebElement webElement = mock(WebElement.class);
    int offset = 15;

    when(baseValidations.assertIfElementExists(ELEMENT_EXISTS_MESSAGE, searchAttributes)).thenReturn(webElement);
    when(point.getX()).thenReturn(offset);
    when(point.getY()).thenReturn(offset);

    List<SequenceAction> actions = List.of(
            new SequenceAction(SequenceActionType.DOUBLE_CLICK, searchAttributes),
            new SequenceAction(SequenceActionType.CLICK_AND_HOLD, searchAttributes),
            new SequenceAction(SequenceActionType.MOVE_BY_OFFSET, point),
            new SequenceAction(SequenceActionType.RELEASE, searchAttributes),
            new SequenceAction(SequenceActionType.ENTER_TEXT, TEXT),
            new SequenceAction(SequenceActionType.CLICK, searchAttributes),
            new SequenceAction(SequenceActionType.MOVE_TO, searchAttributes),
            new SequenceAction(SequenceActionType.DOUBLE_CLICK, null),
            new SequenceAction(SequenceActionType.CLICK_AND_HOLD, null),
            new SequenceAction(SequenceActionType.RELEASE, null),
            new SequenceAction(SequenceActionType.CLICK, null)
            );
    actionSteps.executeSequenceOfActions(actions);
    verify((Interactive) webDriver).perform(argThat(arg -> {
        int hash = webElement.hashCode();
        String mouseSequence = "{id=default mouse, type=pointer, parameters={pointerType=mouse}, actions=["
                + format(POINTER_MOVE, hash)
                + DOUBLE_CLICK_ACTION + SEPARATOR
                + format(POINTER_MOVE, hash)
                + CLICK_AND_HOLD_ACTION + SEPARATOR
                + "{duration=200, x=15, y=15, type=pointerMove, origin=pointer}" + SEPARATOR
                + format(POINTER_MOVE, hash)
                + RELEASE_ACTION + SEPARATOR
                + DURATION_PART + DURATION_PART
                + format(POINTER_MOVE, hash)
                + CLICK_ACTION + SEPARATOR
                + format(POINTER_MOVE_ACTION, hash) + SEPARATOR
                + DOUBLE_CLICK_ACTION + SEPARATOR
                + CLICK_AND_HOLD_ACTION + SEPARATOR
                + RELEASE_ACTION + SEPARATOR
                + CLICK_ACTION
                + "]}";
        String keyboardSequence = "{type=key, actions=["
                + DURATION_PART + DURATION_PART
                + "{duration=0, type=pause}, {duration=0, type=pause}, "
                + "{type=keyDown, value=t}, {type=keyUp, value=t}, {type=keyDown, value=e}, {type=keyUp, value=e}, "
                + "{type=keyDown, value=x}, {type=keyUp, value=x}, {type=keyDown, value=t}, {type=keyUp, value=t}, "
                + "{duration=0, type=pause}, {duration=0, type=pause}, {duration=0, type=pause}, {duration=0, type=pause},"
                + " {duration=0, type=pause}, {duration=0, type=pause}, {duration=0, type=pause}, {duration=0, type=pause},"
                + " {duration=0, type=pause}, {duration=0, type=pause}, {duration=0, type=pause}, {duration=0, type=pause}], "
                + "id=default keyboard}";
        return asString(arg).equals(mouseSequence + keyboardSequence);
    }));
}
 
 类所在包
 类方法
 同包方法