diff --git a/src/main/java/io/appium/java_client/wincore/WincoreDriver.java b/src/main/java/io/appium/java_client/wincore/WincoreDriver.java index 56f414cd8..0c1ca1e3d 100644 --- a/src/main/java/io/appium/java_client/wincore/WincoreDriver.java +++ b/src/main/java/io/appium/java_client/wincore/WincoreDriver.java @@ -43,8 +43,7 @@ /** * WincoreDriver is an officially supported Appium driver created to automate Windows apps. - * It is the successor of the Windows driver, which is deprecated and not supported since Appium 4, - * see {@link io.appium.java_client.windows.WindowsDriver}. + * It is the successor of the Windows driver, which is deprecated and not supported since Appium 4. * Read https://github.com/appium/appium-wincore-driver for more details. */ public class WincoreDriver extends AppiumDriver implements diff --git a/src/main/java/io/appium/java_client/windows/options/PowerShellData.java b/src/main/java/io/appium/java_client/wincore/options/PowerShellData.java similarity index 97% rename from src/main/java/io/appium/java_client/windows/options/PowerShellData.java rename to src/main/java/io/appium/java_client/wincore/options/PowerShellData.java index f3562394d..8c52efdab 100644 --- a/src/main/java/io/appium/java_client/windows/options/PowerShellData.java +++ b/src/main/java/io/appium/java_client/wincore/options/PowerShellData.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.appium.java_client.windows.options; +package io.appium.java_client.wincore.options; import io.appium.java_client.remote.options.SystemScript; diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsAppArgumentsOption.java b/src/main/java/io/appium/java_client/wincore/options/SupportsAppArgumentsOption.java similarity index 97% rename from src/main/java/io/appium/java_client/windows/options/SupportsAppArgumentsOption.java rename to src/main/java/io/appium/java_client/wincore/options/SupportsAppArgumentsOption.java index 5f37ca3ca..38cf026f3 100644 --- a/src/main/java/io/appium/java_client/windows/options/SupportsAppArgumentsOption.java +++ b/src/main/java/io/appium/java_client/wincore/options/SupportsAppArgumentsOption.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.appium.java_client.windows.options; +package io.appium.java_client.wincore.options; import io.appium.java_client.remote.options.BaseOptions; import io.appium.java_client.remote.options.CanSetCapability; diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsAppTopLevelWindowOption.java b/src/main/java/io/appium/java_client/wincore/options/SupportsAppTopLevelWindowOption.java similarity index 97% rename from src/main/java/io/appium/java_client/windows/options/SupportsAppTopLevelWindowOption.java rename to src/main/java/io/appium/java_client/wincore/options/SupportsAppTopLevelWindowOption.java index b57967d38..a7a226992 100644 --- a/src/main/java/io/appium/java_client/windows/options/SupportsAppTopLevelWindowOption.java +++ b/src/main/java/io/appium/java_client/wincore/options/SupportsAppTopLevelWindowOption.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.appium.java_client.windows.options; +package io.appium.java_client.wincore.options; import io.appium.java_client.remote.options.BaseOptions; import io.appium.java_client.remote.options.CanSetCapability; diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsAppWorkingDirOption.java b/src/main/java/io/appium/java_client/wincore/options/SupportsAppWorkingDirOption.java similarity index 97% rename from src/main/java/io/appium/java_client/windows/options/SupportsAppWorkingDirOption.java rename to src/main/java/io/appium/java_client/wincore/options/SupportsAppWorkingDirOption.java index 8086cbeaf..0a5a9edfe 100644 --- a/src/main/java/io/appium/java_client/windows/options/SupportsAppWorkingDirOption.java +++ b/src/main/java/io/appium/java_client/wincore/options/SupportsAppWorkingDirOption.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.appium.java_client.windows.options; +package io.appium.java_client.wincore.options; import io.appium.java_client.remote.options.BaseOptions; import io.appium.java_client.remote.options.CanSetCapability; diff --git a/src/main/java/io/appium/java_client/wincore/options/SupportsWebviewDevtoolsPortOption.java b/src/main/java/io/appium/java_client/wincore/options/SupportsWebviewDevtoolsPortOption.java new file mode 100644 index 000000000..48f196615 --- /dev/null +++ b/src/main/java/io/appium/java_client/wincore/options/SupportsWebviewDevtoolsPortOption.java @@ -0,0 +1,58 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.appium.java_client.wincore.options; + +import io.appium.java_client.remote.options.BaseOptions; +import io.appium.java_client.remote.options.CanSetCapability; +import io.appium.java_client.remote.options.CapabilityReader; +import org.openqa.selenium.Capabilities; + +import java.util.Optional; + +/** + * Provides getters and setters for the {@code webviewDevtoolsPort} capability. + * + * @param options type, used for chaining. + */ +public interface SupportsWebviewDevtoolsPortOption> extends + Capabilities, CanSetCapability { + /** + * Name of the {@code webviewDevtoolsPort} capability. + */ + String WEBVIEW_DEVTOOLS_PORT_OPTION = "webviewDevtoolsPort"; + + /** + * The local port number to use for devtools communication. By default, the first + * free port from 10900..11000 range is selected. Consider setting the custom + * value if you are running parallel tests. + * + * @param port port number in range 0..65535 + * @return self instance for chaining. + */ + default T setWebviewDevtoolsPort(int port) { + return amend(WEBVIEW_DEVTOOLS_PORT_OPTION, port); + } + + /** + * Get the local port number to use for devtools communication. + * + * @return Port number. + */ + default Optional getWebviewDevtoolsPort() { + return new CapabilityReader(this).getInteger(WEBVIEW_DEVTOOLS_PORT_OPTION); + } +} diff --git a/src/main/java/io/appium/java_client/wincore/options/WincoreOptions.java b/src/main/java/io/appium/java_client/wincore/options/WincoreOptions.java index d2e782593..0b43191db 100644 --- a/src/main/java/io/appium/java_client/wincore/options/WincoreOptions.java +++ b/src/main/java/io/appium/java_client/wincore/options/WincoreOptions.java @@ -16,7 +16,6 @@ package io.appium.java_client.wincore.options; -import io.appium.java_client.android.options.context.SupportsWebviewDevtoolsPortOption; import io.appium.java_client.remote.AutomationName; import io.appium.java_client.remote.MobilePlatform; import io.appium.java_client.remote.options.BaseOptions; @@ -24,10 +23,6 @@ import io.appium.java_client.remote.options.SupportsDeviceNameOption; import io.appium.java_client.remote.options.SupportsPostrunOption; import io.appium.java_client.remote.options.SupportsPrerunOption; -import io.appium.java_client.windows.options.PowerShellData; -import io.appium.java_client.windows.options.SupportsAppArgumentsOption; -import io.appium.java_client.windows.options.SupportsAppTopLevelWindowOption; -import io.appium.java_client.windows.options.SupportsAppWorkingDirOption; import org.openqa.selenium.Capabilities; import java.util.Map; @@ -38,8 +33,7 @@ * See https://github.com/appium/appium-wincore-driver#capabilities * for more details. * - *

