Sitelet https://github.com/appium/python-client/pull/728/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions appium/options/android/espresso/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
31 changes: 28 additions & 3 deletions appium/options/android/uiautomator2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
41 changes: 41 additions & 0 deletions appium/options/common/app_option.py
Original file line number Diff line number Diff line change
@@ -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)
40 changes: 40 additions & 0 deletions appium/options/common/auto_web_view_option.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 6 additions & 10 deletions appium/options/common/automation_name_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 11 additions & 1 deletion appium/options/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
38 changes: 38 additions & 0 deletions appium/options/common/clear_system_files_option.py
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 38 additions & 0 deletions appium/options/common/device_name_option.py
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 38 additions & 0 deletions appium/options/common/enable_performance_logging_option.py
Original file line number Diff line number Diff line change
@@ -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)
40 changes: 40 additions & 0 deletions appium/options/common/event_timings_option.py
Original file line number Diff line number Diff line change
@@ -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)
Loading