Skip to content

Commit 99b125b

Browse files
committed
Add device_time property
1 parent 605a7fe commit 99b125b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ class MobileCommand(object):
5656
GET_SETTINGS = 'getSettings'
5757
UPDATE_SETTINGS = 'updateSettings'
5858
SET_LOCATION = 'setLocation'
59+
GET_DEVICE_TIME = 'getDeviceTime'

appium/webdriver/webdriver.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,12 @@ def set_location(self, latitude, longitude, altitude):
728728
self.execute(Command.SET_LOCATION, data)
729729
return self
730730

731+
@property
732+
def device_time(self):
733+
"""Returns the date and time fomr the device
734+
"""
735+
return self.execute(Command.GET_DEVICE_TIME, {})['value']
736+
731737
def _addCommands(self):
732738
self.command_executor._commands[Command.CONTEXTS] = \
733739
('GET', '/session/$sessionId/contexts')
@@ -810,3 +816,5 @@ def _addCommands(self):
810816
('POST', '/session/$sessionId/location')
811817
self.command_executor._commands[Command.LOCATION_IN_VIEW] = \
812818
('GET', '/session/$sessionId/element/$id/location_in_view')
819+
self.command_executor._commands[Command.GET_DEVICE_TIME] = \
820+
('GET', '/session/$sessionId/appium/device/system_time')

test/functional/android/appium_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
import random
2121
from time import sleep
22+
from dateutil.parser import parse
2223

2324
from selenium.common.exceptions import NoSuchElementException
2425

@@ -230,6 +231,11 @@ def test_element_location_in_view(self):
230231
self.assertIsNotNone(loc['x'])
231232
self.assertIsNotNone(loc['y'])
232233

234+
def test_device_time(self):
235+
date_time = self.driver.device_time
236+
# convert to date ought to work
237+
parse(date_time)
238+
233239

234240
if __name__ == "__main__":
235241
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)

0 commit comments

Comments
 (0)