Skip to content

Commit 60ec7ce

Browse files
feat: Add common options (appium#728)
1 parent 8321b9c commit 60ec7ce

28 files changed

+856
-28
lines changed

appium/options/android/espresso/base.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,34 @@
1717

1818
from typing import Dict
1919

20-
from appium.options.common.base import AppiumOptions
20+
from appium.options.common.app_option import AppOption
21+
from appium.options.common.auto_web_view_option import AutoWebViewOption
22+
from appium.options.common.automation_name_option import AUTOMATION_NAME
23+
from appium.options.common.base import PLATFORM_NAME, AppiumOptions
24+
from appium.options.common.device_name_option import DeviceNameOption
25+
from appium.options.common.is_headless_option import IsHeadlessOption
26+
from appium.options.common.language_option import LanguageOption
27+
from appium.options.common.locale_option import LocaleOption
28+
from appium.options.common.orientation_option import OrientationOption
29+
from appium.options.common.skip_log_capture_option import SkipLogCaptureOption
30+
from appium.options.common.udid_option import UdidOption
2131

2232

2333
class EspressoOptions(
2434
AppiumOptions,
35+
AppOption,
36+
OrientationOption,
37+
UdidOption,
38+
LanguageOption,
39+
LocaleOption,
40+
IsHeadlessOption,
41+
SkipLogCaptureOption,
42+
AutoWebViewOption,
43+
DeviceNameOption,
2544
):
2645
@property
2746
def default_capabilities(self) -> Dict:
2847
return {
29-
AppiumOptions.AUTOMATION_NAME: 'Espresso',
30-
AppiumOptions.PLATFORM_NAME: 'Android',
48+
AUTOMATION_NAME: 'Espresso',
49+
PLATFORM_NAME: 'Android',
3150
}

appium/options/android/uiautomator2/base.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,40 @@
1717

1818
from typing import Dict
1919

20-
from appium.options.common.base import AppiumOptions
20+
from appium.options.common.app_option import AppOption
21+
from appium.options.common.auto_web_view_option import AutoWebViewOption
22+
from appium.options.common.automation_name_option import AUTOMATION_NAME
23+
from appium.options.common.base import PLATFORM_NAME, AppiumOptions
24+
from appium.options.common.clear_system_files_option import ClearSystemFilesOption
25+
from appium.options.common.device_name_option import DeviceNameOption
26+
from appium.options.common.enable_performance_logging_option import EnablePerformanceLoggingOption
27+
from appium.options.common.is_headless_option import IsHeadlessOption
28+
from appium.options.common.language_option import LanguageOption
29+
from appium.options.common.locale_option import LocaleOption
30+
from appium.options.common.orientation_option import OrientationOption
31+
from appium.options.common.other_apps_option import OtherAppsOption
32+
from appium.options.common.skip_log_capture_option import SkipLogCaptureOption
33+
from appium.options.common.udid_option import UdidOption
2134

2235

2336
class UiAutomator2Options(
2437
AppiumOptions,
38+
AppOption,
39+
ClearSystemFilesOption,
40+
OrientationOption,
41+
UdidOption,
42+
LanguageOption,
43+
LocaleOption,
44+
IsHeadlessOption,
45+
SkipLogCaptureOption,
46+
AutoWebViewOption,
47+
EnablePerformanceLoggingOption,
48+
OtherAppsOption,
49+
DeviceNameOption,
2550
):
2651
@property
2752
def default_capabilities(self) -> Dict:
2853
return {
29-
AppiumOptions.AUTOMATION_NAME: 'UIAutomator2',
30-
AppiumOptions.PLATFORM_NAME: 'Android',
54+
AUTOMATION_NAME: 'UIAutomator2',
55+
PLATFORM_NAME: 'Android',
3156
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
APP = 'app'
23+
24+
25+
class AppOption(SupportsCapabilities):
26+
@property
27+
def app(self) -> Optional[str]:
28+
"""
29+
:Returns: String representing app location.
30+
"""
31+
return self.get_capability(APP)
32+
33+
@app.setter
34+
def app(self, value: str) -> None:
35+
"""
36+
Set the absolute local path for the location of the App.
37+
The app must be located on the same machine where Appium
38+
server is running.
39+
Could also be a valid URL.
40+
"""
41+
self.set_capability(APP, 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+
AUTO_WEB_VIEW = 'autoWebView'
23+
24+
25+
class AutoWebViewOption(SupportsCapabilities):
26+
@property
27+
def auto_web_view(self) -> Optional[bool]:
28+
"""
29+
:Returns: Whether the driver should try to automatically switch
30+
to a web view context after the session is started.
31+
"""
32+
return self.get_capability(AUTO_WEB_VIEW)
33+
34+
@auto_web_view.setter
35+
def auto_web_view(self, value: bool) -> None:
36+
"""
37+
Set whether the driver should try to automatically switch
38+
a web view context after the session is started.
39+
"""
40+
self.set_capability(AUTO_WEB_VIEW, value)

appium/options/common/automation_name_option.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@
1919

2020
from .supports_capabilities import SupportsCapabilities
2121

22+
AUTOMATION_NAME = 'automationName'
2223

23-
class AutomationNameOption(SupportsCapabilities):
24-
AUTOMATION_NAME = 'automationName'
2524

25+
class AutomationNameOption(SupportsCapabilities):
2626
@property
2727
def automation_name(self) -> Optional[str]:
2828
"""
29-
:Returns: String representing the name of the automation engine
29+
:Returns: String representing the name of the automation engine name.
3030
"""
31-
return self.get_capability(self.AUTOMATION_NAME)
31+
return self.get_capability(AUTOMATION_NAME)
3232

3333
@automation_name.setter
3434
def automation_name(self, value: str) -> None:
3535
"""
36-
Set the automation driver to use.
37-
38-
:Args:
39-
- value: One of supported automation names
40-
36+
Set the automation driver name to use for the given platform.
4137
"""
42-
self.set_capability(self.AUTOMATION_NAME, value)
38+
self.set_capability(AUTOMATION_NAME, value)

appium/options/common/base.py

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

2323
from .automation_name_option import AutomationNameOption
24+
from .event_timings_option import EventTimingsOption
25+
from .full_reset_option import FullResetOption
26+
from .new_command_timeout_option import NewCommandTimeoutOption
27+
from .no_reset_option import NoResetOption
28+
from .print_page_source_on_find_failure_option import PrintPageSourceOnFindFailureOption
2429

2530
APPIUM_PREFIX = 'appium:'
2631
T = TypeVar('T', bound='AppiumOptions')
32+
PLATFORM_NAME = 'platformName'
2733

2834

2935
class AppiumOptions(
3036
BaseOptions,
3137
AutomationNameOption,
38+
EventTimingsOption,
39+
PrintPageSourceOnFindFailureOption,
40+
NoResetOption,
41+
FullResetOption,
42+
NewCommandTimeoutOption,
3243
):
3344
_caps: Dict
34-
PLATFORM_NAME = 'platformName'
3545
W3C_CAPABILITY_NAMES = frozenset(
3646
[
3747
'acceptInsecureCerts',
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+
CLEAR_SYSTEM_FILES = 'clearSystemFiles'
23+
24+
25+
class ClearSystemFilesOption(SupportsCapabilities):
26+
@property
27+
def clear_system_files(self) -> Optional[bool]:
28+
"""
29+
:Returns: Whether the driver should delete generated files at the end of a session.
30+
"""
31+
return self.get_capability(CLEAR_SYSTEM_FILES)
32+
33+
@clear_system_files.setter
34+
def clear_system_files(self, value: bool) -> None:
35+
"""
36+
Set whether the driver should delete generated files at the end of a session.
37+
"""
38+
self.set_capability(CLEAR_SYSTEM_FILES, value)
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+
DEVICE_NAME = 'deviceName'
23+
24+
25+
class DeviceNameOption(SupportsCapabilities):
26+
@property
27+
def device_name(self) -> Optional[str]:
28+
"""
29+
:Returns: The name of the device.
30+
"""
31+
return self.get_capability(DEVICE_NAME)
32+
33+
@device_name.setter
34+
def device_name(self, value: str) -> None:
35+
"""
36+
Set the name of the device to be used in the test.
37+
"""
38+
self.set_capability(DEVICE_NAME, value)
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+
ENABLE_PERFORMANCE_LOGGING = 'enablePerformanceLogging'
23+
24+
25+
class EnablePerformanceLoggingOption(SupportsCapabilities):
26+
@property
27+
def enable_performance_logging(self) -> Optional[bool]:
28+
"""
29+
:Returns: Whether to enable additional performance logging.
30+
"""
31+
return self.get_capability(ENABLE_PERFORMANCE_LOGGING)
32+
33+
@enable_performance_logging.setter
34+
def enable_performance_logging(self, value: bool) -> None:
35+
"""
36+
Set whether to enable additional performance logging.
37+
"""
38+
self.set_capability(ENABLE_PERFORMANCE_LOGGING, 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+
EVENT_TIMINGS = 'eventTimings'
23+
24+
25+
class EventTimingsOption(SupportsCapabilities):
26+
@property
27+
def event_timings(self) -> Optional[bool]:
28+
"""
29+
:Returns: Whether the driver should to report the timings
30+
for various Appium-internal events.
31+
"""
32+
return self.get_capability(EVENT_TIMINGS)
33+
34+
@event_timings.setter
35+
def event_timings(self, value: bool) -> None:
36+
"""
37+
Set whether the driver should to report the timings
38+
for various Appium-internal events.
39+
"""
40+
self.set_capability(EVENT_TIMINGS, value)

0 commit comments

Comments
 (0)