Skip to content

Commit

Permalink
refactor!: remove several previously deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Sep 1, 2023
1 parent 2e49569 commit 83f559f
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 587 deletions.
22 changes: 0 additions & 22 deletions appium/webdriver/common/mobileby.py

This file was deleted.

51 changes: 0 additions & 51 deletions appium/webdriver/extensions/android/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from typing import TYPE_CHECKING, cast

from selenium.common.exceptions import TimeoutException, UnknownMethodException
from selenium.webdriver.support.ui import WebDriverWait

Expand All @@ -23,52 +20,8 @@
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
from appium.webdriver.mobilecommand import MobileCommand as Command

if TYPE_CHECKING:
from appium.webdriver.webdriver import WebDriver


class Activities(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
def start_activity(self, app_package: str, app_activity: str, **opts: str) -> 'WebDriver':
"""Opens an arbitrary activity during a test. If the activity belongs to
another application, that application is started and the activity is opened.
deprecated:: 2.9.0
This is an Android-only method.
Args:
app_package: The package containing the activity to start.
app_activity: The activity to start.
Keyword Args:
app_wait_package (str): Begin automation after this package starts.
app_wait_activity (str): Begin automation after this activity starts.
intent_action (str): Intent to start.
intent_category (str): Intent category to start.
intent_flags (str): Flags to send to the intent.
optional_intent_arguments (str): Optional arguments to the intent.
dont_stop_app_on_reset (str): Should the app be stopped on reset?
"""
warnings.warn(
'The "session" API is deprecated. Use "mobile: startActivity" extension instead.',
DeprecationWarning,
)

data = {'appPackage': app_package, 'appActivity': app_activity}
arguments = {
'app_wait_package': 'appWaitPackage',
'app_wait_activity': 'appWaitActivity',
'intent_action': 'intentAction',
'intent_category': 'intentCategory',
'intent_flags': 'intentFlags',
'optional_intent_arguments': 'optionalIntentArguments',
'dont_stop_app_on_reset': 'dontStopAppOnReset',
}
for key, value in arguments.items():
if key in opts:
data[value] = opts[key]
self.execute(Command.START_ACTIVITY, data)
return cast('WebDriver', self)

@property
def current_activity(self) -> str:
"""Retrieves the current activity running on the device.
Expand Down Expand Up @@ -109,7 +62,3 @@ def _add_commands(self) -> None:
'GET',
'/session/$sessionId/appium/device/current_activity',
)
commands[Command.START_ACTIVITY] = (
'POST',
'/session/$sessionId/appium/device/start_activity',
)
30 changes: 0 additions & 30 deletions appium/webdriver/extensions/android/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,6 @@


class Common(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
def end_test_coverage(self, intent: str, path: str) -> Any:
"""Ends the coverage collection and pull the coverage.ec file from the device.
deprecated:: 2.9.0
Android only.
See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-coverage.md
Args:
intent: description of operation to be performed
path: path to coverage.ec file to be pulled from the device
Returns:
TODO
"""
warnings.warn(
'This API is deprecated and will be removed in future versions',
DeprecationWarning,
)
return self.execute(
Command.END_TEST_COVERAGE,
{
'intent': intent,
'path': path,
},
)['value']

def open_notifications(self) -> 'WebDriver':
"""Open notification shade in Android (API Level 18 and above)
Expand Down Expand Up @@ -83,10 +57,6 @@ def _add_commands(self) -> None:
'GET',
'/session/$sessionId/appium/device/current_package',
)
commands[Command.END_TEST_COVERAGE] = (
'POST',
'/session/$sessionId/appium/app/end_test_coverage',
)
commands[Command.OPEN_NOTIFICATIONS] = (
'POST',
'/session/$sessionId/appium/device/open_notifications',
Expand Down
53 changes: 0 additions & 53 deletions appium/webdriver/extensions/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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.
import warnings
from typing import TYPE_CHECKING, Any, Dict, Union, cast

from selenium.common.exceptions import InvalidArgumentException, UnknownMethodException
Expand Down Expand Up @@ -145,39 +144,6 @@ def remove_app(self, app_id: str, **options: Any) -> 'WebDriver':
self.mark_extension_absence(ext_name).execute(Command.REMOVE_APP, data)
return cast('WebDriver', self)

def launch_app(self) -> 'WebDriver':
"""Start on the device the application specified in the desired capabilities.
deprecated:: 2.0.0
Returns:
Union['WebDriver', 'Applications']: Self instance
"""
warnings.warn(
'The "launchApp" API is deprecated and will be removed in future versions. '
'See https://github.com/appium/appium/issues/15807',
DeprecationWarning,
)

self.execute(Command.LAUNCH_APP)
return cast('WebDriver', self)

def close_app(self) -> 'WebDriver':
"""Stop the running application, specified in the desired capabilities, on
the device.
deprecated:: 2.0.0
Returns:
Union['WebDriver', 'Applications']: Self instance
"""
warnings.warn(
'The "closeApp" API is deprecated and will be removed in future versions. '
'See https://github.com/appium/appium/issues/15807',
DeprecationWarning,
)

self.execute(Command.CLOSE_APP)
return cast('WebDriver', self)

def terminate_app(self, app_id: str, **options: Any) -> bool:
"""Terminates the application if it is running.
Expand Down Expand Up @@ -283,22 +249,6 @@ def app_strings(self, language: Union[str, None] = None, string_file: Union[str,
# TODO: Remove the fallback
return self.mark_extension_absence(ext_name).execute(Command.GET_APP_STRINGS, data)['value']

def reset(self) -> 'WebDriver':
"""Resets the current application on the device.
deprecated:: 2.0.0
Returns:
Union['WebDriver', 'Applications']: Self instance
"""
warnings.warn(
'The "reset" API is deprecated and will be removed in future versions. '
'See https://github.com/appium/appium/issues/15807',
DeprecationWarning,
)

self.execute(Command.RESET)
return cast('WebDriver', self)

def _add_commands(self) -> None:
# noinspection PyProtectedMember,PyUnresolvedReferences
commands = self.command_executor._commands
Expand All @@ -322,6 +272,3 @@ def _add_commands(self) -> None:
'/session/$sessionId/appium/device/app_state',
)
commands[Command.GET_APP_STRINGS] = ('POST', '/session/$sessionId/appium/app/strings')
commands[Command.RESET] = ('POST', '/session/$sessionId/appium/app/reset')
commands[Command.LAUNCH_APP] = ('POST', '/session/$sessionId/appium/app/launch')
commands[Command.CLOSE_APP] = ('POST', '/session/$sessionId/appium/app/close')
141 changes: 0 additions & 141 deletions appium/webdriver/extensions/ime.py

This file was deleted.

Loading

0 comments on commit 83f559f

Please sign in to comment.