Skip to content

Commit 75477dc

Browse files
committed
add support for is keyboard shown command
1 parent 5eaf4bd commit 75477dc

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class MobileCommand(object):
5959
TOGGLE_TOUCH_ID_ENROLLMENT = 'toggleTouchIdEnrollment'
6060
RESET = 'reset'
6161
HIDE_KEYBOARD = 'hideKeyboard'
62+
IS_KEYBOARD_SHOWN = 'isKeyboardShown'
6263
REPLACE_KEYS = 'replaceKeys'
6364
START_ACTIVITY = 'startActivity'
6465
GET_SETTINGS = 'getSettings'

appium/webdriver/webdriver.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,10 @@ def hide_keyboard(self, key_name=None, key=None, strategy=None):
615615
self.execute(Command.HIDE_KEYBOARD, data)
616616
return self
617617

618+
def is_keyboard_shown(self):
619+
"""Attempts to detect whether a software keyboard is present"""
620+
return self.execute(Command.IS_KEYBOARD_SHOWN)['value']
621+
618622
# Needed for Selendroid
619623
def keyevent(self, keycode, metastate=None):
620624
"""Sends a keycode to the device. Android only. Possible keycodes can be
@@ -1438,6 +1442,8 @@ def _addCommands(self):
14381442
('POST', '/session/$sessionId/appium/app/reset')
14391443
self.command_executor._commands[Command.HIDE_KEYBOARD] = \
14401444
('POST', '/session/$sessionId/appium/device/hide_keyboard')
1445+
self.command_executor._commands[Command.IS_KEYBOARD_SHOWN] = \
1446+
('GET', '/session/$sessionId/appium/device/is_keyboard_shown')
14411447
self.command_executor._commands[Command.OPEN_NOTIFICATIONS] = \
14421448
('POST', '/session/$sessionId/appium/device/open_notifications')
14431449
self.command_executor._commands[Command.GET_NETWORK_CONNECTION] = \

test/functional/ios/appium_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ def test_hide_keyboard_no_key_name(self):
116116
# currently fails.
117117
self.assertFalse(el.is_displayed())
118118

119+
def test_is_keyboard_shown(self):
120+
self.assertFalse(self.driver.is_keyboard_shown())
121+
el = self.driver.find_element_by_name('Uses of UITextField')
122+
el.click()
123+
124+
# get focus on text field, so keyboard comes up
125+
el = self.driver.find_element_by_class_name('UIATextField')
126+
el.set_value('Testing')
127+
self.assertTrue(self.driver.is_keyboard_shown())
128+
119129
def test_clear(self):
120130
# Click text fields
121131
self.driver.find_element_by_accessibility_id('TextFields').click()

0 commit comments

Comments
 (0)