diff --git a/appium/options/android/espresso/base.py b/appium/options/android/espresso/base.py index b38640c38..34ce50c22 100644 --- a/appium/options/android/espresso/base.py +++ b/appium/options/android/espresso/base.py @@ -17,15 +17,34 @@ from typing import Dict -from appium.options.common.base import AppiumOptions +from appium.options.common.app_option import AppOption +from appium.options.common.auto_web_view_option import AutoWebViewOption +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 +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: 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 d067d78f1..91727876e 100644 --- a/appium/options/android/uiautomator2/base.py +++ b/appium/options/android/uiautomator2/base.py @@ -17,15 +17,40 @@ from typing import Dict -from appium.options.common.base import AppiumOptions +from appium.options.common.app_option import AppOption +from appium.options.common.auto_web_view_option import AutoWebViewOption +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 +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: 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 new file mode 100644 index 000000000..55fd2abba --- /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 + +APP = 'app' + + +class AppOption(SupportsCapabilities): + @property + def app(self) -> Optional[str]: + """ + :Returns: String representing app location. + """ + return self.get_capability(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(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..3ba7965c6 --- /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 + +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(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(AUTO_WEB_VIEW, value) diff --git a/appium/options/common/automation_name_option.py b/appium/options/common/automation_name_option.py index b52250608..3250b5700 100644 --- a/appium/options/common/automation_name_option.py +++ b/appium/options/common/automation_name_option.py @@ -19,24 +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 + :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 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) + self.set_capability(AUTOMATION_NAME, value) diff --git a/appium/options/common/base.py b/appium/options/common/base.py index f7245d257..41d36d06d 100644 --- a/appium/options/common/base.py +++ b/appium/options/common/base.py @@ -21,17 +21,27 @@ 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') +PLATFORM_NAME = 'platformName' class AppiumOptions( BaseOptions, AutomationNameOption, + EventTimingsOption, + PrintPageSourceOnFindFailureOption, + NoResetOption, + FullResetOption, + 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 new file mode 100644 index 000000000..9eb6fceaa --- /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 + +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(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(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..34d8f989c --- /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 + +DEVICE_NAME = 'deviceName' + + +class DeviceNameOption(SupportsCapabilities): + @property + def device_name(self) -> Optional[str]: + """ + :Returns: The name of the device. + """ + 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(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..d6ea1d682 --- /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 + +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(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(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..d9d8b3e2f --- /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 + +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(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(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..fc8f53040 --- /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 + +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(FULL_RESET) + + @full_reset.setter + def full_reset(self, value: bool) -> None: + """ + Set whether the driver should perform a full reset. + """ + self.set_capability(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..3ab3fc98f --- /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 + +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(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(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..c12ebd37b --- /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 + +LANGUAGE = 'language' + + +class LanguageOption(SupportsCapabilities): + @property + def language(self) -> Optional[str]: + """ + :Returns: Language abbreviation to use in a test session. + """ + 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(LANGUAGE, value) diff --git a/appium/options/common/locale_option.py b/appium/options/common/locale_option.py new file mode 100644 index 000000000..2c9d24e38 --- /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 + +LOCALE = 'locale' + + +class LocaleOption(SupportsCapabilities): + @property + def locale(self) -> Optional[str]: + """ + :Returns: Locale abbreviation to use in a test session. + """ + 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(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..a91f2ee53 --- /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 + +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(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(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..01ca5e7b5 --- /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 + +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(NO_RESET) + + @full_reset.setter + def full_reset(self, value: bool) -> None: + """ + Set whether the driver should not perform a reset. + """ + self.set_capability(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..6060fe8a5 --- /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 + +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(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(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..1751968de --- /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 + +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(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(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..076c222a7 --- /dev/null +++ b/appium/options/common/postrun_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 + +POSTRUN = 'postrun' + + +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 new file mode 100644 index 000000000..8f703cbb8 --- /dev/null +++ b/appium/options/common/prerun_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 + +PRERUN = 'prerun' + + +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) 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..935bc2769 --- /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 + +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(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(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..0489df775 --- /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 + +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(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(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..1e73b58cb --- /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 + +UDID = 'udid' + + +class UdidOption(SupportsCapabilities): + @property + def udid(self) -> Optional[str]: + """ + :Returns: The unique identifier of the device under test. + """ + return self.get_capability(UDID) + + @udid.setter + def udid(self, value: str) -> None: + """ + Set the unique identifier of the device under test. + """ + 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 9718dfec3..12f609d86 100644 --- a/appium/options/ios/xcuitest/base.py +++ b/appium/options/ios/xcuitest/base.py @@ -17,15 +17,40 @@ from typing import Dict -from appium.options.common.base import AppiumOptions +from appium.options.common.app_option import AppOption +from appium.options.common.auto_web_view_option import AutoWebViewOption +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 +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: 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 7c1ebc700..fc37cdddc 100644 --- a/appium/options/mac/mac2/base.py +++ b/appium/options/mac/mac2/base.py @@ -17,15 +17,20 @@ 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 class Mac2Options( AppiumOptions, + PrerunOption, + PostrunOption, ): @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 f1c34aa43..a1f4b2f7a 100644 --- a/appium/options/windows/windows/base.py +++ b/appium/options/windows/windows/base.py @@ -17,15 +17,20 @@ 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 class WindowsOptions( AppiumOptions, + PrerunOption, + PostrunOption, ): @property def default_capabilities(self) -> Dict: return { - AppiumOptions.AUTOMATION_NAME: 'Windows', - AppiumOptions.PLATFORM_NAME: 'Windows', + AUTOMATION_NAME: 'Windows', + PLATFORM_NAME: 'Windows', }