diff --git a/appium/options/android/common/adb/adb_options.py b/appium/options/android/common/adb/adb_options.py
index 001728f1..491081bd 100644
--- a/appium/options/android/common/adb/adb_options.py
+++ b/appium/options/android/common/adb/adb_options.py
@@ -15,14 +15,18 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
class AdbExecTimeoutOption(SupportsCapabilities):
ADB_EXEC_TIMEOUT = 'adbExecTimeout'
- adb_exec_timeout = OptionsDescriptor('ADB_EXEC_TIMEOUT', transform_get, transform_set)
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+
+ adb_exec_timeout = OptionsDescriptor('ADB_EXEC_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Gets and Sets Maximum time to wait until single ADB command is executed.
20000 ms by default.
diff --git a/appium/options/android/common/app/app_options.py b/appium/options/android/common/app/app_options.py
index 4c12090e..3699aefd 100644
--- a/appium/options/android/common/app/app_options.py
+++ b/appium/options/android/common/app/app_options.py
@@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -50,7 +51,10 @@ class AllowTestPackagesOption(SupportsCapabilities):
class AndroidInstallTimeoutOption(SupportsCapabilities):
ANDROID_INSTALL_TIMEOUT = 'androidInstallTimeout'
- android_install_timeout = OptionsDescriptor('ANDROID_INSTALL_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ android_install_timeout = OptionsDescriptor('ANDROID_INSTALL_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Maximum amount of time to wait until the application under test is installed.
90000 ms by default
diff --git a/appium/options/android/common/avd/avd_options.py b/appium/options/android/common/avd/avd_options.py
index dc969dcf..c72944e2 100644
--- a/appium/options/android/common/avd/avd_options.py
+++ b/appium/options/android/common/avd/avd_options.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from appium.options.common.supports_capabilities import SupportsCapabilities
diff --git a/appium/options/android/common/context/context_options.py b/appium/options/android/common/context/context_options.py
index 4af80aea..109cbd5f 100644
--- a/appium/options/android/common/context/context_options.py
+++ b/appium/options/android/common/context/context_options.py
@@ -15,13 +15,17 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
class AutoWebviewTimeoutOption(SupportsCapabilities):
AUTO_WEBVIEW_TIMEOUT = 'autoWebviewTimeout'
- auto_webview_timeout = OptionsDescriptor('AUTO_WEBVIEW_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ auto_webview_timeout = OptionsDescriptor('AUTO_WEBVIEW_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Set the maximum timeout to wait until a web view is
available if autoWebview capability is set to true. 2000 ms by default.
diff --git a/appium/options/android/common/locking/locking_options.py b/appium/options/android/common/locking/locking_options.py
index 8fb7a708..b4850d6b 100644
--- a/appium/options/android/common/locking/locking_options.py
+++ b/appium/options/android/common/locking/locking_options.py
@@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -106,7 +107,10 @@ class UnlockStrategyOption(SupportsCapabilities):
class UnlockSuccessTimeoutOption(SupportsCapabilities):
UNLOCK_SUCCESS_TIMEOUT = 'unlockSuccessTimeout'
- unlock_success_timeout = OptionsDescriptor('UNLOCK_SUCCESS_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ unlock_success_timeout = OptionsDescriptor('UNLOCK_SUCCESS_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Maximum timeout to wait until the device is unlocked.
2000 ms by default.
diff --git a/appium/options/android/common/signing/signing_options.py b/appium/options/android/common/signing/signing_options.py
index 3d40d797..0b54cc75 100644
--- a/appium/options/android/common/signing/signing_options.py
+++ b/appium/options/android/common/signing/signing_options.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from appium.options.common.supports_capabilities import SupportsCapabilities
diff --git a/appium/options/base_options.py b/appium/options/base_options.py
new file mode 100644
index 00000000..242800bc
--- /dev/null
+++ b/appium/options/base_options.py
@@ -0,0 +1,34 @@
+from typing import Any, TypeVar, Generic, Type, Callable, Optional
+
+from appium.options.common.supports_capabilities import SupportsCapabilities
+
+RT = TypeVar("RT")
+VT = TypeVar("VT")
+C = TypeVar('C', bound='SupportsCapabilities')
+
+class OptionsDescriptor(Generic[RT, VT]):
+ """Generic Descriptor class which calls get_capability and set_capability:
+ without transforming the values
+
+ If transformation method is passed, get_capability and set_capability:
+ method will be called with transformed value
+ """
+ def __init__(self, name: str,
+ tget: Optional[Callable[[Any], RT]] = None,
+ tset: Optional[Callable[[VT], Any]] = None) -> None:
+ self.name = name
+ self.tget = tget
+ self.tset = tset
+
+ def __get__(self, obj: C, cls: Type[C]) -> RT:
+ value = obj.get_capability(self.name)
+ if self.tget:
+ # transform the value and then return
+ return self.tget(obj, value)
+ return value
+
+ def __set__(self, obj: C, value: VT) -> None:
+ if self.tset:
+ # transform the value before setting
+ transformed_value = self.tset(obj, value)
+ obj.set_capability(self.name, transformed_value)
\ No newline at end of file
diff --git a/appium/options/common/common_options.py b/appium/options/common/common_options.py
index 370942ba..8b1a8eed 100644
--- a/appium/options/common/common_options.py
+++ b/appium/options/common/common_options.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from .supports_capabilities import SupportsCapabilities
diff --git a/appium/options/gecko/gecko_options.py b/appium/options/gecko/gecko_options.py
index de22b27b..f3bb2703 100644
--- a/appium/options/gecko/gecko_options.py
+++ b/appium/options/gecko/gecko_options.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from appium.options.common.supports_capabilities import SupportsCapabilities
diff --git a/appium/options/ios/safari/safari_options.py b/appium/options/ios/safari/safari_options.py
index f72183b9..ee3896a7 100644
--- a/appium/options/ios/safari/safari_options.py
+++ b/appium/options/ios/safari/safari_options.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from appium.options.common.supports_capabilities import SupportsCapabilities
diff --git a/appium/options/ios/xcuitest/app/app_options.py b/appium/options/ios/xcuitest/app/app_options.py
index 66c57d05..055823af 100644
--- a/appium/options/ios/xcuitest/app/app_options.py
+++ b/appium/options/ios/xcuitest/app/app_options.py
@@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -55,7 +56,10 @@ class AppInstallStrategyOption(SupportsCapabilities):
class AppPushTimeoutOption(SupportsCapabilities):
APP_PUSH_TIMEOUT = 'appPushTimeout'
- app_push_timeout = OptionsDescriptor('APP_PUSH_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ app_push_timeout = OptionsDescriptor('APP_PUSH_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
The timeout for application upload.
Works for real devices only.
@@ -105,4 +109,4 @@ class LocalizableStringsDirOption(SupportsCapabilities):
- `Optional[str]`
- Set
- `None`
- """
+ """
\ No newline at end of file
diff --git a/appium/options/ios/xcuitest/other/other_options.py b/appium/options/ios/xcuitest/other/other_options.py
index 7d0bb1d3..0f5509f9 100644
--- a/appium/options/ios/xcuitest/other/other_options.py
+++ b/appium/options/ios/xcuitest/other/other_options.py
@@ -17,7 +17,7 @@
from datetime import timedelta
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -108,14 +108,14 @@ class LaunchWithIdbOption(SupportsCapabilities):
class CommandTimeoutsOption(SupportsCapabilities):
COMMAND_TIMEOUTS = 'commandTimeouts'
- def transform_get(self, value):
+ def transform_timeout_get(self, value):
if value is None:
return None
if isinstance(value, dict):
return {k: timedelta(milliseconds=v) for k, v in value.items()}
return timedelta(milliseconds=int(value))
- def transform_set(self, value):
+ def transform_timeout_set(self, value):
if isinstance(value, dict):
return {k: int(v.total_seconds() * 1000) for k, v in value.items()}
elif isinstance(value, timedelta):
@@ -123,7 +123,7 @@ def transform_set(self, value):
else:
return value
- command_timeouts = OptionsDescriptor('COMMAND_TIMEOUTS', transform_get, transform_set)
+ command_timeouts = OptionsDescriptor('COMMAND_TIMEOUTS', transform_timeout_get, transform_timeout_set)
"""
Custom timeout for all WDA backend commands execution.
This might be useful if WDA backend freezes unexpectedly or requires too
diff --git a/appium/options/ios/xcuitest/simulator/simulator_options.py b/appium/options/ios/xcuitest/simulator/simulator_options.py
index 1b404aa0..d7836488 100644
--- a/appium/options/ios/xcuitest/simulator/simulator_options.py
+++ b/appium/options/ios/xcuitest/simulator/simulator_options.py
@@ -1,6 +1,7 @@
import json
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -484,7 +485,10 @@ class SimulatorPasteboardAutomaticSyncOption(SupportsCapabilities):
class SimulatorStartupTimeoutOption(SupportsCapabilities):
SIMULATOR_STARTUP_TIMEOUT = 'simulatorStartupTimeout'
- simulator_startup_timeout = OptionsDescriptor('SIMULATOR_STARTUP_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ simulator_startup_timeout = OptionsDescriptor('SIMULATOR_STARTUP_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Allows to change the default timeout for Simulator startup.
By default, this value is set to 120000ms (2 minutes),
diff --git a/appium/options/ios/xcuitest/wda/wda_options.py b/appium/options/ios/xcuitest/wda/wda_options.py
index 8241b843..3a0d0674 100644
--- a/appium/options/ios/xcuitest/wda/wda_options.py
+++ b/appium/options/ios/xcuitest/wda/wda_options.py
@@ -17,7 +17,7 @@
from datetime import timedelta
-from appium.options.transformers import OptionsDescriptor
+from appium.options.base_options import OptionsDescriptor
from appium.options.common.supports_capabilities import SupportsCapabilities
class AllowProvisioningDeviceRegistrationOption(SupportsCapabilities):
diff --git a/appium/options/ios/xcuitest/webview/webview_options.py b/appium/options/ios/xcuitest/webview/webview_options.py
index cc23d0ac..f39538dd 100644
--- a/appium/options/ios/xcuitest/webview/webview_options.py
+++ b/appium/options/ios/xcuitest/webview/webview_options.py
@@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -441,7 +442,10 @@ class SafariWebInspectorMaxFrameLengthOption(SupportsCapabilities):
class WebkitResponseTimeoutOption(SupportsCapabilities):
WEBKIT_RESPONSE_TIMEOUT = 'webkitResponseTimeout'
- webkit_response_timeout = OptionsDescriptor('WEBKIT_RESPONSE_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ webkit_response_timeout = OptionsDescriptor('WEBKIT_RESPONSE_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Time to wait for a response from WebKit in a Safari session.
(Real device only) Set the time to wait for a respons
@@ -495,7 +499,10 @@ class WebviewConnectRetriesOption(SupportsCapabilities):
class WebviewConnectTimeoutOption(SupportsCapabilities):
WEBVIEW_CONNECT_TIMEOUT = 'webviewConnectTimeout'
- webview_connect_timeout = OptionsDescriptor('WEBVIEW_CONNECT_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ webview_connect_timeout = OptionsDescriptor('WEBVIEW_CONNECT_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
The time to wait for the initial presence of webviews in
MobileSafari or hybrid apps. Defaults to 0ms.
diff --git a/appium/options/mac/mac2/mac_options.py b/appium/options/mac/mac2/mac_options.py
index 5c20625e..4dee3ce8 100644
--- a/appium/options/mac/mac2/mac_options.py
+++ b/appium/options/mac/mac2/mac_options.py
@@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_get, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
class ArgumentsOption(SupportsCapabilities):
@@ -104,7 +105,10 @@ class EnvironmentOption(SupportsCapabilities):
class ServerStartupTimeoutOption(SupportsCapabilities):
SERVER_STARTUP_TIMEOUT = 'serverStartupTimeout'
- server_startup_timeout = OptionsDescriptor('SERVER_STARTUP_TIMEOUT', transform_get, transform_set)
+
+ _transform_duration_get = DurationTransformer.transform_duration_get
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ server_startup_timeout = OptionsDescriptor('SERVER_STARTUP_TIMEOUT', _transform_duration_get, _transform_duration_set)
"""
Gets and Sets the timeout to wait util the WebDriverAgentMac
project is built and started.
diff --git a/appium/options/transformers.py b/appium/options/transformers.py
index ccba2f2d..454b7dea 100644
--- a/appium/options/transformers.py
+++ b/appium/options/transformers.py
@@ -1,39 +1,15 @@
from datetime import timedelta
-from typing import Any, TypeVar, Generic, Type
-
-from appium.options.common.supports_capabilities import SupportsCapabilities
-
-T = TypeVar('T')
-C = TypeVar('C', bound='SupportsCapabilities')
-
-class OptionsDescriptor(Generic[T]):
- """Generic Descriptor class which calls get_capability and set_capability:
- without transforming the values
-
- If transformation method is passed, get_capability and set_capability:
- method will be called with transformed value
- """
- def __init__(self, name: str, tget=None, tset=None) -> None:
- self.name = name
- self.tget = tget
- self.tset = tset
-
- def __get__(self, obj: C, cls: Type[C]) -> Any:
- value = obj.get_capability(self.name)
- if self.tget:
- # transform the value and then return
- return self.tget(obj, value)
- return value
-
- def __set__(self, obj: C, value: Any) -> None:
- if self.tset:
- # transform the value before setting
- value = self.tset(obj, value)
- obj.set_capability(self.name, value)
-
-def transform_get(self, value):
- """Transfroms the value into timedelta"""
- return None if value is None else timedelta(milliseconds=value)
-
-def transform_set(self, value):
- return int(value.total_seconds() * 1000) if isinstance(value, timedelta) else value
\ No newline at end of file
+from typing import Any, TypeVar
+
+RT = TypeVar("RT")
+VT = TypeVar("VT")
+
+class DurationTransformer:
+ @staticmethod
+ def transform_duration_get(value: Any) -> RT:
+ """Transfroms the value into timedelta"""
+ return None if value is None else timedelta(milliseconds=value)
+
+ @staticmethod
+ def transform_duration_set(value: VT) -> Any:
+ return int(value.total_seconds() * 1000) if isinstance(value, timedelta) else value
\ No newline at end of file
diff --git a/appium/options/windows/windows/windows_options.py b/appium/options/windows/windows/windows_options.py
index b073d671..1f170415 100644
--- a/appium/options/windows/windows/windows_options.py
+++ b/appium/options/windows/windows/windows_options.py
@@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from appium.options.transformers import OptionsDescriptor, transform_set
+from appium.options.base_options import OptionsDescriptor
+from appium.options.transformers import DurationTransformer
from appium.options.common.supports_capabilities import SupportsCapabilities
@@ -104,7 +105,9 @@ class AppWorkingDirOption(SupportsCapabilities):
class CreateSessionTimeoutOption(SupportsCapabilities):
CREATE_SESSION_TIMEOUT = 'createSessionTimeout'
- create_session_timeout = OptionsDescriptor('CREATE_SESSION_TIMEOUT', tset=transform_set)
+
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ create_session_timeout = OptionsDescriptor('CREATE_SESSION_TIMEOUT', tset=_transform_duration_set)
"""
Set the timeout used to retry Appium Windows Driver session startup.
This capability could be used as a workaround for the long startup times
@@ -160,7 +163,9 @@ class ExperimentalWebDriverOption(SupportsCapabilities):
class WaitForAppLaunchOption(SupportsCapabilities):
WAIT_FOR_APP_LAUNCH = 'ms:waitForAppLaunch'
- wait_for_app_launch = OptionsDescriptor('WAIT_FOR_APP_LAUNCH', tset=transform_set)
+
+ _transform_duration_set = DurationTransformer.transform_duration_set
+ wait_for_app_launch = OptionsDescriptor('WAIT_FOR_APP_LAUNCH', tset=_transform_duration_set)
"""
Similar to createSessionTimeout, but is
applied on the server side. Enables Appium Windows Driver to wait for
diff --git a/test/unit/junit.xml b/test/unit/junit.xml
index 7e1cc364..8e356ca6 100644
--- a/test/unit/junit.xml
+++ b/test/unit/junit.xml
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file