How to use withTimeLimit method of io.appium.java_client.screenrecording.BaseStartScreenRecordingOptions class

Best io.appium code snippet using io.appium.java_client.screenrecording.BaseStartScreenRecordingOptions.withTimeLimit

Run io.appium automation tests on LambdaTest cloud grid

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

AndroidStartScreenRecordingOptions.java

Source: AndroidStartScreenRecordingOptions.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.android;
18
19import static java.util.Optional.ofNullable;
20
21import com.google.common.collect.ImmutableMap;
22
23import io.appium.java_client.screenrecording.BaseStartScreenRecordingOptions;
24import io.appium.java_client.screenrecording.ScreenRecordingUploadOptions;
25
26import java.time.Duration;
27import java.util.Map;
28
29public class AndroidStartScreenRecordingOptions
30        extends BaseStartScreenRecordingOptions<AndroidStartScreenRecordingOptions> {
31    private Integer bitRate;
32    private String videoSize;
33    private Boolean isBugReportEnabled;
34
35    public static AndroidStartScreenRecordingOptions startScreenRecordingOptions() {
36        return new AndroidStartScreenRecordingOptions();
37    }
38
39    /**
40     * The video bit rate for the video, in megabits per second.
41     * The default value is 4000000 (4 Mb/s) for Android API level below 27
42     * and 20000000 (20 Mb/s) for API level 27 and above.
43     * You can increase the bit rate to improve video quality,
44     * but doing so results in larger movie files.
45     *
46     * @param bitRate The actual bit rate (Mb/s).
47     * @return self instance for chaining.
48     */
49    public AndroidStartScreenRecordingOptions withBitRate(int bitRate) {
50        this.bitRate = bitRate;
51        return this;
52    }
53
54    /**
55     * {@inheritDoc}
56     */
57    @Override
58    public AndroidStartScreenRecordingOptions withUploadOptions(ScreenRecordingUploadOptions uploadOptions) {
59        return (AndroidStartScreenRecordingOptions) super.withUploadOptions(uploadOptions);
60    }
61    
62    /**
63     * The video size of the generated media file. The format is WIDTHxHEIGHT.
64     * The default value is the device's native display resolution (if supported),
65     * 1280x720 if not. For best results,
66     * use a size supported by your device's Advanced Video Coding (AVC) encoder.
67     *
68     * @param videoSize The actual video size: WIDTHxHEIGHT.
69     * @return self instance for chaining.
70     */
71    public AndroidStartScreenRecordingOptions withVideoSize(String videoSize) {
72        this.videoSize = videoSize;
73        return this;
74    }
75
76    /**
77     * Makes the recorder to display an additional information on the video overlay,
78     * such as a timestamp, that is helpful in videos captured to illustrate bugs.
79     * This option is only supported since API level 27 (Android P).
80     *
81     * @return self instance for chaining.
82     */
83    public AndroidStartScreenRecordingOptions enableBugReport() {
84        this.isBugReportEnabled = true;
85        return this;
86    }
87
88    /**
89     * The maximum recording time. The default and maximum value is 180 seconds (3 minutes).
90     * Setting values greater than this or less than zero will cause an exception. The minimum
91     * time resolution unit is one second.
92     *
93     * <p>Since Appium 1.8.2 the time limit can be up to 1800 seconds (30 minutes).
94     * Appium will automatically try to merge the 3-minutes chunks recorded
95     * by the screenrecord utility, however, this requires FFMPEG utility
96     * to be installed and available in PATH on the server machine. If the utility is not
97     * present then the most recent screen recording chunk is going to be returned as the result.</p>
98     *
99     * @param timeLimit The actual time limit of the recorded video.
100     * @return self instance for chaining.
101     */
102    @Override
103    public AndroidStartScreenRecordingOptions withTimeLimit(Duration timeLimit) {
104        return super.withTimeLimit(timeLimit);
105    }
106
107    @Override
108    public Map<String, Object> build() {
109        final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
110        builder.putAll(super.build());
111        ofNullable(bitRate).map(x -> builder.put("bitRate", x));
112        ofNullable(videoSize).map(x -> builder.put("videoSize", x));
113        ofNullable(isBugReportEnabled).map(x -> builder.put("bugReport", x));
114        return builder.build();
115    }
116}
117
Full Screen

IOSStartScreenRecordingOptions.java

