Skip to content

Commit d93a6ca

Browse files
feat: Add missing platformVersion and browserName options (#925)
1 parent 6f1cf34 commit d93a6ca

File tree

6 files changed

+87
-1
lines changed

6 files changed

+87
-1
lines changed

appium/options/android/espresso/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
from appium.options.common.locale_option import LocaleOption
109109
from appium.options.common.orientation_option import OrientationOption
110110
from appium.options.common.other_apps_option import OtherAppsOption
111+
from appium.options.common.platform_version_option import PlatformVersionOption
111112
from appium.options.common.skip_log_capture_option import SkipLogCaptureOption
112113
from appium.options.common.system_port_option import SystemPortOption
113114
from appium.options.common.udid_option import UdidOption
@@ -154,6 +155,7 @@ class EspressoOptions(
154155
EnforceAppInstallOption,
155156
LocaleScriptOption,
156157
AdbPortOption,
158+
PlatformVersionOption,
157159
RemoteAdbHostOption,
158160
AdbExecTimeoutOption,
159161
ClearDeviceLogsOnStartOption,

appium/options/android/uiautomator2/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
from appium.options.common.locale_option import LocaleOption
109109
from appium.options.common.orientation_option import OrientationOption
110110
from appium.options.common.other_apps_option import OtherAppsOption
111+
from appium.options.common.platform_version_option import PlatformVersionOption
111112
from appium.options.common.skip_log_capture_option import SkipLogCaptureOption
112113
from appium.options.common.system_port_option import SystemPortOption
113114
from appium.options.common.udid_option import UdidOption
@@ -144,6 +145,7 @@ class UiAutomator2Options(
144145
SkipDeviceInitializationOption,
145146
AppPackageOption,
146147
AppActivityOption,
148+
PlatformVersionOption,
147149
AppWaitActivityOption,
148150
AppWaitPackageOption,
149151
AppWaitDurationOption,

appium/options/common/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from selenium.webdriver.common.options import BaseOptions
2222

2323
from .automation_name_option import AutomationNameOption
24+
from .browser_name_option import BROWSER_NAME, BrowserNameOption
2425
from .event_timings_option import EventTimingsOption
2526
from .full_reset_option import FullResetOption
2627
from .new_command_timeout_option import NewCommandTimeoutOption
@@ -34,6 +35,7 @@
3435

3536
class AppiumOptions(
3637
BaseOptions,
38+
BrowserNameOption,
3739
AutomationNameOption,
3840
EventTimingsOption,
3941
PrintPageSourceOnFindFailureOption,
@@ -45,7 +47,7 @@ class AppiumOptions(
4547
W3C_CAPABILITY_NAMES = frozenset(
4648
[
4749
'acceptInsecureCerts',
48-
'browserName',
50+
BROWSER_NAME,
4951
'browserVersion',
5052
PLATFORM_NAME,
5153
'pageLoadStrategy',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from .supports_capabilities import SupportsCapabilities
21+
22+
BROWSER_NAME = 'browserName'
23+
24+
25+
class BrowserNameOption(SupportsCapabilities):
26+
@property
27+
def browser_name(self) -> Optional[str]:
28+
"""
29+
The name of the browser to run the test on.
30+
"""
31+
return self.get_capability(BROWSER_NAME)
32+
33+
@browser_name.setter
34+
def browser_name(self, value: str) -> None:
35+
"""
36+
Set the name of the browser to run the test on.
37+
"""
38+
self.set_capability(BROWSER_NAME, value)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from .supports_capabilities import SupportsCapabilities
21+
22+
PLATFORM_VERSION = 'platformVersion'
23+
24+
25+
class PlatformVersionOption(SupportsCapabilities):
26+
@property
27+
def platform_version(self) -> Optional[str]:
28+
"""
29+
The platform version of an emulator or a real device.
30+
This capability is used for device autodetection if udid is not provided.
31+
"""
32+
return self.get_capability(PLATFORM_VERSION)
33+
34+
@platform_version.setter
35+
def platform_version(self, value: str) -> None:
36+
"""
37+
Set the platform version of an emulator or a real device.
38+
This capability is used for device autodetection if udid is not provided.
39+
"""
40+
self.set_capability(PLATFORM_VERSION, value)

appium/options/ios/xcuitest/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from appium.options.common.locale_option import LocaleOption
3131
from appium.options.common.orientation_option import OrientationOption
3232
from appium.options.common.other_apps_option import OtherAppsOption
33+
from appium.options.common.platform_version_option import PlatformVersionOption
3334
from appium.options.common.skip_log_capture_option import SkipLogCaptureOption
3435
from appium.options.common.udid_option import UdidOption
3536

@@ -120,6 +121,7 @@ class XCUITestOptions(
120121
AppiumOptions,
121122
AppOption,
122123
BundleIdOption,
124+
PlatformVersionOption,
123125
ClearSystemFilesOption,
124126
OrientationOption,
125127
UdidOption,

0 commit comments

Comments
 (0)