How to use getPostrun method of io.appium.java_client.windows.options.WindowsOptions class

Best io.appium code snippet using io.appium.java_client.windows.options.WindowsOptions.getPostrun

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

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 WindowsOptions

Trigger getPostrun code on LambdaTest Cloud Grid

Execute automation tests with getPostrun 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)