-
-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Windows driver options (#1564)
- Loading branch information
1 parent
853ef49
commit 3fd3bac
Showing
15 changed files
with
611 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/io/appium/java_client/windows/options/RunScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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.BaseMapOptionData; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class RunScript extends BaseMapOptionData<RunScript> { | ||
public RunScript() { | ||
} | ||
|
||
public RunScript(Map<String, Object> options) { | ||
super(options); | ||
} | ||
|
||
/** | ||
* Allows to provide a multiline PowerShell script. | ||
* | ||
* @param script A valid PowerShell script. | ||
* @return self instance for chaining. | ||
*/ | ||
public RunScript withScript(String script) { | ||
return assignOptionValue("script", script); | ||
} | ||
|
||
/** | ||
* Get a multiline PowerShell script. | ||
* | ||
* @return PowerShell script. | ||
*/ | ||
public Optional<String> getScript() { | ||
return getOptionValue("script"); | ||
} | ||
|
||
/** | ||
* Allows to provide a single-line PowerShell script. | ||
* | ||
* @param command A valid PowerShell script. | ||
* @return self instance for chaining. | ||
*/ | ||
public RunScript withCommand(String command) { | ||
return assignOptionValue("command", command); | ||
} | ||
|
||
/** | ||
* Get a single-line PowerShell script. | ||
* | ||
* @return PowerShell script. | ||
*/ | ||
public Optional<String> getCommand() { | ||
return getOptionValue("command"); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/io/appium/java_client/windows/options/SupportsAppArgumentsOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 org.openqa.selenium.Capabilities; | ||
|
||
import java.net.URL; | ||
import java.util.Optional; | ||
|
||
public interface SupportsAppArgumentsOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String APP_ARGUMENTS_OPTION = "appArguments"; | ||
|
||
/** | ||
* Application arguments string. | ||
* | ||
* @param args E.g. "/?" | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAppArguments(String args) { | ||
return amend(APP_ARGUMENTS_OPTION, args); | ||
} | ||
|
||
/** | ||
* Get application arguments. | ||
* | ||
* @return Application arguments. | ||
*/ | ||
default Optional<String> setAppArguments() { | ||
return Optional.ofNullable((String) getCapability(APP_ARGUMENTS_OPTION)); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/io/appium/java_client/windows/options/SupportsAppTopLevelWindowOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 org.openqa.selenium.Capabilities; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SupportsAppTopLevelWindowOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String APP_TOP_LEVEL_WINDOW_OPTION = "appTopLevelWindow"; | ||
|
||
/** | ||
* Set the hexadecimal handle of an existing application top level | ||
* window to attach to, for example 0x12345 (should be of string type). | ||
* Either this capability or app one must be provided on session startup. | ||
* | ||
* @param identifier E.g. "0x12345". | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAppTopLevelWindow(String identifier) { | ||
return amend(APP_TOP_LEVEL_WINDOW_OPTION, identifier); | ||
} | ||
|
||
/** | ||
* Get the hexadecimal handle of an existing application top level | ||
* window to attach to. | ||
* | ||
* @return Top level window handle. | ||
*/ | ||
default Optional<String> getAppTopLevelWindow() { | ||
return Optional.ofNullable((String) getCapability(APP_TOP_LEVEL_WINDOW_OPTION)); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/io/appium/java_client/windows/options/SupportsAppWorkingDirOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 org.openqa.selenium.Capabilities; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SupportsAppWorkingDirOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String APP_WORKING_DIR_OPTION = "appWorkingDir"; | ||
|
||
/** | ||
* Full path to the folder, which is going to be set as the working | ||
* dir for the application under test. This is only applicable for classic apps. | ||
* | ||
* @param path Existing folder path on the server file system. | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAppWorkingDir(String path) { | ||
return amend(APP_WORKING_DIR_OPTION, path); | ||
} | ||
|
||
/** | ||
* Get the full path to the folder, which is going to be set as the working | ||
* dir for the application under test. | ||
* | ||
* @return Folder path on the server file system. | ||
*/ | ||
default Optional<String> getAppWorkingDir() { | ||
return Optional.ofNullable((String) getCapability(APP_WORKING_DIR_OPTION)); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/io/appium/java_client/windows/options/SupportsCreateSessionTimeoutOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 org.openqa.selenium.Capabilities; | ||
|
||
import java.time.Duration; | ||
import java.util.Optional; | ||
|
||
import static io.appium.java_client.internal.CapabilityHelpers.toDuration; | ||
|
||
public interface SupportsCreateSessionTimeoutOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
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<Duration> getCreateSessionTimeout() { | ||
return Optional.ofNullable( | ||
toDuration(getCapability(CREATE_SESSION_TIMEOUT_OPTION)) | ||
); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ain/java/io/appium/java_client/windows/options/SupportsMsExperimentalWebDriverOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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 org.openqa.selenium.Capabilities; | ||
|
||
import java.util.Optional; | ||
|
||
import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean; | ||
|
||
public interface SupportsMsExperimentalWebDriverOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
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<Boolean> isExperimentalWebDriver() { | ||
return Optional.ofNullable(toSafeBoolean(getCapability(MS_EXPERIMENTAL_WEBDRIVER_OPTION))); | ||
} | ||
} |
Oops, something went wrong.