Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ jobs:
XCODE_VERSION: 16.4
IOS_VERSION: 18.5
IPHONE_MODEL: iPhone 16
FLUTTER_ANDROID_APP: "https://github.com/AppiumTestDistribution/appium-flutter-server/releases/latest/download/app-debug.apk"
FLUTTER_IOS_APP: "https://github.com/AppiumTestDistribution/appium-flutter-server/releases/latest/download/ios.zip"
FLUTTER_ANDROID_APP: "https://github.com/AppiumTestDistribution/appium-flutter-server/releases/download/0.0.33/app-debug.apk"
FLUTTER_IOS_APP: "https://github.com/AppiumTestDistribution/appium-flutter-server/releases/download/0.0.33/ios.zip"
PREBUILT_WDA_PATH: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app

steps:
Expand Down
31 changes: 4 additions & 27 deletions appium/webdriver/extensions/device_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,19 @@

from typing import Optional

from selenium.common.exceptions import UnknownMethodException

from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence

from ..mobilecommand import MobileCommand as Command


class DeviceTime(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
class DeviceTime(CanExecuteCommands, CanExecuteScripts):
@property
def device_time(self) -> str:
"""Returns the date and time from the device.

Return:
str: The date and time
"""
ext_name = 'mobile: getDeviceTime'
try:
return self.assert_extension_exists(ext_name).execute_script(ext_name)
except UnknownMethodException:
# TODO: Remove the fallback
return self.mark_extension_absence(ext_name).execute(Command.GET_DEVICE_TIME_GET, {})['value']
return self.execute_script('mobile: getDeviceTime')

def get_device_time(self, format: Optional[str] = None) -> str:
"""Returns the date and time from the device.
Expand All @@ -54,22 +44,9 @@ def get_device_time(self, format: Optional[str] = None) -> str:
Return:
str: The date and time
"""
ext_name = 'mobile: getDeviceTime'
if format is None:
return self.device_time
try:
return self.assert_extension_exists(ext_name).execute_script(ext_name, {'format': format})
except UnknownMethodException:
return self.mark_extension_absence(ext_name).execute(Command.GET_DEVICE_TIME_POST, {'format': format})['value']
return self.execute_script('mobile: getDeviceTime', {'format': format})

def _add_commands(self) -> None:
self.command_executor.add_command(
Command.GET_DEVICE_TIME_GET,
'GET',
'/session/$sessionId/appium/device/system_time',
)
self.command_executor.add_command(
Command.GET_DEVICE_TIME_POST,
'POST',
'/session/$sessionId/appium/device/system_time',
)
pass
2 changes: 0 additions & 2 deletions appium/webdriver/mobilecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class MobileCommand:
IS_LOCKED = 'isLocked'
LOCK = 'lock'
UNLOCK = 'unlock'
GET_DEVICE_TIME_GET = 'getDeviceTimeGet'
GET_DEVICE_TIME_POST = 'getDeviceTimePost'
INSTALL_APP = 'installApp'
REMOVE_APP = 'removeApp'
IS_APP_INSTALLED = 'isAppInstalled'
Expand Down
1 change: 1 addition & 0 deletions test/functional/flutter_integration/helper/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def make_options() -> FlutterOptions:
'newCommandTimeout': 120,
'uiautomator2ServerInstallTimeout': 120000,
'adbExecTimeout': 120000,
'androidInstallTimeout': 240000,
'app': os.environ['FLUTTER_ANDROID_APP'],
'autoGrantPermissions': True,
}
Expand Down
15 changes: 0 additions & 15 deletions test/unit/webdriver/device/device_time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ class TestWebDriverDeviceTime:
@httpretty.activate
def test_device_time(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.GET,
appium_command('/session/1234567890/appium/device/system_time'),
body='{"value": "2019-01-05T14:46:44+09:00"}',
)
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/execute/sync'),
Expand All @@ -36,11 +31,6 @@ def test_device_time(self):
@httpretty.activate
def test_get_device_time(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.GET,
appium_command('/session/1234567890/appium/device/system_time'),
body='{"value": "2019-01-05T14:46:44+09:00"}',
)
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/execute/sync'),
Expand All @@ -51,11 +41,6 @@ def test_get_device_time(self):
@httpretty.activate
def test_get_formatted_device_time(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/device/system_time'),
body='{"value": "2019-01-08"}',
)
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/execute/sync'),
Expand Down
Loading