Add events property by vrunoa · Pull Request #427 · appium/python-client · GitHub
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
2 changes: 2 additions & 0 deletions appium/webdriver/mobilecommand.py
28 changes: 28 additions & 0 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,32 @@ def battery_info(self):
"""
return self.execute_script('mobile: batteryInfo')

@property
Comment thread
vrunoa marked this conversation as resolved.
def session(self):
""" Retrieves session information from the current session
Usage:
session = driver.session
Returns:
`dict containing information from the current session`
"""
return self.execute(Command.GET_SESSION)['value']

@property
def events(self):
""" Retrieves events information from the current session
Usage:
events = driver.events

Returns:
`dict containing events timing information from the current session`
"""
try:
session = self.session
return session['events']
except Exception as e:
Comment thread
vrunoa marked this conversation as resolved.
logger.warning('Could not find events information in the session. Error:', e)
return {}

# pylint: disable=protected-access

def _addCommands(self):
Expand All @@ -701,6 +727,8 @@ def _addCommands(self):
if hasattr(mixin_class, self._addCommands.__name__):
getattr(mixin_class, self._addCommands.__name__, None)(self)

self.command_executor._commands[Command.GET_SESSION] = \
('GET', '/session/$sessionId')
self.command_executor._commands[Command.TOUCH_ACTION] = \
('POST', '/session/$sessionId/touch/perform')
self.command_executor._commands[Command.MULTI_ACTION] = \
Expand Down
59 changes: 59 additions & 0 deletions test/unit/webdriver/webdriver_test.py