Source: IOSStartScreenRecordingOptions.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.ios;
18
19import static com.google.common.base.Preconditions.checkNotNull;
20import static java.util.Optional.ofNullable;
21
22import com.google.common.collect.ImmutableMap;
23
24import io.appium.java_client.screenrecording.BaseStartScreenRecordingOptions;
25import io.appium.java_client.screenrecording.ScreenRecordingUploadOptions;
26
27import java.time.Duration;
28import java.util.Map;
29
30public class IOSStartScreenRecordingOptions
31        extends BaseStartScreenRecordingOptions<IOSStartScreenRecordingOptions> {
32    private String videoType;
33    private String videoQuality;
34    private String videoScale;
35    private String videoFilters;
36    private Integer fps;
37
38    public static IOSStartScreenRecordingOptions startScreenRecordingOptions() {
39        return new IOSStartScreenRecordingOptions();
40    }
41
42    /**
43     * {@inheritDoc}
44     */
45    @Override
46    public IOSStartScreenRecordingOptions withUploadOptions(ScreenRecordingUploadOptions uploadOptions) {
47        return (IOSStartScreenRecordingOptions) super.withUploadOptions(uploadOptions);
48    }
49
50    /**
51     * The video codec type used for encoding of the recorded screen capture.
52     * Execute `ffmpeg -codecs` in the terminal to see the list of supported video codecs.
53     * 'mjpeg' by default.
54     *
55     * @since Appium 1.10.0
56     * @param videoType one of available video codec names, for example 'libx264'.
57     * @return self instance for chaining.
58     */
59    public IOSStartScreenRecordingOptions withVideoType(String videoType) {
60        this.videoType = checkNotNull(videoType);
61        return this;
62    }
63
64    public enum VideoQuality {
65        LOW, MEDIUM, HIGH, PHOTO
66    }
67
68    /**
69     * The video encoding quality (low, medium, high, photo - defaults to medium).
70     * Only works for real devices.
71     *
72     * @param videoQuality one of possible quality preset names.
73     * @return self instance for chaining.
74     */
75    public IOSStartScreenRecordingOptions withVideoQuality(VideoQuality videoQuality) {
76        this.videoQuality = checkNotNull(videoQuality).name().toLowerCase();
77        return this;
78    }
79
80    /**
81     * The Frames Per Second rate of the recorded video. Defaults to 10.
82     *
83     * @since Appium 1.10.0
84     * @param fps frames per second value in range 1..60.
85     * @return self instance for chaining.
86     */
87    public IOSStartScreenRecordingOptions withFps(int fps) {
88        this.fps = fps;
89        return this;
90    }
91
92    /**
93     * The scaling value to apply. Read https://trac.ffmpeg.org/wiki/Scaling for possible values.
94     * No scale is applied by default.
95     * If filters are set then the scale setting is effectively ignored.
96     *
97     * @since Appium 1.10.0
98     * @param videoScale ffmpeg-compatible scale format specifier.
99     * @return self instance for chaining.
100     */
101    public IOSStartScreenRecordingOptions withVideoScale(String videoScale) {
102        this.videoScale = checkNotNull(videoScale);
103        return this;
104    }
105
106    /**
107     * The maximum recording time. The default value is 180 seconds (3 minutes).
108     * The maximum value is 30 minutes.
109     * Setting values greater than this or less than zero will cause an exception. The minimum
110     * time resolution unit is one second.
111     *
112     * @param timeLimit The actual time limit of the recorded video.
113     * @return self instance for chaining.
114     */
115    @Override
116    public IOSStartScreenRecordingOptions withTimeLimit(Duration timeLimit) {
117        return super.withTimeLimit(timeLimit);
118    }
119
120    /**
121     * The FFMPEG video filters to apply. These filters allow to scale, flip, rotate and do many
122     * other useful transformations on the source video stream. The format of the property
123     * must comply with https://ffmpeg.org/ffmpeg-filters.html.
124     *
125     * @since Appium 1.15
126     * @param filters One or more filters to apply to the resulting video stream,
127     *                for example "transpose=1" to rotate the resulting video 90 degrees clockwise.
128     * @return self instance for chaining.
129     */
130    public IOSStartScreenRecordingOptions withVideoFilters(String filters) {
131        this.videoFilters = filters;
132        return this;
133    }
134
135    @Override
136    public Map<String, Object> build() {
137        final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
138        builder.putAll(super.build());
139        ofNullable(videoType).map(x -> builder.put("videoType", x));
140        ofNullable(videoQuality).map(x -> builder.put("videoQuality", x));
141        ofNullable(videoScale).map(x -> builder.put("videoScale", x));
142        ofNullable(videoFilters).map(x -> builder.put("videoFilters", x));
143        ofNullable(fps).map(x -> builder.put("videoFps", x));
144        return builder.build();
145    }
146}
147
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 BaseStartScreenRecordingOptions

Trigger withTimeLimit code on LambdaTest Cloud Grid

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