diff --git a/appium/options/ios/safari/automatic_inspection_option.py b/appium/options/ios/safari/automatic_inspection_option.py new file mode 100644 index 000000000..ef95aa7b2 --- /dev/null +++ b/appium/options/ios/safari/automatic_inspection_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 appium.options.common.supports_capabilities import SupportsCapabilities + +AUTOMATIC_INSPECTION = 'safari:automaticInspection' + + +class AutomaticInspectionOption(SupportsCapabilities): + @property + def automatic_inspection(self) -> Optional[bool]: + """ + :Returns: Whether to use automatic inspection. + """ + return self.get_capability(AUTOMATIC_INSPECTION) + + @automatic_inspection.setter + def automatic_inspection(self, value: bool) -> None: + """ + This capability instructs Safari to preload the Web Inspector and JavaScript + debugger in the background prior to returning a newly-created window. + To pause the test's execution in JavaScript and bring up Web Inspector's + Debugger tab, you can simply evaluate a debugger statement in the test page. + """ + self.set_capability(AUTOMATIC_INSPECTION, value) diff --git a/appium/options/ios/safari/automatic_profiling_option.py b/appium/options/ios/safari/automatic_profiling_option.py new file mode 100644 index 000000000..e45089d99 --- /dev/null +++ b/appium/options/ios/safari/automatic_profiling_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 appium.options.common.supports_capabilities import SupportsCapabilities + +AUTOMATIC_PROFILING = 'safari:automaticProfiling' + + +class AutomaticProfilingOption(SupportsCapabilities): + @property + def automatic_profiling(self) -> Optional[bool]: + """ + :Returns: Whether to use automatic profiling. + """ + return self.get_capability(AUTOMATIC_PROFILING) + + @automatic_profiling.setter + def automatic_profiling(self, value: bool) -> None: + """ + This capability instructs Safari to preload the Web Inspector and start + a Timeline recording in the background prior to returning a newly-created + window. To view the recording, open the Web Inspector through Safari's + Develop menu. + """ + self.set_capability(AUTOMATIC_PROFILING, value) diff --git a/appium/options/ios/safari/base.py b/appium/options/ios/safari/base.py index 80db4328b..8c6cfa685 100644 --- a/appium/options/ios/safari/base.py +++ b/appium/options/ios/safari/base.py @@ -18,15 +18,34 @@ from typing import Dict from appium.options.common.automation_name_option import AUTOMATION_NAME -from appium.options.common.base import AppiumOptions +from appium.options.common.base import PLATFORM_NAME, AppiumOptions + +from .automatic_inspection_option import AutomaticInspectionOption +from .automatic_profiling_option import AutomaticProfilingOption +from .device_name_option import DeviceNameOption +from .device_type_option import DeviceTypeOption +from .device_udid_option import DeviceUdidOption +from .platform_build_version_option import PlatformBuildVersionOption +from .platform_version_option import PlatformVersionOption +from .use_simulator_option import UseSimulatorOption +from .webkit_webrtc_option import WebkitWebrtcOption class SafariOptions( AppiumOptions, + AutomaticInspectionOption, + AutomaticProfilingOption, + DeviceNameOption, + DeviceTypeOption, + DeviceUdidOption, + PlatformBuildVersionOption, + PlatformVersionOption, + UseSimulatorOption, + WebkitWebrtcOption, ): @property def default_capabilities(self) -> Dict: return { - AppiumOptions.PLATFORM_NAME: 'iOS', + PLATFORM_NAME: 'iOS', AUTOMATION_NAME: 'Safari', } diff --git a/appium/options/ios/safari/device_name_option.py b/appium/options/ios/safari/device_name_option.py new file mode 100644 index 000000000..b7697ed25 --- /dev/null +++ b/appium/options/ios/safari/device_name_option.py @@ -0,0 +1,43 @@ +# 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 appium.options.common.supports_capabilities import SupportsCapabilities + +DEVICE_NAME = 'safari:deviceName' + + +class DeviceNameOption(SupportsCapabilities): + @property + def device_name(self) -> Optional[str]: + """ + :Returns: String representing the name of the device. + """ + return self.get_capability(DEVICE_NAME) + + @device_name.setter + def device_name(self, value: str) -> None: + """ + safaridriver will only create a session using hosts whose device name + matches the value of safari:deviceName. Device names are compared + case-insensitively. NOTE: Device names for connected devices are shown in + iTunes. If Xcode is installed, device names for connected devices are available + via the output of instruments(1) and in the Devices and Simulators window + (accessed in Xcode via "Window -> Devices and Simulators"). + """ + self.set_capability(DEVICE_NAME, value) diff --git a/appium/options/ios/safari/device_type_option.py b/appium/options/ios/safari/device_type_option.py new file mode 100644 index 000000000..d7951513e --- /dev/null +++ b/appium/options/ios/safari/device_type_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 appium.options.common.supports_capabilities import SupportsCapabilities + +DEVICE_TYPE = 'safari:deviceType' + + +class DeviceTypeOption(SupportsCapabilities): + @property + def device_type(self) -> Optional[str]: + """ + :Returns: String representing the type of the device. + """ + return self.get_capability(DEVICE_TYPE) + + @device_type.setter + def device_type(self, value: str) -> None: + """ + If the value of safari:deviceType is 'iPhone', safaridriver will only create a session + using an iPhone device or iPhone simulator. If the value of safari:deviceType is 'iPad', + safaridriver will only create a session using an iPad device or iPad simulator. + Values of safari:deviceType are compared case-insensitively. + """ + self.set_capability(DEVICE_TYPE, value) diff --git a/appium/options/ios/safari/device_udid_option.py b/appium/options/ios/safari/device_udid_option.py new file mode 100644 index 000000000..7ef435fd2 --- /dev/null +++ b/appium/options/ios/safari/device_udid_option.py @@ -0,0 +1,43 @@ +# 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 appium.options.common.supports_capabilities import SupportsCapabilities + +DEVICE_UDID = 'safari:deviceUDID' + + +class DeviceUdidOption(SupportsCapabilities): + @property + def device_udid(self) -> Optional[str]: + """ + :Returns: String representing the UDID of the device. + """ + return self.get_capability(DEVICE_UDID) + + @device_udid.setter + def device_udid(self, value: str) -> None: + """ + safaridriver will only create a session using hosts whose device UDID + matches the value of safari:deviceUDID. Device UDIDs are compared + case-insensitively. NOTE: If Xcode is installed, UDIDs for connected + devices are available via the output of instruments(1) and in the + Devices and Simulators window (accessed in Xcode via + "Window -> Devices and Simulators"). + """ + self.set_capability(DEVICE_UDID, value) diff --git a/appium/options/ios/safari/platform_build_version_option.py b/appium/options/ios/safari/platform_build_version_option.py new file mode 100644 index 000000000..4f6497c70 --- /dev/null +++ b/appium/options/ios/safari/platform_build_version_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 appium.options.common.supports_capabilities import SupportsCapabilities + +PLATFORM_BUILD_VERSION = 'safari:platformBuildVersion' + + +class PlatformBuildVersionOption(SupportsCapabilities): + @property + def platform_build_version(self) -> Optional[str]: + """ + :Returns: String representing the platform build version. + """ + return self.get_capability(PLATFORM_BUILD_VERSION) + + @platform_build_version.setter + def platform_build_version(self, value: str) -> None: + """ + safaridriver will only create a session using hosts whose OS build + version matches the value of safari:platformBuildVersion. Example + of a macOS build version is '18E193'. On macOS, the OS build version + can be determined by running the sw_vers(1) utility. + """ + self.set_capability(PLATFORM_BUILD_VERSION, value) diff --git a/appium/options/ios/safari/platform_version_option.py b/appium/options/ios/safari/platform_version_option.py new file mode 100644 index 000000000..d6a91fb79 --- /dev/null +++ b/appium/options/ios/safari/platform_version_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 appium.options.common.supports_capabilities import SupportsCapabilities + +PLATFORM_VERSION = 'safari:platformVersion' + + +class PlatformVersionOption(SupportsCapabilities): + @property + def platform_version(self) -> Optional[str]: + """ + :Returns: String representing the platform version. + """ + return self.get_capability(PLATFORM_VERSION) + + @platform_version.setter + def platform_version(self, value: str) -> None: + """ + safaridriver will only create a session using hosts whose OS + version matches the value of safari:platformVersion. OS version + numbers are prefix-matched. For example, if the value of safari:platformVersion + is '12', this will allow hosts with an OS version of '12.0' or '12.1' but not '10.12'. + """ + self.set_capability(PLATFORM_VERSION, value) diff --git a/appium/options/ios/safari/use_simulator_option.py b/appium/options/ios/safari/use_simulator_option.py new file mode 100644 index 000000000..8ac641d33 --- /dev/null +++ b/appium/options/ios/safari/use_simulator_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 appium.options.common.supports_capabilities import SupportsCapabilities + +USE_SIMULATOR = 'safari:useSimulator' + + +class UseSimulatorOption(SupportsCapabilities): + @property + def use_simulator(self) -> Optional[bool]: + """ + :Returns: Whether to use iOS Simulator. + """ + return self.get_capability(USE_SIMULATOR) + + @use_simulator.setter + def use_simulator(self, value: bool) -> None: + """ + If the value of safari:useSimulator is true, safaridriver will only use + iOS Simulator hosts. If the value of safari:useSimulator is false, safaridriver + will not use iOS Simulator hosts. NOTE: An Xcode installation is required + in order to run WebDriver tests on iOS Simulator hosts. + """ + self.set_capability(USE_SIMULATOR, value) diff --git a/appium/options/ios/safari/webkit_webrtc_option.py b/appium/options/ios/safari/webkit_webrtc_option.py new file mode 100644 index 000000000..0890b6545 --- /dev/null +++ b/appium/options/ios/safari/webkit_webrtc_option.py @@ -0,0 +1,52 @@ +# 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 Any, Dict, Optional + +from appium.options.common.supports_capabilities import SupportsCapabilities + +WEBKIT_WEBRTC = 'webkit:WebRTC' + + +class WebkitWebrtcOption(SupportsCapabilities): + @property + def webkit_webrtc(self) -> Optional[Dict[str, Any]]: + """ + :Returns: WebRTC policies. + """ + return self.get_capability(WEBKIT_WEBRTC) + + @webkit_webrtc.setter + def webkit_webrtc(self, value: Dict[str, Any]) -> None: + """ + This option allows a test to temporarily change Safari's policies + for WebRTC and Media Capture. + The following dictionary values are supported: + - DisableInsecureMediaCapture: Boolean value. + Normally, Safari refuses to allow media capture over insecure connections. + This restriction is relaxed by default for WebDriver sessions for testing + purposes (for example, a test web server not configured for HTTPS). When + this capability is specified, Safari will revert to the normal behavior of + preventing media capture over insecure connections. + - DisableICECandidateFiltering: Boolean value. + To protect a user's privacy, Safari normally filters out WebRTC + ICE candidates that correspond to internal network addresses when + capture devices are not in use. This capability suppresses ICE candidate + filtering so that both internal and external network addresses are + always sent as ICE candidates. + """ + self.set_capability(WEBKIT_WEBRTC, value)