How to use build method of io.appium.java_client.touch.ActionOptions class

Best io.appium code snippet using io.appium.java_client.touch.ActionOptions.build

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

AbstractOptionCombinedWithPosition.java

Source: AbstractOptionCombinedWithPosition.java Github

copy
1package io.appium.java_client.touch.offset;
2
3import static java.util.Optional.ofNullable;
4
5import io.appium.java_client.touch.ActionOptions;
6
7import java.util.Map;
8
9public abstract class AbstractOptionCombinedWithPosition<T extends AbstractOptionCombinedWithPosition<T>>
10        extends ActionOptions<AbstractOptionCombinedWithPosition<T>> {
11    private ActionOptions<?> positionOption;
12
13    /**
14     * Some actions may require coordinates. Invocation of this method
15     * replaces the result of previous {@link #withElement(ElementOption)} invocation.
16     *
17     * @param positionOption required coordinates.     *
18     * @return self-reference
19     */
20    public T withPosition(PointOption positionOption) {
21        this.positionOption = positionOption;
22        return (T) this;
23    }
24
25    /**
26     * Most of touch action may use position which is relative to some element. In order to unify
27     * this behaviour this method was added. Invocation of this method
28     * replaces the result of previous {@link #withPosition(PointOption)} invocation.
29     *
30     * @param element required position which is relative to some element
31     * @return self-reference
32     */
33    public T withElement(ElementOption element) {
34        positionOption = element;
35        return (T) this;
36    }
37
38    protected void verify() {
39        ofNullable(positionOption).orElseThrow(() ->
40                new IllegalArgumentException("Some coordinates or an offset from an element should "
41                        + "be defined. Use withPosition or withElement methods"));
42    }
43
44    @Override
45    public Map<String, Object> build() {
46        final Map<String, Object> result = super.build();
47        result.putAll(positionOption.build());
48        return result;
49    }
50}
51
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in ActionOptions

Trigger build code on LambdaTest Cloud Grid

Execute automation tests with build on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)