The driver replaces appium-windows-driver, which is deprecated and not supported since Appium 4, see - * {@link io.appium.java_client.windows.options.WindowsOptions}.

+ *

The driver replaces appium-windows-driver, which is deprecated and not supported since Appium 4.

*/ public class WincoreOptions extends BaseOptions implements SupportsAppOption, diff --git a/src/main/java/io/appium/java_client/windows/WindowsDriver.java b/src/main/java/io/appium/java_client/windows/WindowsDriver.java deleted file mode 100644 index d4684f989..000000000 --- a/src/main/java/io/appium/java_client/windows/WindowsDriver.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows; - -import io.appium.java_client.AppiumClientConfig; -import io.appium.java_client.AppiumDriver; -import io.appium.java_client.CommandExecutionHelper; -import io.appium.java_client.PullsFiles; -import io.appium.java_client.PushesFiles; -import io.appium.java_client.http.HttpClient; -import io.appium.java_client.remote.AppiumCommandExecutor; -import io.appium.java_client.remote.AutomationName; -import io.appium.java_client.screenrecording.CanRecordScreen; -import io.appium.java_client.service.local.AppiumDriverLocalService; -import io.appium.java_client.service.local.AppiumServiceBuilder; -import org.jspecify.annotations.Nullable; -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.Platform; - -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.Map; - -import static io.appium.java_client.MobileCommand.PULL_FILE; -import static io.appium.java_client.MobileCommand.PULL_FOLDER; -import static io.appium.java_client.MobileCommand.PUSH_FILE; -import static java.util.Objects.requireNonNull; - -/** - * WindowsDriver is an Appium driver created to automate Windows apps. - * Read https://github.com/appium/appium-windows-driver for more details. - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Use {@link io.appium.java_client.wincore.WincoreDriver} instead. - */ -@Deprecated -public class WindowsDriver extends AppiumDriver implements - PullsFiles, - PushesFiles, - CanRecordScreen { - private static final String PLATFORM_NAME = Platform.WINDOWS.name(); - private static final String AUTOMATION_NAME = AutomationName.WINDOWS; - - /** - * Creates a new instance based on command {@code executor} and {@code capabilities}. - * - * @param executor is an instance of {@link AppiumCommandExecutor} - * or class that extends it. Default commands or another vendor-specific - * commands may be specified there. - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(AppiumCommandExecutor executor, Capabilities capabilities) { - super(executor, ensurePlatformAndAutomationNames(capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on Appium server URL and {@code capabilities}. - * - * @param remoteAddress is the address of remotely/locally started Appium server - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(URL remoteAddress, Capabilities capabilities) { - super(remoteAddress, ensurePlatformAndAutomationNames( - capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on Appium server URL, HTTP client factory and {@code capabilities}. - * - * @param remoteAddress is the address of remotely/locally started Appium server - * @param httpClientFactory take a look at {@link HttpClient.Factory} - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(URL remoteAddress, HttpClient.Factory httpClientFactory, Capabilities capabilities) { - super(remoteAddress, httpClientFactory, ensurePlatformAndAutomationNames( - capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on Appium driver local service and {@code capabilities}. - * - * @param service take a look at {@link AppiumDriverLocalService} - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(AppiumDriverLocalService service, Capabilities capabilities) { - super(service, ensurePlatformAndAutomationNames(capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on Appium driver local service, HTTP client factory and {@code capabilities}. - * - * @param service take a look at {@link AppiumDriverLocalService} - * @param httpClientFactory take a look at {@link HttpClient.Factory} - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(AppiumDriverLocalService service, HttpClient.Factory httpClientFactory, - Capabilities capabilities) { - super(service, httpClientFactory, ensurePlatformAndAutomationNames( - capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on Appium service builder and {@code capabilities}. - * - * @param builder take a look at {@link AppiumServiceBuilder} - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(AppiumServiceBuilder builder, Capabilities capabilities) { - super(builder, ensurePlatformAndAutomationNames(capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on Appium service builder, HTTP client factory and {@code capabilities}. - * - * @param builder take a look at {@link AppiumServiceBuilder} - * @param httpClientFactory take a look at {@link HttpClient.Factory} - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(AppiumServiceBuilder builder, HttpClient.Factory httpClientFactory, - Capabilities capabilities) { - super(builder, httpClientFactory, ensurePlatformAndAutomationNames( - capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on HTTP client factory and {@code capabilities}. - * - * @param httpClientFactory take a look at {@link HttpClient.Factory} - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(HttpClient.Factory httpClientFactory, Capabilities capabilities) { - super(httpClientFactory, ensurePlatformAndAutomationNames( - capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance connected to an already running driver session. - * Intended for debugging purposes only; the caller maintains the session state. - * - * @param remoteSessionAddress The address of the **running** session including the session identifier. - */ - public WindowsDriver(URL remoteSessionAddress) { - super(remoteSessionAddress, PLATFORM_NAME, AUTOMATION_NAME); - } - - /** - * Creates a new instance based on the given AppiumClientConfig and {@code capabilities}. - * The HTTP client is default client generated by {@link HttpClient.Factory#createDefault()}. - * For example: - * - *
-     *
-     * AppiumClientConfig appiumClientConfig = AppiumClientConfig.defaultConfig()
-     *     .directConnect(true)
-     *     .baseUri(URI.create("WebDriver URL"))
-     *     .readTimeout(Duration.ofMinutes(5));
-     * WindowsOptions options = new WindowsOptions();
-     * WindowsDriver driver = new WindowsDriver(appiumClientConfig, options);
-     *
-     * 
- * - * @param appiumClientConfig take a look at {@link AppiumClientConfig} - * @param capabilities take a look at {@link Capabilities} - * - */ - public WindowsDriver(AppiumClientConfig appiumClientConfig, Capabilities capabilities) { - super(appiumClientConfig, ensurePlatformAndAutomationNames( - capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Creates a new instance based on {@code capabilities}. - * - * @param capabilities take a look at {@link Capabilities} - */ - public WindowsDriver(Capabilities capabilities) { - super(ensurePlatformAndAutomationNames(capabilities, PLATFORM_NAME, AUTOMATION_NAME)); - } - - /** - * Pulls a file from the remote system. The Windows driver has no `mobile:` extension for it. - * - * @param remotePath Path to the file to read data from the remote device. - * @return A byte array of Base64 encoded data. - */ - @Override - public byte[] pullFile(String remotePath) { - return decodeBase64(CommandExecutionHelper.execute(this, Map.entry(PULL_FILE, Map.of("path", remotePath)))); - } - - /** - * Pulls the content of a folder from the remote system. The Windows driver has no `mobile:` extension for it. - * - * @param remotePath Path to the folder to read data from the remote device. - * @return A byte array of Base64 encoded zip archive data. - */ - @Override - public byte[] pullFolder(String remotePath) { - return decodeBase64(CommandExecutionHelper.execute(this, Map.entry(PULL_FOLDER, Map.of("path", remotePath)))); - } - - /** - * Saves base64-encoded data as a file on the remote system. The Windows driver has no `mobile:` extension for it. - * - * @param remotePath Path to the file to write data to on the remote device. - * @param base64Data Base64 encoded byte array of the data to write to the remote device. - */ - @Override - public void pushFile(String remotePath, byte[] base64Data) { - CommandExecutionHelper.execute(this, Map.entry(PUSH_FILE, Map.of( - "path", remotePath, - "data", new String(base64Data, StandardCharsets.UTF_8) - ))); - } - - private static byte[] decodeBase64(@Nullable String base64String) { - return Base64.getDecoder().decode(requireNonNull(base64String).getBytes(StandardCharsets.UTF_8)); - } - - /** - * Launch the application app under test after it was closed. - */ - public void launchApp() { - CommandExecutionHelper.executeScript(this, "windows: launchApp"); - } - - /** - * Close the app under test. - */ - public void closeApp() { - CommandExecutionHelper.executeScript(this, "windows: closeApp"); - } -} diff --git a/src/main/java/io/appium/java_client/windows/WindowsStartScreenRecordingOptions.java b/src/main/java/io/appium/java_client/windows/WindowsStartScreenRecordingOptions.java deleted file mode 100644 index de2c21a0a..000000000 --- a/src/main/java/io/appium/java_client/windows/WindowsStartScreenRecordingOptions.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows; - -import io.appium.java_client.screenrecording.BaseStartScreenRecordingOptions; - -import java.time.Duration; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Optional.ofNullable; - -/** - * Windows-specific options for starting a screen recording. - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Use {@link io.appium.java_client.wincore.WincoreStartScreenRecordingOptions} instead. - */ -@Deprecated -public class WindowsStartScreenRecordingOptions - extends BaseStartScreenRecordingOptions { - /** - * Creates a new instance. - */ - public WindowsStartScreenRecordingOptions() { - } - - private Integer fps; - private String videoFilter; - private String preset; - private Boolean captureCursor; - private Boolean captureClicks; - private String audioInput; - - /** - * Creates a new options instance. - * - * @return a new {@link WindowsStartScreenRecordingOptions} instance. - */ - public static WindowsStartScreenRecordingOptions startScreenRecordingOptions() { - return new WindowsStartScreenRecordingOptions(); - } - - /** - * The count of frames per second in the resulting video. - * Increasing fps value also increases the size of the resulting - * video file and the CPU usage. - * - * @param fps The actual frames per second value. - * The default value is 15. - * @return self instance for chaining. - */ - public WindowsStartScreenRecordingOptions withFps(int fps) { - this.fps = fps; - return this; - } - - /** - * Whether to capture the mouse cursor while recording - * the screen. Disabled by default. - * - * @return self instance for chaining. - */ - public WindowsStartScreenRecordingOptions enableCursorCapture() { - this.captureCursor = true; - return this; - } - - /** - * Whether to capture the click gestures while recording - * the screen. Disabled by default. - * - * @return self instance for chaining. - */ - public WindowsStartScreenRecordingOptions enableClicksCapture() { - this.captureClicks = true; - return this; - } - - /** - * If provided then the given audio input will be used to record the computer audio - * along with the desktop video. The list of available devices could be retrieved using - * `ffmpeg -list_devices true -f dshow -i dummy` command. - * - * @param audioInput One of valid audio input names listed by ffmpeg - * @return self instance for chaining. - */ - public WindowsStartScreenRecordingOptions withAudioInput(String audioInput) { - this.audioInput = audioInput; - return this; - } - - /** - * The video filter spec to apply for ffmpeg. - * See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values. - * Example: Set it to `scale=ifnot(gte(iw\,1024)\,iw\,1024):-2` in order to limit the video width - * to 1024px. The height will be adjusted automatically to match the actual screen aspect ratio. - * - * @param videoFilter Valid ffmpeg video filter spec string. - * @return self instance for chaining. - */ - public WindowsStartScreenRecordingOptions withVideoFilter(String videoFilter) { - this.videoFilter = videoFilter; - return this; - } - - /** - * A preset is a collection of options that will provide a certain encoding speed to compression ratio. - * A slower preset will provide better compression (compression is quality per filesize). - * This means that, for example, if you target a certain file size or constant bit rate, you will - * achieve better quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 - * for more details. - * - * @param preset One of the supported encoding presets. Possible values are: - * - ultrafast - * - superfast - * - veryfast (default) - * - faster - * - fast - * - medium - * - slow - * - slower - * - veryslow - * @return self instance for chaining. - */ - public WindowsStartScreenRecordingOptions withPreset(String preset) { - this.preset = preset; - return this; - } - - /** - * The maximum recording time. The default value is 600 seconds (10 minutes). - * The minimum time resolution unit is one second. - * - * @param timeLimit The actual time limit of the recorded video. - * @return self instance for chaining. - */ - @Override - public WindowsStartScreenRecordingOptions withTimeLimit(Duration timeLimit) { - return super.withTimeLimit(timeLimit); - } - - @Override - public Map build() { - var map = new HashMap<>(super.build()); - ofNullable(fps).map(x -> map.put("fps", x)); - ofNullable(preset).map(x -> map.put("preset", x)); - ofNullable(videoFilter).map(x -> map.put("videoFilter", x)); - ofNullable(captureClicks).map(x -> map.put("captureClicks", x)); - ofNullable(captureCursor).map(x -> map.put("captureCursor", x)); - ofNullable(audioInput).map(x -> map.put("audioInput", x)); - return Collections.unmodifiableMap(map); - } -} diff --git a/src/main/java/io/appium/java_client/windows/WindowsStopScreenRecordingOptions.java b/src/main/java/io/appium/java_client/windows/WindowsStopScreenRecordingOptions.java deleted file mode 100644 index 7de721548..000000000 --- a/src/main/java/io/appium/java_client/windows/WindowsStopScreenRecordingOptions.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows; - -import io.appium.java_client.screenrecording.BaseStopScreenRecordingOptions; - -/** - * Windows-specific options for stopping a screen recording. - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Use {@link io.appium.java_client.wincore.WincoreStopScreenRecordingOptions} instead. - */ -@Deprecated -public class WindowsStopScreenRecordingOptions extends - BaseStopScreenRecordingOptions { - /** - * Creates a new instance. - */ - public WindowsStopScreenRecordingOptions() { - } - - /** - * Creates a new options instance. - * - * @return a new {@link WindowsStopScreenRecordingOptions} instance. - */ - public static WindowsStopScreenRecordingOptions stopScreenRecordingOptions() { - return new WindowsStopScreenRecordingOptions(); - } - -} diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsCreateSessionTimeoutOption.java b/src/main/java/io/appium/java_client/windows/options/SupportsCreateSessionTimeoutOption.java deleted file mode 100644 index b490a284b..000000000 --- a/src/main/java/io/appium/java_client/windows/options/SupportsCreateSessionTimeoutOption.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows.options; - -import io.appium.java_client.remote.options.BaseOptions; -import io.appium.java_client.remote.options.CanSetCapability; -import io.appium.java_client.remote.options.CapabilityReader; -import org.openqa.selenium.Capabilities; - -import java.time.Duration; -import java.util.Optional; - -/** - * Support for the {@code createSessionTimeout} capability: the timeout for creating a session. - * - * @param the concrete options type, returned for chaining - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Its successor, the Wincore driver, does not support this capability. - */ -@Deprecated -public interface SupportsCreateSessionTimeoutOption> extends - Capabilities, CanSetCapability { - /** - * Name of the {@code createSessionTimeout} capability. - */ - String CREATE_SESSION_TIMEOUT_OPTION = "createSessionTimeout"; - - /** - * Set the timeout used to retry Appium Windows Driver session startup. - * This capability could be used as a workaround for the long startup times - * of UWP applications (aka Failed to locate opened application window - * with appId: TestCompany.my_app4!App, and processId: 8480). Default value is 20000ms. - * - * @param timeout The timeout value. - * @return self instance for chaining. - */ - default T setCreateSessionTimeout(Duration timeout) { - return amend(CREATE_SESSION_TIMEOUT_OPTION, timeout.toMillis()); - } - - /** - * Get the timeout used to retry Appium Windows Driver session startup. - * - * @return The timeout value. - */ - default Optional getCreateSessionTimeout() { - return new CapabilityReader(this).getDuration(CREATE_SESSION_TIMEOUT_OPTION); - } -} diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsMsExperimentalWebDriverOption.java b/src/main/java/io/appium/java_client/windows/options/SupportsMsExperimentalWebDriverOption.java deleted file mode 100644 index f3c6c4fe3..000000000 --- a/src/main/java/io/appium/java_client/windows/options/SupportsMsExperimentalWebDriverOption.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows.options; - -import io.appium.java_client.remote.options.BaseOptions; -import io.appium.java_client.remote.options.CanSetCapability; -import io.appium.java_client.remote.options.CapabilityReader; -import org.openqa.selenium.Capabilities; - -import java.util.Optional; - -/** - * Support for the {@code ms:experimental-webdriver} capability: whether experimental driver features are enabled. - * - * @param the concrete options type, returned for chaining - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Its successor, the Wincore driver, does not support this capability. - */ -@Deprecated -public interface SupportsMsExperimentalWebDriverOption> extends - Capabilities, CanSetCapability { - /** - * Name of the {@code ms:experimental-webdriver} capability. - */ - String MS_EXPERIMENTAL_WEBDRIVER_OPTION = "ms:experimental-webdriver"; - - /** - * Enforce to enable experimental driver features and optimizations. - * - * @return self instance for chaining. - */ - default T experimentalWebDriver() { - return amend(MS_EXPERIMENTAL_WEBDRIVER_OPTION, true); - } - - /** - * Enables experimental features and optimizations. See Appium Windows - * Driver release notes for more details on this capability. false by default. - * - * @param value Whether to enable experimental features and optimizations. - * @return self instance for chaining. - */ - default T setExperimentalWebDriver(boolean value) { - return amend(MS_EXPERIMENTAL_WEBDRIVER_OPTION, value); - } - - /** - * Get whether to enable experimental features and optimizations. - * - * @return True or false. - */ - default Optional isExperimentalWebDriver() { - return new CapabilityReader(this).getBoolean(MS_EXPERIMENTAL_WEBDRIVER_OPTION); - } -} diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsMsWaitForAppLaunchOption.java b/src/main/java/io/appium/java_client/windows/options/SupportsMsWaitForAppLaunchOption.java deleted file mode 100644 index b664d344f..000000000 --- a/src/main/java/io/appium/java_client/windows/options/SupportsMsWaitForAppLaunchOption.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows.options; - -import io.appium.java_client.remote.options.BaseOptions; -import io.appium.java_client.remote.options.CanSetCapability; -import io.appium.java_client.remote.options.CapabilityReader; -import org.openqa.selenium.Capabilities; - -import java.time.Duration; -import java.util.Optional; - -/** - * Support for the {@code ms:waitForAppLaunch} capability: the time to wait for the application to launch. - * - * @param the concrete options type, returned for chaining - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Use {@link io.appium.java_client.wincore.options.SupportsWaitForAppLaunchOption} instead. - */ -@Deprecated -public interface SupportsMsWaitForAppLaunchOption> extends - Capabilities, CanSetCapability { - /** - * Name of the {@code ms:waitForAppLaunch} capability. - */ - String MS_WAIT_FOR_APP_LAUNCH_OPTION = "ms:waitForAppLaunch"; - - /** - * Similar to createSessionTimeout, but is - * applied on the server side. Enables Appium Windows Driver to wait for - * a defined amount of time after an app launch is initiated prior to - * attaching to the application session. The limit for this is 50 seconds. - * - * @param timeout The timeout value. - * @return self instance for chaining. - */ - default T setWaitForAppLaunch(Duration timeout) { - return amend(MS_WAIT_FOR_APP_LAUNCH_OPTION, timeout.getSeconds()); - } - - /** - * Get the time to wait after an app launch is initiated before attaching to it. - * - * @return The timeout value. - */ - default Optional doesWaitForAppLaunch() { - return new CapabilityReader(this).getDuration(MS_WAIT_FOR_APP_LAUNCH_OPTION, Duration::ofSeconds); - } -} diff --git a/src/main/java/io/appium/java_client/windows/options/SupportsSystemPortOption.java b/src/main/java/io/appium/java_client/windows/options/SupportsSystemPortOption.java deleted file mode 100644 index 8d2d74163..000000000 --- a/src/main/java/io/appium/java_client/windows/options/SupportsSystemPortOption.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows.options; - -import io.appium.java_client.remote.options.BaseOptions; -import io.appium.java_client.remote.options.CanSetCapability; -import io.appium.java_client.remote.options.CapabilityReader; -import org.openqa.selenium.Capabilities; - -import java.util.Optional; - -/** - * Support for the {@code systemPort} capability: the port the driver server listens on. - * - * @param the concrete options type, returned for chaining - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Its successor, the Wincore driver, does not support this capability. - */ -@Deprecated -public interface SupportsSystemPortOption> extends - Capabilities, CanSetCapability { - /** - * Name of the {@code systemPort} capability. - */ - String SYSTEM_PORT_OPTION = "systemPort"; - - /** - * The port number to execute Appium Windows Driver server listener on, - * for example 5556. The port must not be occupied. The default starting port - * number for a new Appium Windows Driver session is 4724. If this port is - * already busy then the next free port will be automatically selected. - * - * @param port port number in range 0..65535 - * @return self instance for chaining. - */ - default T setSystemPort(int port) { - return amend(SYSTEM_PORT_OPTION, port); - } - - /** - * Get the port number to execute Appium Windows Driver server listener on. - * - * @return System port value. - */ - default Optional getSystemPort() { - return new CapabilityReader(this).getInteger(SYSTEM_PORT_OPTION); - } -} diff --git a/src/main/java/io/appium/java_client/windows/options/WindowsOptions.java b/src/main/java/io/appium/java_client/windows/options/WindowsOptions.java deleted file mode 100644 index 80fff5d0e..000000000 --- a/src/main/java/io/appium/java_client/windows/options/WindowsOptions.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.windows.options; - -import io.appium.java_client.remote.AutomationName; -import io.appium.java_client.remote.MobilePlatform; -import io.appium.java_client.remote.options.BaseOptions; -import io.appium.java_client.remote.options.SupportsAppOption; -import io.appium.java_client.remote.options.SupportsPostrunOption; -import io.appium.java_client.remote.options.SupportsPrerunOption; -import org.openqa.selenium.Capabilities; - -import java.util.Map; -import java.util.Optional; - -/** - * https://github.com/appium/appium-windows-driver#usage. - * - * @deprecated The Windows driver is deprecated and not supported since Appium 4. - * Use {@link io.appium.java_client.wincore.options.WincoreOptions} instead. - */ -@Deprecated -public class WindowsOptions extends BaseOptions implements - SupportsAppOption, - SupportsAppArgumentsOption, - SupportsAppTopLevelWindowOption, - SupportsAppWorkingDirOption, - SupportsCreateSessionTimeoutOption, - SupportsMsWaitForAppLaunchOption, - SupportsMsExperimentalWebDriverOption, - SupportsSystemPortOption, - SupportsPrerunOption, - SupportsPostrunOption { - /** Creates options with the default capabilities set. */ - public WindowsOptions() { - setCommonOptions(); - } - - /** - * Creates options from the given capabilities. - * - * @param source The capabilities to copy. - */ - public WindowsOptions(Capabilities source) { - super(source); - setCommonOptions(); - } - - /** - * Creates options from the given capabilities map. - * - * @param source The capabilities to copy. - */ - public WindowsOptions(Map source) { - super(source); - setCommonOptions(); - } - - private void setCommonOptions() { - setPlatformName(MobilePlatform.WINDOWS); - setAutomationName(AutomationName.WINDOWS); - } - - /** - * An object containing either script or command key. The value of - * each key must be a valid PowerShell script or command to be - * executed prior to the WinAppDriver session startup. - * See - * https://github.com/appium/appium-windows-driver#power-shell-commands-execution - * for more details. - * - * @param script E.g. {script: 'Get-Process outlook -ErrorAction SilentlyContinue'}. - * @return self instance for chaining. - */ - public WindowsOptions setPrerun(PowerShellData script) { - return amend(PRERUN_OPTION, script.toMap()); - } - - /** - * Get the prerun script. - * - * @return Prerun script. - */ - public Optional getPrerun() { - //noinspection unchecked - return Optional.ofNullable(getCapability(PRERUN_OPTION)) - .map(v -> new PowerShellData((Map) v)); - } - - /** - * An object containing either script or command key. The value of - * each key must be a valid PowerShell script or command to be - * executed after an WinAppDriver session is finished. - * See - * https://github.com/appium/appium-windows-driver#power-shell-commands-execution - * for more details. - * - * @param script E.g. {script: 'Get-Process outlook -ErrorAction SilentlyContinue'}. - * @return self instance for chaining. - */ - public WindowsOptions setPostrun(PowerShellData script) { - return amend(POSTRUN_OPTION, script.toMap()); - } - - /** - * Get the postrun script. - * - * @return Postrun script. - */ - public Optional getPostrun() { - //noinspection unchecked - return Optional.ofNullable(getCapability(POSTRUN_OPTION)) - .map(v -> new PowerShellData((Map) v)); - } -} diff --git a/src/test/java/io/appium/java_client/drivers/options/OptionsBuildingTest.java b/src/test/java/io/appium/java_client/drivers/options/OptionsBuildingTest.java index f5a9716a8..de1f65b96 100644 --- a/src/test/java/io/appium/java_client/drivers/options/OptionsBuildingTest.java +++ b/src/test/java/io/appium/java_client/drivers/options/OptionsBuildingTest.java @@ -32,9 +32,8 @@ import io.appium.java_client.remote.AutomationName; import io.appium.java_client.safari.options.SafariOptions; import io.appium.java_client.safari.options.WebrtcData; +import io.appium.java_client.wincore.options.PowerShellData; import io.appium.java_client.wincore.options.WincoreOptions; -import io.appium.java_client.windows.options.PowerShellData; -import io.appium.java_client.windows.options.WindowsOptions; import org.junit.jupiter.api.Test; import org.openqa.selenium.Platform; @@ -118,19 +117,6 @@ public void canBuildEspressoOptions() { assertTrue(options.doesForceEspressoRebuild().orElse(false)); } - @Test - public void canBuildWindowsOptions() { - WindowsOptions options = new WindowsOptions(); - assertEquals(Platform.WINDOWS, options.getPlatformName()); - assertEquals(AutomationName.WINDOWS, options.getAutomationName().orElse(null)); - options.setNewCommandTimeout(Duration.ofSeconds(10)) - .setPrerun(new PowerShellData().withScript("yolo prescript")) - .setPostrun(new PowerShellData().withCommand("yolo command")); - assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null)); - assertEquals("yolo prescript", options.getPrerun().orElse(null).getScript().orElse(null)); - assertEquals("yolo command", options.getPostrun().orElse(null).getCommand().orElse(null)); - } - @Test public void canBuildWincoreOptions() { WincoreOptions options = new WincoreOptions(); diff --git a/src/test/java/io/appium/java_client/remote/ExtensionCommandsOverHttpTest.java b/src/test/java/io/appium/java_client/remote/ExtensionCommandsOverHttpTest.java index 4190850f1..00bfda5a6 100644 --- a/src/test/java/io/appium/java_client/remote/ExtensionCommandsOverHttpTest.java +++ b/src/test/java/io/appium/java_client/remote/ExtensionCommandsOverHttpTest.java @@ -25,8 +25,6 @@ import io.appium.java_client.wincore.WincoreDriver; import io.appium.java_client.wincore.WincoreStartScreenRecordingOptions; import io.appium.java_client.wincore.options.WincoreOptions; -import io.appium.java_client.windows.WindowsDriver; -import io.appium.java_client.windows.options.WindowsOptions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -129,34 +127,6 @@ void emulatorPowerStateUsesTheDriverExtension() throws IOException { assertEquals(List.of(Map.of("state", "off")), lastBody().get("args")); } - @Test - void windowsFilesAreTransferredWithTheDriverCommands() throws IOException { - var driver = new WindowsDriver(url(), new WindowsOptions()); - - assertArrayEquals("data".getBytes(StandardCharsets.UTF_8), driver.pullFile("C:\\a.txt")); - assertEquals("POST /session/s1/appium/device/pull_file", lastRequest()); - assertEquals(Map.of("path", "C:\\a.txt"), lastBody()); - - assertArrayEquals("data".getBytes(StandardCharsets.UTF_8), driver.pullFolder("C:\\dir")); - assertEquals("POST /session/s1/appium/device/pull_folder", lastRequest()); - assertEquals(Map.of("path", "C:\\dir"), lastBody()); - - driver.pushFile("C:\\b.txt", "ZGF0YQ==".getBytes(StandardCharsets.UTF_8)); - assertEquals("POST /session/s1/appium/device/push_file", lastRequest()); - assertEquals(Map.of("path", "C:\\b.txt", "data", "ZGF0YQ=="), lastBody()); - } - - @Test - void windowsAppIsLaunchedAndClosedWithTheDriverExtensions() throws IOException { - var driver = new WindowsDriver(url(), new WindowsOptions()); - - driver.closeApp(); - assertEquals("windows: closeApp", lastBody().get("script")); - - driver.launchApp(); - assertEquals("windows: launchApp", lastBody().get("script")); - } - @Test void wincoreFilesAreTransferredWithTheDriverCommands() throws IOException { var driver = new WincoreDriver(url(), new WincoreOptions()); diff --git a/src/test/resources/architecture/dependency-baseline.txt b/src/test/resources/architecture/dependency-baseline.txt index 39174d840..d4d871662 100644 --- a/src/test/resources/architecture/dependency-baseline.txt +++ b/src/test/resources/architecture/dependency-baseline.txt @@ -2,8 +2,3 @@ # core -> driver and driver -> other driver edges are removed in Phase 1; this file must end empty. io.appium.java_client.service.local.AppiumServiceBuilder -> io.appium.java_client.android.options.context.SupportsChromedriverExecutableOption [core -> android] io.appium.java_client.service.local.AppiumServiceBuilder -> io.appium.java_client.android.options.signing.SupportsKeystoreOptions [core -> android] -io.appium.java_client.wincore.options.WincoreOptions -> io.appium.java_client.android.options.context.SupportsWebviewDevtoolsPortOption [wincore -> android] -io.appium.java_client.wincore.options.WincoreOptions -> io.appium.java_client.windows.options.PowerShellData [wincore -> windows] -io.appium.java_client.wincore.options.WincoreOptions -> io.appium.java_client.windows.options.SupportsAppArgumentsOption [wincore -> windows] -io.appium.java_client.wincore.options.WincoreOptions -> io.appium.java_client.windows.options.SupportsAppTopLevelWindowOption [wincore -> windows] -io.appium.java_client.wincore.options.WincoreOptions -> io.appium.java_client.windows.options.SupportsAppWorkingDirOption [wincore -> windows]