All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.appium.java_client.flutter.commands.LongPressParameter Maven / Gradle / Ivy

The newest version!
package io.appium.java_client.flutter.commands;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.internal.Require;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Accessors(chain = true)
@Setter
@Getter
public class LongPressParameter extends FlutterCommandParameter {
    private WebElement element;
    private Point offset;

    @Override
    public Map toJson() {
        Require.precondition(element != null || offset != null,
                "Must supply a valid element or offset to perform flutter gesture event");

        Map params = new HashMap<>();
        Optional.ofNullable(element).ifPresent(element -> params.put("origin", element));
        Optional.ofNullable(offset).ifPresent(offset ->
                params.put("offset", Map.of("x", offset.getX(), "y", offset.getY())));
        return Collections.unmodifiableMap(params);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy