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
14 changes: 14 additions & 0 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,20 @@ def long_press_keycode(self, keycode, metastate=None, flags=None):
self.execute(Command.LONG_PRESS_KEYCODE, data)
return self

def press_button(self, button_name):
"""Sends a physical button name to the device to simulate the user pressing. iOS only.
Possible button names can be found in
https://github.com/appium/WebDriverAgent/blob/master/WebDriverAgentLib/Categories/XCUIDevice%2BFBHelpers.h

:Args:
- button_name - the button name to be sent to the device
"""
data = {
'name': button_name
}
self.execute_script('mobile: pressButton', data)
return self

@property
def current_activity(self):
"""Retrieves the current activity running on the device.
Expand Down
8 changes: 8 additions & 0 deletions test/functional/ios/appium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ def test_clear(self):
text = self.driver.find_element_by_accessibility_id('Normal').get_attribute('value')
self.assertEqual(text, def_text)

def test_press_button(self):
self.driver.press_button("Home")
if float(desired_capabilities.get_desired_capabilities(
desired_capabilities.BUNDLE_ID)['platformVersion']) < 11:
return
self.assertEqual(self.driver.query_app_state(desired_capabilities.BUNDLE_ID),
ApplicationState.RUNNING_IN_FOREGROUND)


if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)
Expand Down