How to use SupportsPrerunOption class of io.appium.java_client.remote.options package

Best io.appium code snippet using io.appium.java_client.remote.options.SupportsPrerunOption

Run io.appium automation tests on LambdaTest cloud grid

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

WindowsOptions.java

Source: WindowsOptions.java Github

copy
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * See the NOTICE file distributed with this work for additional
5 * information regarding copyright ownership.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package io.appium.java_client.windows.options;
18
19import io.appium.java_client.remote.AutomationName;
20import io.appium.java_client.remote.MobilePlatform;
21import io.appium.java_client.remote.options.BaseOptions;
22import io.appium.java_client.remote.options.SupportsAppOption;
23import io.appium.java_client.remote.options.SupportsPostrunOption;
24import io.appium.java_client.remote.options.SupportsPrerunOption;
25import org.openqa.selenium.Capabilities;
26
27import java.util.Map;
28import java.util.Optional;
29
30/**
31 * https://github.com/appium/appium-windows-driver#usage
32 */
33public class WindowsOptions extends BaseOptions<WindowsOptions> implements
34        SupportsAppOption<WindowsOptions>,
35        SupportsAppArgumentsOption<WindowsOptions>,
36        SupportsAppTopLevelWindowOption<WindowsOptions>,
37        SupportsAppWorkingDirOption<WindowsOptions>,
38        SupportsCreateSessionTimeoutOption<WindowsOptions>,
39        SupportsMsWaitForAppLaunchOption<WindowsOptions>,
40        SupportsMsExperimentalWebDriverOption<WindowsOptions>,
41        SupportsSystemPortOption<WindowsOptions>,
42        SupportsPrerunOption<WindowsOptions, PowerShellData>,
43        SupportsPostrunOption<WindowsOptions, PowerShellData> {
44    public WindowsOptions() {
45        setCommonOptions();
46    }
47
48    public WindowsOptions(Capabilities source) {
49        super(source);
50        setCommonOptions();
51    }
52
53    public WindowsOptions(Map<String, ?> source) {
54        super(source);
55        setCommonOptions();
56    }
57
58    private void setCommonOptions() {
59        setPlatformName(MobilePlatform.WINDOWS);
60        setAutomationName(AutomationName.WINDOWS);
61    }
62
63    /**
64     * An object containing either script or command key. The value of
65     * each key must be a valid PowerShell script or command to be
66     * executed prior to the WinAppDriver session startup.
67     * See
68     * https://github.com/appium/appium-windows-driver#power-shell-commands-execution
69     * for more details.
70     *
71     * @param script E.g. {script: 'Get-Process outlook -ErrorAction SilentlyContinue'}.
72     * @return self instance for chaining.
73     */
74    public WindowsOptions setPrerun(PowerShellData script) {
75        return amend(PRERUN_OPTION, script.toMap());
76    }
77
78    /**
79     * Get the prerun script.
80     *
81     * @return Prerun script.
82     */
83    public Optional<PowerShellData> getPrerun() {
84        //noinspection unchecked
85        return Optional.ofNullable(getCapability(PRERUN_OPTION))
86                .map((v) -> new PowerShellData((Map<String, Object>) v));
87    }
88
89    /**
90     * An object containing either script or command key. The value of
91     * each key must be a valid PowerShell script or command to be
92     * executed after an WinAppDriver session is finished.
93     * See
94     * https://github.com/appium/appium-windows-driver#power-shell-commands-execution
95     * for more details.
96     *
97     * @param script E.g. {script: 'Get-Process outlook -ErrorAction SilentlyContinue'}.
98     * @return self instance for chaining.
99     */
100    public WindowsOptions setPostrun(PowerShellData script) {
101        return amend(POSTRUN_OPTION, script.toMap());
102    }
103
104    /**
105     * Get the postrun script.
106     *
107     * @return Postrun script.
108     */
109    public Optional<PowerShellData> getPostrun() {
110        //noinspection unchecked
111        return Optional.ofNullable(getCapability(POSTRUN_OPTION))
112                .map((v) -> new PowerShellData((Map<String, Object>) v));
113    }
114}
115
Full Screen

