From 6f802e61f8fe422f7e05e6f81ca0282e8b318bdd Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 15 Jun 2022 16:13:27 +0200 Subject: [PATCH 1/3] feat: Add common options --- appium/options/android/espresso/base.py | 18 ++++++++ appium/options/android/uiautomator2/base.py | 24 +++++++++++ appium/options/common/app_option.py | 41 +++++++++++++++++++ appium/options/common/auto_web_view_option.py | 40 ++++++++++++++++++ .../options/common/automation_name_option.py | 8 +--- appium/options/common/base.py | 10 +++++ .../common/clear_system_files_option.py | 38 +++++++++++++++++ appium/options/common/device_name_option.py | 38 +++++++++++++++++ .../enable_performance_logging_option.py | 38 +++++++++++++++++ appium/options/common/event_timings_option.py | 40 ++++++++++++++++++ appium/options/common/full_reset_option.py | 38 +++++++++++++++++ appium/options/common/is_headless_option.py | 39 ++++++++++++++++++ appium/options/common/language_option.py | 38 +++++++++++++++++ appium/options/common/locale_option.py | 38 +++++++++++++++++ .../common/new_command_timeout_option.py | 41 +++++++++++++++++++ appium/options/common/no_reset_option.py | 38 +++++++++++++++++ appium/options/common/orientation_option.py | 40 ++++++++++++++++++ appium/options/common/other_apps_option.py | 39 ++++++++++++++++++ appium/options/common/postrun_option.py | 32 +++++++++++++++ appium/options/common/prerun_option.py | 32 +++++++++++++++ ...rint_page_source_on_find_failure_option.py | 40 ++++++++++++++++++ .../options/common/skip_log_capture_option.py | 38 +++++++++++++++++ appium/options/common/udid_option.py | 38 +++++++++++++++++ appium/options/ios/xcuitest/base.py | 24 +++++++++++ appium/options/mac/mac2/base.py | 4 ++ appium/options/windows/windows/base.py | 4 ++ 26 files changed, 812 insertions(+), 6 deletions(-) create mode 100644 appium/options/common/app_option.py create mode 100644 appium/options/common/auto_web_view_option.py create mode 100644 appium/options/common/clear_system_files_option.py create mode 100644 appium/options/common/device_name_option.py create mode 100644 appium/options/common/enable_performance_logging_option.py create mode 100644 appium/options/common/event_timings_option.py create mode 100644 appium/options/common/full_reset_option.py create mode 100644 appium/options/common/is_headless_option.py create mode 100644 appium/options/common/language_option.py create mode 100644 appium/options/common/locale_option.py create mode 100644 appium/options/common/new_command_timeout_option.py create mode 100644 appium/options/common/no_reset_option.py create mode 100644 appium/options/common/orientation_option.py create mode 100644 appium/options/common/other_apps_option.py create mode 100644 appium/options/common/postrun_option.py create mode 100644 appium/options/common/prerun_option.py create mode 100644 appium/options/common/print_page_source_on_find_failure_option.py create mode 100644 appium/options/common/skip_log_capture_option.py create mode 100644 appium/options/common/udid_option.py diff --git a/appium/options/android/espresso/base.py b/appium/options/android/espresso/base.py index b38640c38..be24dd982 100644 --- a/appium/options/android/espresso/base.py +++ b/appium/options/android/espresso/base.py @@ -17,11 +17,29 @@ from typing import Dict +from appium.options.common.app_option import AppOption +from appium.options.common.auto_web_view_option import AutoWebViewOption from appium.options.common.base import AppiumOptions +from appium.options.common.device_name_option import DeviceNameOption +from appium.options.common.is_headless_option import IsHeadlessOption +from appium.options.common.language_option import LanguageOption +from appium.options.common.locale_option import LocaleOption +from appium.options.common.orientation_option import OrientationOption +from appium.options.common.skip_log_capture_option import SkipLogCaptureOption +from appium.options.common.udid_option import UdidOption class EspressoOptions( AppiumOptions, + AppOption, + OrientationOption, + UdidOption, + LanguageOption, + LocaleOption, + IsHeadlessOption, + SkipLogCaptureOption, + AutoWebViewOption, + DeviceNameOption, ): @property def default_capabilities(self) -> Dict: diff --git a/appium/options/android/uiautomator2/base.py b/appium/options/android/uiautomator2/base.py index d067d78f1..d7e4fe501 100644 --- a/appium/options/android/uiautomator2/base.py +++ b/appium/options/android/uiautomator2/base.py @@ -17,11 +17,35 @@ from typing import Dict +from appium.options.common.app_option import AppOption +from appium.options.common.auto_web_view_option import AutoWebViewOption from appium.options.common.base import AppiumOptions +from appium.options.common.clear_system_files_option import ClearSystemFilesOption +from appium.options.common.device_name_option import DeviceNameOption +from appium.options.common.enable_performance_logging_option import EnablePerformanceLoggingOption +from appium.options.common.is_headless_option import IsHeadlessOption +from appium.options.common.language_option import LanguageOption +from appium.options.common.locale_option import LocaleOption +from appium.options.common.orientation_option import OrientationOption +from appium.options.common.other_apps_option import OtherAppsOption +from appium.options.common.skip_log_capture_option import SkipLogCaptureOption +from appium.options.common.udid_option import UdidOption class UiAutomator2Options( AppiumOptions, + AppOption, + ClearSystemFilesOption, + OrientationOption, + UdidOption, + LanguageOption, + LocaleOption, + IsHeadlessOption, + SkipLogCaptureOption, + AutoWebViewOption, + EnablePerformanceLoggingOption, + OtherAppsOption, + DeviceNameOption, ): @property def default_capabilities(self) -> Dict: diff --git a/appium/options/common/app_option.py b/appium/options/common/app_option.py new file mode 100644 index 000000000..2d76dd674 --- /dev/null +++ b/appium/options/common/app_option.py @@ -0,0 +1,41 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class AppOption(SupportsCapabilities): + APP = 'app' + + @property + def app(self) -> Optional[str]: + """ + :Returns: String representing app location. + """ + return self.get_capability(self.APP) + + @app.setter + def app(self, value: str) -> None: + """ + Set the absolute local path for the location of the App. + The app must be located on the same machine where Appium + server is running. + Could also be a valid URL. + """ + self.set_capability(self.APP, value) diff --git a/appium/options/common/auto_web_view_option.py b/appium/options/common/auto_web_view_option.py new file mode 100644 index 000000000..16c977492 --- /dev/null +++ b/appium/options/common/auto_web_view_option.py @@ -0,0 +1,40 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class AutoWebViewOption(SupportsCapabilities): + AUTO_WEB_VIEW = 'autoWebView' + + @property + def auto_web_view(self) -> Optional[bool]: + """ + :Returns: Whether the driver should try to automatically switch + to a web view context after the session is started. + """ + return self.get_capability(self.AUTO_WEB_VIEW) + + @auto_web_view.setter + def auto_web_view(self, value: bool) -> None: + """ + Set whether the driver should try to automatically switch + a web view context after the session is started. + """ + self.set_capability(self.AUTO_WEB_VIEW, value) diff --git a/appium/options/common/automation_name_option.py b/appium/options/common/automation_name_option.py index b52250608..c2004b413 100644 --- a/appium/options/common/automation_name_option.py +++ b/appium/options/common/automation_name_option.py @@ -26,17 +26,13 @@ class AutomationNameOption(SupportsCapabilities): @property def automation_name(self) -> Optional[str]: """ - :Returns: String representing the name of the automation engine + :Returns: String representing the name of the automation engine name. """ return self.get_capability(self.AUTOMATION_NAME) @automation_name.setter def automation_name(self, value: str) -> None: """ - Set the automation driver to use. - - :Args: - - value: One of supported automation names - + Set the automation driver name to use for the given platform. """ self.set_capability(self.AUTOMATION_NAME, value) diff --git a/appium/options/common/base.py b/appium/options/common/base.py index f7245d257..c5869cab8 100644 --- a/appium/options/common/base.py +++ b/appium/options/common/base.py @@ -21,6 +21,11 @@ from selenium.webdriver.common.options import BaseOptions from .automation_name_option import AutomationNameOption +from .event_timings_option import EventTimingsOption +from .full_reset_option import FullResetOption +from .new_command_timeout_option import NewCommandTimeoutOption +from .no_reset_option import NoResetOption +from .print_page_source_on_find_failure_option import PrintPageSourceOnFindFailureOption APPIUM_PREFIX = 'appium:' T = TypeVar('T', bound='AppiumOptions') @@ -29,6 +34,11 @@ class AppiumOptions( BaseOptions, AutomationNameOption, + EventTimingsOption, + PrintPageSourceOnFindFailureOption, + NoResetOption, + FullResetOption, + NewCommandTimeoutOption, ): _caps: Dict PLATFORM_NAME = 'platformName' diff --git a/appium/options/common/clear_system_files_option.py b/appium/options/common/clear_system_files_option.py new file mode 100644 index 000000000..34a321cb5 --- /dev/null +++ b/appium/options/common/clear_system_files_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class ClearSystemFilesOption(SupportsCapabilities): + CLEAR_SYSTEM_FILES = 'clearSystemFiles' + + @property + def clear_system_files(self) -> Optional[bool]: + """ + :Returns: Whether the driver should delete generated files at the end of a session. + """ + return self.get_capability(self.CLEAR_SYSTEM_FILES) + + @clear_system_files.setter + def clear_system_files(self, value: bool) -> None: + """ + Set whether the driver should delete generated files at the end of a session. + """ + self.set_capability(self.CLEAR_SYSTEM_FILES, value) diff --git a/appium/options/common/device_name_option.py b/appium/options/common/device_name_option.py new file mode 100644 index 000000000..285949fd0 --- /dev/null +++ b/appium/options/common/device_name_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class DeviceNameOption(SupportsCapabilities): + DEVICE_NAME = 'deviceName' + + @property + def device_name(self) -> Optional[str]: + """ + :Returns: The name of the device. + """ + return self.get_capability(self.DEVICE_NAME) + + @device_name.setter + def device_name(self, value: str) -> None: + """ + Set the name of the device to be used in the test. + """ + self.set_capability(self.DEVICE_NAME, value) diff --git a/appium/options/common/enable_performance_logging_option.py b/appium/options/common/enable_performance_logging_option.py new file mode 100644 index 000000000..4fa06f320 --- /dev/null +++ b/appium/options/common/enable_performance_logging_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class EnablePerformanceLoggingOption(SupportsCapabilities): + ENABLE_PERFORMANCE_LOGGING = 'enablePerformanceLogging' + + @property + def enable_performance_logging(self) -> Optional[bool]: + """ + :Returns: Whether to enable additional performance logging. + """ + return self.get_capability(self.ENABLE_PERFORMANCE_LOGGING) + + @enable_performance_logging.setter + def enable_performance_logging(self, value: bool) -> None: + """ + Set whether to enable additional performance logging. + """ + self.set_capability(self.ENABLE_PERFORMANCE_LOGGING, value) diff --git a/appium/options/common/event_timings_option.py b/appium/options/common/event_timings_option.py new file mode 100644 index 000000000..601c20903 --- /dev/null +++ b/appium/options/common/event_timings_option.py @@ -0,0 +1,40 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class EventTimingsOption(SupportsCapabilities): + EVENT_TIMINGS = 'eventTimings' + + @property + def event_timings(self) -> Optional[bool]: + """ + :Returns: Whether the driver should to report the timings + for various Appium-internal events. + """ + return self.get_capability(self.EVENT_TIMINGS) + + @event_timings.setter + def event_timings(self, value: bool) -> None: + """ + Set whether the driver should to report the timings + for various Appium-internal events. + """ + self.set_capability(self.EVENT_TIMINGS, value) diff --git a/appium/options/common/full_reset_option.py b/appium/options/common/full_reset_option.py new file mode 100644 index 000000000..ea11f6295 --- /dev/null +++ b/appium/options/common/full_reset_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class FullResetOption(SupportsCapabilities): + FULL_RESET = 'fullReset' + + @property + def full_reset(self) -> Optional[bool]: + """ + :Returns: Whether the driver should perform a full reset. + """ + return self.get_capability(self.FULL_RESET) + + @full_reset.setter + def full_reset(self, value: bool) -> None: + """ + Set whether the driver should perform a full reset. + """ + self.set_capability(self.FULL_RESET, value) diff --git a/appium/options/common/is_headless_option.py b/appium/options/common/is_headless_option.py new file mode 100644 index 000000000..95409c8e0 --- /dev/null +++ b/appium/options/common/is_headless_option.py @@ -0,0 +1,39 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class IsHeadlessOption(SupportsCapabilities): + IS_HEADLESS = 'isHeadless' + + @property + def is_headless(self) -> Optional[bool]: + """ + :Returns: Whether the driver should start emulator/simulator in headless mode. + """ + return self.get_capability(self.IS_HEADLESS) + + @is_headless.setter + def is_headless(self, value: bool) -> None: + """ + Set emulator/simulator to start in headless mode (e.g. no UI is shown). + It is only applied if the emulator is not running before the test starts. + """ + self.set_capability(self.IS_HEADLESS, value) diff --git a/appium/options/common/language_option.py b/appium/options/common/language_option.py new file mode 100644 index 000000000..7c3cd492a --- /dev/null +++ b/appium/options/common/language_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class LanguageOption(SupportsCapabilities): + LANGUAGE = 'language' + + @property + def language(self) -> Optional[str]: + """ + :Returns: Language abbreviation to use in a test session. + """ + return self.get_capability(self.LANGUAGE) + + @language.setter + def language(self, value: str) -> None: + """ + Set language abbreviation to use in a test session. + """ + self.set_capability(self.LANGUAGE, value) diff --git a/appium/options/common/locale_option.py b/appium/options/common/locale_option.py new file mode 100644 index 000000000..05ccff6a2 --- /dev/null +++ b/appium/options/common/locale_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class LocaleOption(SupportsCapabilities): + LOCALE = 'locale' + + @property + def locale(self) -> Optional[str]: + """ + :Returns: Locale abbreviation to use in a test session. + """ + return self.get_capability(self.LOCALE) + + @locale.setter + def locale(self, value: str) -> None: + """ + Set locale abbreviation to use in a test session. + """ + self.set_capability(self.LOCALE, value) diff --git a/appium/options/common/new_command_timeout_option.py b/appium/options/common/new_command_timeout_option.py new file mode 100644 index 000000000..f9f572826 --- /dev/null +++ b/appium/options/common/new_command_timeout_option.py @@ -0,0 +1,41 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from datetime import timedelta +from typing import Optional, Union + +from .supports_capabilities import SupportsCapabilities + + +class NewCommandTimeoutOption(SupportsCapabilities): + NEW_COMMAND_TIMEOUT = 'newCommandTimeout' + + @property + def new_command_timeout(self) -> Optional[timedelta]: + """ + :Returns: The allowed time before seeing a new server command. + """ + value = self.get_capability(self.NEW_COMMAND_TIMEOUT) + return None if value is None else timedelta(seconds=value) + + @new_command_timeout.setter + def new_command_timeout(self, value: Union[timedelta, int]) -> None: + """ + Set the allowed time before seeing a new server command. + The value could either be provided as timedelta instance or an integer number of seconds. + """ + self.set_capability(self.NEW_COMMAND_TIMEOUT, value.seconds if isinstance(value, timedelta) else value) diff --git a/appium/options/common/no_reset_option.py b/appium/options/common/no_reset_option.py new file mode 100644 index 000000000..f5692fc46 --- /dev/null +++ b/appium/options/common/no_reset_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class NoResetOption(SupportsCapabilities): + NO_RESET = 'noReset' + + @property + def full_reset(self) -> Optional[bool]: + """ + :Returns: Whether the driver should not perform a reset. + """ + return self.get_capability(self.NO_RESET) + + @full_reset.setter + def full_reset(self, value: bool) -> None: + """ + Set whether the driver should not perform a reset. + """ + self.set_capability(self.NO_RESET, value) diff --git a/appium/options/common/orientation_option.py b/appium/options/common/orientation_option.py new file mode 100644 index 000000000..d111c15c2 --- /dev/null +++ b/appium/options/common/orientation_option.py @@ -0,0 +1,40 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class OrientationOption(SupportsCapabilities): + ORIENTATION = 'orientation' + + @property + def orientation(self) -> Optional[str]: + """ + :Returns: The orientation of the device's screen. + Usually this is either 'PORTRAIT' or 'LANDSCAPE'. + """ + return self.get_capability(self.ORIENTATION) + + @orientation.setter + def orientation(self, value: str) -> None: + """ + Set the orientation of the device's screen. + Usually this is either 'PORTRAIT' or 'LANDSCAPE'. + """ + self.set_capability(self.ORIENTATION, value) diff --git a/appium/options/common/other_apps_option.py b/appium/options/common/other_apps_option.py new file mode 100644 index 000000000..7fc755087 --- /dev/null +++ b/appium/options/common/other_apps_option.py @@ -0,0 +1,39 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class OtherAppsOption(SupportsCapabilities): + OTHER_APPS = 'otherApps' + + @property + def other_apps(self) -> Optional[str]: + """ + :Returns: Locations of apps to install before running a test. + """ + return self.get_capability(self.OTHER_APPS) + + @other_apps.setter + def other_apps(self, value: str) -> None: + """ + Set locations of apps to install before running a test. + Each item could be separated with a single comma. + """ + self.set_capability(self.OTHER_APPS, value) diff --git a/appium/options/common/postrun_option.py b/appium/options/common/postrun_option.py new file mode 100644 index 000000000..beea91e5c --- /dev/null +++ b/appium/options/common/postrun_option.py @@ -0,0 +1,32 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class PostrunOption(SupportsCapabilities): + POSTRUN = 'postrun' + + @property + def postrun(self) -> Optional[str]: + return self.get_capability(self.POSTRUN) + + @postrun.setter + def postrun(self, value: str) -> None: + self.set_capability(self.POSTRUN, value) diff --git a/appium/options/common/prerun_option.py b/appium/options/common/prerun_option.py new file mode 100644 index 000000000..3b2569a38 --- /dev/null +++ b/appium/options/common/prerun_option.py @@ -0,0 +1,32 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class PrerunOption(SupportsCapabilities): + PRERUN = 'prerun' + + @property + def prerun(self) -> Optional[str]: + return self.get_capability(self.PRERUN) + + @prerun.setter + def prerun(self, value: str) -> None: + self.set_capability(self.PRERUN, value) diff --git a/appium/options/common/print_page_source_on_find_failure_option.py b/appium/options/common/print_page_source_on_find_failure_option.py new file mode 100644 index 000000000..c67fcae55 --- /dev/null +++ b/appium/options/common/print_page_source_on_find_failure_option.py @@ -0,0 +1,40 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class PrintPageSourceOnFindFailureOption(SupportsCapabilities): + PRINT_PAGE_SOURCE_ON_FIND_FAILURE = 'printPageSourceOnFindFailure' + + @property + def print_page_source_on_find_failure(self) -> Optional[bool]: + """ + :Returns: Whether the driver should print the page source to the log + if a find failure occurs. + """ + return self.get_capability(self.PRINT_PAGE_SOURCE_ON_FIND_FAILURE) + + @print_page_source_on_find_failure.setter + def print_page_source_on_find_failure(self, value: bool) -> None: + """ + Set whether the driver should print the page source to the log + if a find failure occurs. + """ + self.set_capability(self.PRINT_PAGE_SOURCE_ON_FIND_FAILURE, value) diff --git a/appium/options/common/skip_log_capture_option.py b/appium/options/common/skip_log_capture_option.py new file mode 100644 index 000000000..e195f3ace --- /dev/null +++ b/appium/options/common/skip_log_capture_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class SkipLogCaptureOption(SupportsCapabilities): + SKIP_LOG_CAPTURE = 'skipLogCapture' + + @property + def skip_log_capture(self) -> Optional[bool]: + """ + :Returns: Whether the driver should not record device logs. + """ + return self.get_capability(self.SKIP_LOG_CAPTURE) + + @skip_log_capture.setter + def skip_log_capture(self, value: bool) -> None: + """ + Set whether the driver should not record device logs. + """ + self.set_capability(self.SKIP_LOG_CAPTURE, value) diff --git a/appium/options/common/udid_option.py b/appium/options/common/udid_option.py new file mode 100644 index 000000000..a1023702d --- /dev/null +++ b/appium/options/common/udid_option.py @@ -0,0 +1,38 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. 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. + +from typing import Optional + +from .supports_capabilities import SupportsCapabilities + + +class UdidOption(SupportsCapabilities): + UDID = 'udid' + + @property + def udid(self) -> Optional[str]: + """ + :Returns: The id of the device under test. + """ + return self.get_capability(self.UDID) + + @udid.setter + def udid(self, value: str) -> None: + """ + Set the id of the device under test. + """ + self.set_capability(self.UDID, value) diff --git a/appium/options/ios/xcuitest/base.py b/appium/options/ios/xcuitest/base.py index 9718dfec3..5b9a1eb2d 100644 --- a/appium/options/ios/xcuitest/base.py +++ b/appium/options/ios/xcuitest/base.py @@ -17,11 +17,35 @@ from typing import Dict +from appium.options.common.app_option import AppOption +from appium.options.common.auto_web_view_option import AutoWebViewOption from appium.options.common.base import AppiumOptions +from appium.options.common.clear_system_files_option import ClearSystemFilesOption +from appium.options.common.device_name_option import DeviceNameOption +from appium.options.common.enable_performance_logging_option import EnablePerformanceLoggingOption +from appium.options.common.is_headless_option import IsHeadlessOption +from appium.options.common.language_option import LanguageOption +from appium.options.common.locale_option import LocaleOption +from appium.options.common.orientation_option import OrientationOption +from appium.options.common.other_apps_option import OtherAppsOption +from appium.options.common.skip_log_capture_option import SkipLogCaptureOption +from appium.options.common.udid_option import UdidOption class XCUITestOptions( AppiumOptions, + AppOption, + ClearSystemFilesOption, + OrientationOption, + UdidOption, + LanguageOption, + LocaleOption, + IsHeadlessOption, + SkipLogCaptureOption, + AutoWebViewOption, + EnablePerformanceLoggingOption, + OtherAppsOption, + DeviceNameOption, ): @property def default_capabilities(self) -> Dict: diff --git a/appium/options/mac/mac2/base.py b/appium/options/mac/mac2/base.py index 7c1ebc700..1ddeefdb7 100644 --- a/appium/options/mac/mac2/base.py +++ b/appium/options/mac/mac2/base.py @@ -18,10 +18,14 @@ from typing import Dict from appium.options.common.base import AppiumOptions +from appium.options.common.postrun_option import PostrunOption +from appium.options.common.prerun_option import PrerunOption class Mac2Options( AppiumOptions, + PrerunOption, + PostrunOption, ): @property def default_capabilities(self) -> Dict: diff --git a/appium/options/windows/windows/base.py b/appium/options/windows/windows/base.py index f1c34aa43..4ba4ff163 100644 --- a/appium/options/windows/windows/base.py +++ b/appium/options/windows/windows/base.py @@ -18,10 +18,14 @@ from typing import Dict from appium.options.common.base import AppiumOptions +from appium.options.common.postrun_option import PostrunOption +from appium.options.common.prerun_option import PrerunOption class WindowsOptions( AppiumOptions, + PrerunOption, + PostrunOption, ): @property def default_capabilities(self) -> Dict: From 2f637d3770852f4658ba8d631864710f5ab25a61 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 15 Jun 2022 21:19:04 +0200 Subject: [PATCH 2/3] Tune constants --- appium/options/android/espresso/base.py | 7 ++++--- appium/options/android/uiautomator2/base.py | 7 ++++--- appium/options/common/app_option.py | 8 ++++---- appium/options/common/auto_web_view_option.py | 8 ++++---- appium/options/common/automation_name_option.py | 8 ++++---- appium/options/common/base.py | 2 +- appium/options/common/clear_system_files_option.py | 8 ++++---- appium/options/common/device_name_option.py | 8 ++++---- .../common/enable_performance_logging_option.py | 8 ++++---- appium/options/common/event_timings_option.py | 8 ++++---- appium/options/common/full_reset_option.py | 8 ++++---- appium/options/common/is_headless_option.py | 8 ++++---- appium/options/common/language_option.py | 8 ++++---- appium/options/common/locale_option.py | 8 ++++---- appium/options/common/new_command_timeout_option.py | 8 ++++---- appium/options/common/no_reset_option.py | 8 ++++---- appium/options/common/orientation_option.py | 8 ++++---- appium/options/common/other_apps_option.py | 8 ++++---- appium/options/common/postrun_option.py | 8 ++++---- appium/options/common/prerun_option.py | 8 ++++---- .../print_page_source_on_find_failure_option.py | 8 ++++---- appium/options/common/skip_log_capture_option.py | 8 ++++---- appium/options/common/udid_option.py | 12 ++++++------ appium/options/gecko/base.py | 3 ++- appium/options/ios/safari/base.py | 3 ++- appium/options/ios/xcuitest/base.py | 7 ++++--- appium/options/mac/mac2/base.py | 7 ++++--- appium/options/windows/windows/base.py | 7 ++++--- 28 files changed, 107 insertions(+), 100 deletions(-) diff --git a/appium/options/android/espresso/base.py b/appium/options/android/espresso/base.py index be24dd982..34ce50c22 100644 --- a/appium/options/android/espresso/base.py +++ b/appium/options/android/espresso/base.py @@ -19,7 +19,8 @@ from appium.options.common.app_option import AppOption from appium.options.common.auto_web_view_option import AutoWebViewOption -from appium.options.common.base import AppiumOptions +from appium.options.common.automation_name_option import AUTOMATION_NAME +from appium.options.common.base import PLATFORM_NAME, AppiumOptions from appium.options.common.device_name_option import DeviceNameOption from appium.options.common.is_headless_option import IsHeadlessOption from appium.options.common.language_option import LanguageOption @@ -44,6 +45,6 @@ class EspressoOptions( @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'Espresso', - AppiumOptions.PLATFORM_NAME: 'Android', + AUTOMATION_NAME: 'Espresso', + PLATFORM_NAME: 'Android', } diff --git a/appium/options/android/uiautomator2/base.py b/appium/options/android/uiautomator2/base.py index d7e4fe501..91727876e 100644 --- a/appium/options/android/uiautomator2/base.py +++ b/appium/options/android/uiautomator2/base.py @@ -19,7 +19,8 @@ from appium.options.common.app_option import AppOption from appium.options.common.auto_web_view_option import AutoWebViewOption -from appium.options.common.base import AppiumOptions +from appium.options.common.automation_name_option import AUTOMATION_NAME +from appium.options.common.base import PLATFORM_NAME, AppiumOptions from appium.options.common.clear_system_files_option import ClearSystemFilesOption from appium.options.common.device_name_option import DeviceNameOption from appium.options.common.enable_performance_logging_option import EnablePerformanceLoggingOption @@ -50,6 +51,6 @@ class UiAutomator2Options( @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'UIAutomator2', - AppiumOptions.PLATFORM_NAME: 'Android', + AUTOMATION_NAME: 'UIAutomator2', + PLATFORM_NAME: 'Android', } diff --git a/appium/options/common/app_option.py b/appium/options/common/app_option.py index 2d76dd674..55fd2abba 100644 --- a/appium/options/common/app_option.py +++ b/appium/options/common/app_option.py @@ -19,16 +19,16 @@ from .supports_capabilities import SupportsCapabilities +APP = 'app' -class AppOption(SupportsCapabilities): - APP = 'app' +class AppOption(SupportsCapabilities): @property def app(self) -> Optional[str]: """ :Returns: String representing app location. """ - return self.get_capability(self.APP) + return self.get_capability(APP) @app.setter def app(self, value: str) -> None: @@ -38,4 +38,4 @@ def app(self, value: str) -> None: server is running. Could also be a valid URL. """ - self.set_capability(self.APP, value) + self.set_capability(APP, value) diff --git a/appium/options/common/auto_web_view_option.py b/appium/options/common/auto_web_view_option.py index 16c977492..3ba7965c6 100644 --- a/appium/options/common/auto_web_view_option.py +++ b/appium/options/common/auto_web_view_option.py @@ -19,17 +19,17 @@ from .supports_capabilities import SupportsCapabilities +AUTO_WEB_VIEW = 'autoWebView' -class AutoWebViewOption(SupportsCapabilities): - AUTO_WEB_VIEW = 'autoWebView' +class AutoWebViewOption(SupportsCapabilities): @property def auto_web_view(self) -> Optional[bool]: """ :Returns: Whether the driver should try to automatically switch to a web view context after the session is started. """ - return self.get_capability(self.AUTO_WEB_VIEW) + return self.get_capability(AUTO_WEB_VIEW) @auto_web_view.setter def auto_web_view(self, value: bool) -> None: @@ -37,4 +37,4 @@ def auto_web_view(self, value: bool) -> None: Set whether the driver should try to automatically switch a web view context after the session is started. """ - self.set_capability(self.AUTO_WEB_VIEW, value) + self.set_capability(AUTO_WEB_VIEW, value) diff --git a/appium/options/common/automation_name_option.py b/appium/options/common/automation_name_option.py index c2004b413..3250b5700 100644 --- a/appium/options/common/automation_name_option.py +++ b/appium/options/common/automation_name_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +AUTOMATION_NAME = 'automationName' -class AutomationNameOption(SupportsCapabilities): - AUTOMATION_NAME = 'automationName' +class AutomationNameOption(SupportsCapabilities): @property def automation_name(self) -> Optional[str]: """ :Returns: String representing the name of the automation engine name. """ - return self.get_capability(self.AUTOMATION_NAME) + return self.get_capability(AUTOMATION_NAME) @automation_name.setter def automation_name(self, value: str) -> None: """ Set the automation driver name to use for the given platform. """ - self.set_capability(self.AUTOMATION_NAME, value) + self.set_capability(AUTOMATION_NAME, value) diff --git a/appium/options/common/base.py b/appium/options/common/base.py index c5869cab8..41d36d06d 100644 --- a/appium/options/common/base.py +++ b/appium/options/common/base.py @@ -29,6 +29,7 @@ APPIUM_PREFIX = 'appium:' T = TypeVar('T', bound='AppiumOptions') +PLATFORM_NAME = 'platformName' class AppiumOptions( @@ -41,7 +42,6 @@ class AppiumOptions( NewCommandTimeoutOption, ): _caps: Dict - PLATFORM_NAME = 'platformName' W3C_CAPABILITY_NAMES = frozenset( [ 'acceptInsecureCerts', diff --git a/appium/options/common/clear_system_files_option.py b/appium/options/common/clear_system_files_option.py index 34a321cb5..9eb6fceaa 100644 --- a/appium/options/common/clear_system_files_option.py +++ b/appium/options/common/clear_system_files_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +CLEAR_SYSTEM_FILES = 'clearSystemFiles' -class ClearSystemFilesOption(SupportsCapabilities): - CLEAR_SYSTEM_FILES = 'clearSystemFiles' +class ClearSystemFilesOption(SupportsCapabilities): @property def clear_system_files(self) -> Optional[bool]: """ :Returns: Whether the driver should delete generated files at the end of a session. """ - return self.get_capability(self.CLEAR_SYSTEM_FILES) + return self.get_capability(CLEAR_SYSTEM_FILES) @clear_system_files.setter def clear_system_files(self, value: bool) -> None: """ Set whether the driver should delete generated files at the end of a session. """ - self.set_capability(self.CLEAR_SYSTEM_FILES, value) + self.set_capability(CLEAR_SYSTEM_FILES, value) diff --git a/appium/options/common/device_name_option.py b/appium/options/common/device_name_option.py index 285949fd0..34d8f989c 100644 --- a/appium/options/common/device_name_option.py +++ b/appium/options/common/device_name_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +DEVICE_NAME = 'deviceName' -class DeviceNameOption(SupportsCapabilities): - DEVICE_NAME = 'deviceName' +class DeviceNameOption(SupportsCapabilities): @property def device_name(self) -> Optional[str]: """ :Returns: The name of the device. """ - return self.get_capability(self.DEVICE_NAME) + return self.get_capability(DEVICE_NAME) @device_name.setter def device_name(self, value: str) -> None: """ Set the name of the device to be used in the test. """ - self.set_capability(self.DEVICE_NAME, value) + self.set_capability(DEVICE_NAME, value) diff --git a/appium/options/common/enable_performance_logging_option.py b/appium/options/common/enable_performance_logging_option.py index 4fa06f320..d6ea1d682 100644 --- a/appium/options/common/enable_performance_logging_option.py +++ b/appium/options/common/enable_performance_logging_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +ENABLE_PERFORMANCE_LOGGING = 'enablePerformanceLogging' -class EnablePerformanceLoggingOption(SupportsCapabilities): - ENABLE_PERFORMANCE_LOGGING = 'enablePerformanceLogging' +class EnablePerformanceLoggingOption(SupportsCapabilities): @property def enable_performance_logging(self) -> Optional[bool]: """ :Returns: Whether to enable additional performance logging. """ - return self.get_capability(self.ENABLE_PERFORMANCE_LOGGING) + return self.get_capability(ENABLE_PERFORMANCE_LOGGING) @enable_performance_logging.setter def enable_performance_logging(self, value: bool) -> None: """ Set whether to enable additional performance logging. """ - self.set_capability(self.ENABLE_PERFORMANCE_LOGGING, value) + self.set_capability(ENABLE_PERFORMANCE_LOGGING, value) diff --git a/appium/options/common/event_timings_option.py b/appium/options/common/event_timings_option.py index 601c20903..d9d8b3e2f 100644 --- a/appium/options/common/event_timings_option.py +++ b/appium/options/common/event_timings_option.py @@ -19,17 +19,17 @@ from .supports_capabilities import SupportsCapabilities +EVENT_TIMINGS = 'eventTimings' -class EventTimingsOption(SupportsCapabilities): - EVENT_TIMINGS = 'eventTimings' +class EventTimingsOption(SupportsCapabilities): @property def event_timings(self) -> Optional[bool]: """ :Returns: Whether the driver should to report the timings for various Appium-internal events. """ - return self.get_capability(self.EVENT_TIMINGS) + return self.get_capability(EVENT_TIMINGS) @event_timings.setter def event_timings(self, value: bool) -> None: @@ -37,4 +37,4 @@ def event_timings(self, value: bool) -> None: Set whether the driver should to report the timings for various Appium-internal events. """ - self.set_capability(self.EVENT_TIMINGS, value) + self.set_capability(EVENT_TIMINGS, value) diff --git a/appium/options/common/full_reset_option.py b/appium/options/common/full_reset_option.py index ea11f6295..fc8f53040 100644 --- a/appium/options/common/full_reset_option.py +++ b/appium/options/common/full_reset_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +FULL_RESET = 'fullReset' -class FullResetOption(SupportsCapabilities): - FULL_RESET = 'fullReset' +class FullResetOption(SupportsCapabilities): @property def full_reset(self) -> Optional[bool]: """ :Returns: Whether the driver should perform a full reset. """ - return self.get_capability(self.FULL_RESET) + return self.get_capability(FULL_RESET) @full_reset.setter def full_reset(self, value: bool) -> None: """ Set whether the driver should perform a full reset. """ - self.set_capability(self.FULL_RESET, value) + self.set_capability(FULL_RESET, value) diff --git a/appium/options/common/is_headless_option.py b/appium/options/common/is_headless_option.py index 95409c8e0..3ab3fc98f 100644 --- a/appium/options/common/is_headless_option.py +++ b/appium/options/common/is_headless_option.py @@ -19,16 +19,16 @@ from .supports_capabilities import SupportsCapabilities +IS_HEADLESS = 'isHeadless' -class IsHeadlessOption(SupportsCapabilities): - IS_HEADLESS = 'isHeadless' +class IsHeadlessOption(SupportsCapabilities): @property def is_headless(self) -> Optional[bool]: """ :Returns: Whether the driver should start emulator/simulator in headless mode. """ - return self.get_capability(self.IS_HEADLESS) + return self.get_capability(IS_HEADLESS) @is_headless.setter def is_headless(self, value: bool) -> None: @@ -36,4 +36,4 @@ def is_headless(self, value: bool) -> None: Set emulator/simulator to start in headless mode (e.g. no UI is shown). It is only applied if the emulator is not running before the test starts. """ - self.set_capability(self.IS_HEADLESS, value) + self.set_capability(IS_HEADLESS, value) diff --git a/appium/options/common/language_option.py b/appium/options/common/language_option.py index 7c3cd492a..c12ebd37b 100644 --- a/appium/options/common/language_option.py +++ b/appium/options/common/language_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +LANGUAGE = 'language' -class LanguageOption(SupportsCapabilities): - LANGUAGE = 'language' +class LanguageOption(SupportsCapabilities): @property def language(self) -> Optional[str]: """ :Returns: Language abbreviation to use in a test session. """ - return self.get_capability(self.LANGUAGE) + return self.get_capability(LANGUAGE) @language.setter def language(self, value: str) -> None: """ Set language abbreviation to use in a test session. """ - self.set_capability(self.LANGUAGE, value) + self.set_capability(LANGUAGE, value) diff --git a/appium/options/common/locale_option.py b/appium/options/common/locale_option.py index 05ccff6a2..2c9d24e38 100644 --- a/appium/options/common/locale_option.py +++ b/appium/options/common/locale_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +LOCALE = 'locale' -class LocaleOption(SupportsCapabilities): - LOCALE = 'locale' +class LocaleOption(SupportsCapabilities): @property def locale(self) -> Optional[str]: """ :Returns: Locale abbreviation to use in a test session. """ - return self.get_capability(self.LOCALE) + return self.get_capability(LOCALE) @locale.setter def locale(self, value: str) -> None: """ Set locale abbreviation to use in a test session. """ - self.set_capability(self.LOCALE, value) + self.set_capability(LOCALE, value) diff --git a/appium/options/common/new_command_timeout_option.py b/appium/options/common/new_command_timeout_option.py index f9f572826..a91f2ee53 100644 --- a/appium/options/common/new_command_timeout_option.py +++ b/appium/options/common/new_command_timeout_option.py @@ -20,16 +20,16 @@ from .supports_capabilities import SupportsCapabilities +NEW_COMMAND_TIMEOUT = 'newCommandTimeout' -class NewCommandTimeoutOption(SupportsCapabilities): - NEW_COMMAND_TIMEOUT = 'newCommandTimeout' +class NewCommandTimeoutOption(SupportsCapabilities): @property def new_command_timeout(self) -> Optional[timedelta]: """ :Returns: The allowed time before seeing a new server command. """ - value = self.get_capability(self.NEW_COMMAND_TIMEOUT) + value = self.get_capability(NEW_COMMAND_TIMEOUT) return None if value is None else timedelta(seconds=value) @new_command_timeout.setter @@ -38,4 +38,4 @@ def new_command_timeout(self, value: Union[timedelta, int]) -> None: Set the allowed time before seeing a new server command. The value could either be provided as timedelta instance or an integer number of seconds. """ - self.set_capability(self.NEW_COMMAND_TIMEOUT, value.seconds if isinstance(value, timedelta) else value) + self.set_capability(NEW_COMMAND_TIMEOUT, value.seconds if isinstance(value, timedelta) else value) diff --git a/appium/options/common/no_reset_option.py b/appium/options/common/no_reset_option.py index f5692fc46..01ca5e7b5 100644 --- a/appium/options/common/no_reset_option.py +++ b/appium/options/common/no_reset_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +NO_RESET = 'noReset' -class NoResetOption(SupportsCapabilities): - NO_RESET = 'noReset' +class NoResetOption(SupportsCapabilities): @property def full_reset(self) -> Optional[bool]: """ :Returns: Whether the driver should not perform a reset. """ - return self.get_capability(self.NO_RESET) + return self.get_capability(NO_RESET) @full_reset.setter def full_reset(self, value: bool) -> None: """ Set whether the driver should not perform a reset. """ - self.set_capability(self.NO_RESET, value) + self.set_capability(NO_RESET, value) diff --git a/appium/options/common/orientation_option.py b/appium/options/common/orientation_option.py index d111c15c2..6060fe8a5 100644 --- a/appium/options/common/orientation_option.py +++ b/appium/options/common/orientation_option.py @@ -19,17 +19,17 @@ from .supports_capabilities import SupportsCapabilities +ORIENTATION = 'orientation' -class OrientationOption(SupportsCapabilities): - ORIENTATION = 'orientation' +class OrientationOption(SupportsCapabilities): @property def orientation(self) -> Optional[str]: """ :Returns: The orientation of the device's screen. Usually this is either 'PORTRAIT' or 'LANDSCAPE'. """ - return self.get_capability(self.ORIENTATION) + return self.get_capability(ORIENTATION) @orientation.setter def orientation(self, value: str) -> None: @@ -37,4 +37,4 @@ def orientation(self, value: str) -> None: Set the orientation of the device's screen. Usually this is either 'PORTRAIT' or 'LANDSCAPE'. """ - self.set_capability(self.ORIENTATION, value) + self.set_capability(ORIENTATION, value) diff --git a/appium/options/common/other_apps_option.py b/appium/options/common/other_apps_option.py index 7fc755087..1751968de 100644 --- a/appium/options/common/other_apps_option.py +++ b/appium/options/common/other_apps_option.py @@ -19,16 +19,16 @@ from .supports_capabilities import SupportsCapabilities +OTHER_APPS = 'otherApps' -class OtherAppsOption(SupportsCapabilities): - OTHER_APPS = 'otherApps' +class OtherAppsOption(SupportsCapabilities): @property def other_apps(self) -> Optional[str]: """ :Returns: Locations of apps to install before running a test. """ - return self.get_capability(self.OTHER_APPS) + return self.get_capability(OTHER_APPS) @other_apps.setter def other_apps(self, value: str) -> None: @@ -36,4 +36,4 @@ def other_apps(self, value: str) -> None: Set locations of apps to install before running a test. Each item could be separated with a single comma. """ - self.set_capability(self.OTHER_APPS, value) + self.set_capability(OTHER_APPS, value) diff --git a/appium/options/common/postrun_option.py b/appium/options/common/postrun_option.py index beea91e5c..c7c52f479 100644 --- a/appium/options/common/postrun_option.py +++ b/appium/options/common/postrun_option.py @@ -19,14 +19,14 @@ from .supports_capabilities import SupportsCapabilities +POSTRUN = 'postrun' -class PostrunOption(SupportsCapabilities): - POSTRUN = 'postrun' +class PostrunOption(SupportsCapabilities): @property def postrun(self) -> Optional[str]: - return self.get_capability(self.POSTRUN) + return self.get_capability(POSTRUN) @postrun.setter def postrun(self, value: str) -> None: - self.set_capability(self.POSTRUN, value) + self.set_capability(POSTRUN, value) diff --git a/appium/options/common/prerun_option.py b/appium/options/common/prerun_option.py index 3b2569a38..f81ba2c6e 100644 --- a/appium/options/common/prerun_option.py +++ b/appium/options/common/prerun_option.py @@ -19,14 +19,14 @@ from .supports_capabilities import SupportsCapabilities +PRERUN = 'prerun' -class PrerunOption(SupportsCapabilities): - PRERUN = 'prerun' +class PrerunOption(SupportsCapabilities): @property def prerun(self) -> Optional[str]: - return self.get_capability(self.PRERUN) + return self.get_capability(PRERUN) @prerun.setter def prerun(self, value: str) -> None: - self.set_capability(self.PRERUN, value) + self.set_capability(PRERUN, value) diff --git a/appium/options/common/print_page_source_on_find_failure_option.py b/appium/options/common/print_page_source_on_find_failure_option.py index c67fcae55..935bc2769 100644 --- a/appium/options/common/print_page_source_on_find_failure_option.py +++ b/appium/options/common/print_page_source_on_find_failure_option.py @@ -19,17 +19,17 @@ from .supports_capabilities import SupportsCapabilities +PRINT_PAGE_SOURCE_ON_FIND_FAILURE = 'printPageSourceOnFindFailure' -class PrintPageSourceOnFindFailureOption(SupportsCapabilities): - PRINT_PAGE_SOURCE_ON_FIND_FAILURE = 'printPageSourceOnFindFailure' +class PrintPageSourceOnFindFailureOption(SupportsCapabilities): @property def print_page_source_on_find_failure(self) -> Optional[bool]: """ :Returns: Whether the driver should print the page source to the log if a find failure occurs. """ - return self.get_capability(self.PRINT_PAGE_SOURCE_ON_FIND_FAILURE) + return self.get_capability(PRINT_PAGE_SOURCE_ON_FIND_FAILURE) @print_page_source_on_find_failure.setter def print_page_source_on_find_failure(self, value: bool) -> None: @@ -37,4 +37,4 @@ def print_page_source_on_find_failure(self, value: bool) -> None: Set whether the driver should print the page source to the log if a find failure occurs. """ - self.set_capability(self.PRINT_PAGE_SOURCE_ON_FIND_FAILURE, value) + self.set_capability(PRINT_PAGE_SOURCE_ON_FIND_FAILURE, value) diff --git a/appium/options/common/skip_log_capture_option.py b/appium/options/common/skip_log_capture_option.py index e195f3ace..0489df775 100644 --- a/appium/options/common/skip_log_capture_option.py +++ b/appium/options/common/skip_log_capture_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +SKIP_LOG_CAPTURE = 'skipLogCapture' -class SkipLogCaptureOption(SupportsCapabilities): - SKIP_LOG_CAPTURE = 'skipLogCapture' +class SkipLogCaptureOption(SupportsCapabilities): @property def skip_log_capture(self) -> Optional[bool]: """ :Returns: Whether the driver should not record device logs. """ - return self.get_capability(self.SKIP_LOG_CAPTURE) + return self.get_capability(SKIP_LOG_CAPTURE) @skip_log_capture.setter def skip_log_capture(self, value: bool) -> None: """ Set whether the driver should not record device logs. """ - self.set_capability(self.SKIP_LOG_CAPTURE, value) + self.set_capability(SKIP_LOG_CAPTURE, value) diff --git a/appium/options/common/udid_option.py b/appium/options/common/udid_option.py index a1023702d..1e73b58cb 100644 --- a/appium/options/common/udid_option.py +++ b/appium/options/common/udid_option.py @@ -19,20 +19,20 @@ from .supports_capabilities import SupportsCapabilities +UDID = 'udid' -class UdidOption(SupportsCapabilities): - UDID = 'udid' +class UdidOption(SupportsCapabilities): @property def udid(self) -> Optional[str]: """ - :Returns: The id of the device under test. + :Returns: The unique identifier of the device under test. """ - return self.get_capability(self.UDID) + return self.get_capability(UDID) @udid.setter def udid(self, value: str) -> None: """ - Set the id of the device under test. + Set the unique identifier of the device under test. """ - self.set_capability(self.UDID, value) + self.set_capability(UDID, value) diff --git a/appium/options/gecko/base.py b/appium/options/gecko/base.py index 483314167..d11b2511c 100644 --- a/appium/options/gecko/base.py +++ b/appium/options/gecko/base.py @@ -17,6 +17,7 @@ from typing import Dict +from appium.options.common.automation_name_option import AUTOMATION_NAME from appium.options.common.base import AppiumOptions @@ -26,5 +27,5 @@ class GeckoOptions( @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'Gecko', + AUTOMATION_NAME: 'Gecko', } diff --git a/appium/options/ios/safari/base.py b/appium/options/ios/safari/base.py index bbee54a0e..80db4328b 100644 --- a/appium/options/ios/safari/base.py +++ b/appium/options/ios/safari/base.py @@ -17,6 +17,7 @@ from typing import Dict +from appium.options.common.automation_name_option import AUTOMATION_NAME from appium.options.common.base import AppiumOptions @@ -27,5 +28,5 @@ class SafariOptions( def default_capabilities(self) -> Dict: return { AppiumOptions.PLATFORM_NAME: 'iOS', - AppiumOptions.AUTOMATION_NAME: 'Safari', + AUTOMATION_NAME: 'Safari', } diff --git a/appium/options/ios/xcuitest/base.py b/appium/options/ios/xcuitest/base.py index 5b9a1eb2d..12f609d86 100644 --- a/appium/options/ios/xcuitest/base.py +++ b/appium/options/ios/xcuitest/base.py @@ -19,7 +19,8 @@ from appium.options.common.app_option import AppOption from appium.options.common.auto_web_view_option import AutoWebViewOption -from appium.options.common.base import AppiumOptions +from appium.options.common.automation_name_option import AUTOMATION_NAME +from appium.options.common.base import PLATFORM_NAME, AppiumOptions from appium.options.common.clear_system_files_option import ClearSystemFilesOption from appium.options.common.device_name_option import DeviceNameOption from appium.options.common.enable_performance_logging_option import EnablePerformanceLoggingOption @@ -50,6 +51,6 @@ class XCUITestOptions( @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'XCUITest', - AppiumOptions.PLATFORM_NAME: 'iOS', + AUTOMATION_NAME: 'XCUITest', + PLATFORM_NAME: 'iOS', } diff --git a/appium/options/mac/mac2/base.py b/appium/options/mac/mac2/base.py index 1ddeefdb7..fc37cdddc 100644 --- a/appium/options/mac/mac2/base.py +++ b/appium/options/mac/mac2/base.py @@ -17,7 +17,8 @@ from typing import Dict -from appium.options.common.base import AppiumOptions +from appium.options.common.automation_name_option import AUTOMATION_NAME +from appium.options.common.base import PLATFORM_NAME, AppiumOptions from appium.options.common.postrun_option import PostrunOption from appium.options.common.prerun_option import PrerunOption @@ -30,6 +31,6 @@ class Mac2Options( @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'Mac2', - AppiumOptions.PLATFORM_NAME: 'Mac', + AUTOMATION_NAME: 'Mac2', + PLATFORM_NAME: 'Mac', } diff --git a/appium/options/windows/windows/base.py b/appium/options/windows/windows/base.py index 4ba4ff163..a1f4b2f7a 100644 --- a/appium/options/windows/windows/base.py +++ b/appium/options/windows/windows/base.py @@ -17,7 +17,8 @@ from typing import Dict -from appium.options.common.base import AppiumOptions +from appium.options.common.automation_name_option import AUTOMATION_NAME +from appium.options.common.base import PLATFORM_NAME, AppiumOptions from appium.options.common.postrun_option import PostrunOption from appium.options.common.prerun_option import PrerunOption @@ -30,6 +31,6 @@ class WindowsOptions( @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'Windows', - AppiumOptions.PLATFORM_NAME: 'Windows', + AUTOMATION_NAME: 'Windows', + PLATFORM_NAME: 'Windows', } From 371a003c050cba8a3b5799482ada422f17e12056 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 15 Jun 2022 21:27:41 +0200 Subject: [PATCH 3/3] Add docs --- appium/options/common/postrun_option.py | 7 +++++++ appium/options/common/prerun_option.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/appium/options/common/postrun_option.py b/appium/options/common/postrun_option.py index c7c52f479..076c222a7 100644 --- a/appium/options/common/postrun_option.py +++ b/appium/options/common/postrun_option.py @@ -25,8 +25,15 @@ class PostrunOption(SupportsCapabilities): @property def postrun(self) -> Optional[str]: + """ + :return: System script which is supposed to be executed upon + driver session quit. + """ return self.get_capability(POSTRUN) @postrun.setter def postrun(self, value: str) -> None: + """ + Set a system script to execute upon driver session quit. + """ self.set_capability(POSTRUN, value) diff --git a/appium/options/common/prerun_option.py b/appium/options/common/prerun_option.py index f81ba2c6e..8f703cbb8 100644 --- a/appium/options/common/prerun_option.py +++ b/appium/options/common/prerun_option.py @@ -25,8 +25,16 @@ class PrerunOption(SupportsCapabilities): @property def prerun(self) -> Optional[str]: + """ + :return: System script which is supposed to be executed before + a driver session is initialised. + """ return self.get_capability(PRERUN) @prerun.setter def prerun(self, value: str) -> None: + """ + Set a system script which is supposed to be executed before + a driver session is initialised. + """ self.set_capability(PRERUN, value)