Mac2Options.java

Source: Mac2Options.java Github

copy
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * See the NOTICE file distributed with this work for additional
5 * information regarding copyright ownership.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package io.appium.java_client.mac.options;
18
19import io.appium.java_client.remote.AutomationName;
20import io.appium.java_client.remote.MobilePlatform;
21import io.appium.java_client.remote.options.BaseOptions;
22import io.appium.java_client.remote.options.SupportsPostrunOption;
23import io.appium.java_client.remote.options.SupportsPrerunOption;
24import org.openqa.selenium.Capabilities;
25
26import java.util.Map;
27import java.util.Optional;
28
29/**
30 * https://github.com/appium/appium-mac2-driver#capabilities
31 */
32public class Mac2Options extends BaseOptions<Mac2Options> implements
33        SupportsSystemPortOption<Mac2Options>,
34        SupportsSystemHostOption<Mac2Options>,
35        SupportsWebDriverAgentMacUrlOption<Mac2Options>,
36        SupportsBootstrapRootOption<Mac2Options>,
37        SupportsBundleIdOption<Mac2Options>,
38        SupportsArgumentsOption<Mac2Options>,
39        SupportsEnvironmentOption<Mac2Options>,
40        SupportsServerStartupTimeoutOption<Mac2Options>,
41        SupportsSkipAppKillOption<Mac2Options>,
42        SupportsShowServerLogsOption<Mac2Options>,
43        SupportsPrerunOption<Mac2Options, AppleScriptData>,
44        SupportsPostrunOption<Mac2Options, AppleScriptData> {
45    public Mac2Options() {
46        setCommonOptions();
47    }
48
49    public Mac2Options(Capabilities source) {
50        super(source);
51        setCommonOptions();
52    }
53
54    public Mac2Options(Map<String, ?> source) {
55        super(source);
56        setCommonOptions();
57    }
58
59    private void setCommonOptions() {
60        setPlatformName(MobilePlatform.MAC);
61        setAutomationName(AutomationName.MAC2);
62    }
63
64    /**
65     * An object containing either script or command key. The value of
66     * each key must be a valid AppleScript script or command to be
67     * executed after before Mac2Driver session is started. See
68     * https://github.com/appium/appium-mac2-driver#applescript-commands-execution
69     * for more details.
70     *
71     * @param script A valid AppleScript snippet.
72     * @return self instance for chaining.
73     */
74    public Mac2Options setPrerun(AppleScriptData script) {
75        return amend(PRERUN_OPTION, script.toMap());
76    }
77
78    /**
79     * Get the prerun script.
80     *
81     * @return Prerun script.
82     */
83    public Optional<AppleScriptData> getPrerun() {
84        //noinspection unchecked
85        return Optional.ofNullable(getCapability(PRERUN_OPTION))
86                .map((v) -> new AppleScriptData((Map<String, Object>) v));
87    }
88
89    /**
90     * An object containing either script or command key. The value of
91     * each key must be a valid AppleScript script or command to be
92     * executed after Mac2Driver session is stopped. See
93     * https://github.com/appium/appium-mac2-driver#applescript-commands-execution
94     * for more details.
95     *
96     * @param script A valid AppleScript snippet.
97     * @return self instance for chaining.
98     */
99    public Mac2Options setPostrun(AppleScriptData script) {
100        return amend(POSTRUN_OPTION, script.toMap());
101    }
102
103    /**
104     * Get the postrun script.
105     *
106     * @return Postrun script.
107     */
108    public Optional<AppleScriptData> getPostrun() {
109        //noinspection unchecked
110        return Optional.ofNullable(getCapability(POSTRUN_OPTION))
111                .map((v) -> new AppleScriptData((Map<String, Object>) v));
112    }
113}
114
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 methods in SupportsPrerunOption

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

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)