# How to get the height of Keyboard in Android and iOS

**URL:** <https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326>\
**Category:** Issues/Bugs\
**Created:** [April 15, 2020, 6:18am UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326 "2020-04-15T06:18:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolvasanth](https://discuss.appium.io/user_avatar/discuss.appium.io/coolvasanth/32/7085_2.png) [@coolvasanth](https://discuss.appium.io/u/coolvasanth)\
**Post date:** [April 15, 2020, 6:18am UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/1 "2020-04-15T06:18:38Z")

</div>

Hi,

There is a button at the bottom my a page. When keyboard is open there are chances that the button will be present behind the Keyboard. What is the best way I can detect it ? I had a thought that, by knowing the y co-ordinate of keyboard and the element we can figure this out.  
But I do not know how to find the position of height of the keyboard. Kindly help at the earliest.

---

<div class="post-metadata">

**Author:** ![mykola-mokhnach](https://discuss.appium.io/user_avatar/discuss.appium.io/mykola-mokhnach/32/4578_2.png) [@mykola-mokhnach](https://discuss.appium.io/u/mykola-mokhnach)\
**Post date:** [April 15, 2020, 10:28am UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/2 "2020-04-15T10:28:26Z")

</div>

By default the keyboard element is not visible in the page source. You could try to enable the `enableMultiWindows` setting in order to “see” it (requires the most recent server version)

---

<div class="post-metadata">

**Author:** ![coolvasanth](https://discuss.appium.io/user_avatar/discuss.appium.io/coolvasanth/32/7085_2.png) [@coolvasanth](https://discuss.appium.io/u/coolvasanth)\
**Post date:** [April 17, 2020, 9:35am UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/3 "2020-04-17T09:35:46Z")

</div>

Hi @mykola-mokhnach can you give me a small code snippet, how to achieve it ? Should I need to set this property (`enableMultiWindows`) during appium driver creation ?

---

<div class="post-metadata">

**Author:** ![abhiqa](https://discuss.appium.io/user_avatar/discuss.appium.io/abhiqa/32/11074_2.png) [@abhiqa](https://discuss.appium.io/u/abhiqa)\
**Post date:** [April 17, 2020, 2:29pm UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/4 "2020-04-17T14:29:11Z")

</div>

@coolvasanth if you don’t need keyboard anymore you can hide keyboard by using `driver.hideKeyboard()` method and perform desired action on specific button. From your description it’s not clear that what you want to achieve, do you need to click on this button when keyboard is opened or you just need to located the button only.  
Exact manual steps are very important for automating any test case.

---

<div class="post-metadata">

**Author:** ![coolvasanth](https://discuss.appium.io/user_avatar/discuss.appium.io/coolvasanth/32/7085_2.png) [@coolvasanth](https://discuss.appium.io/u/coolvasanth)\
**Post date:** [April 20, 2020, 5:22am UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/5 "2020-04-20T05:22:24Z")

</div>

@abhiqa, Thanks for the reply. The test case requirement is to just ensure the button is not behind the keyboard. Below is the detailed steps for your reference.

- Open search page and enter key ‘xyz’

- When the keyboard is open the fab submit button which is present on the bottom right of the page should be visible(should be present above the keyboard).

- After successful entering of the key the keyboard should suspend and the submit fab button should be present on the default state. (at the bottom left)

---

<div class="post-metadata">

**Author:** ![abhiqa](https://discuss.appium.io/user_avatar/discuss.appium.io/abhiqa/32/11074_2.png) [@abhiqa](https://discuss.appium.io/u/abhiqa)\
**Post date:** [April 21, 2020, 4:39am UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/6 "2020-04-21T04:39:02Z")

</div>

@coolvasanth you can use assertion to check whether the button is displayed or not on screen while keyboard is opened.  
to do so you may use elements.`isEmpty(); or element.isDisplayed();` after step 1  
though i am not sure about the reliability of `isDisplayed()` method.

Alternatively if the button text is unique you can getText of particular button and store it in an element and matches after step 1 that it is displayed on the screen or not.

Hope it’ll solve your problem.

---

<div class="post-metadata">

**Author:** ![coolvasanth](https://discuss.appium.io/user_avatar/discuss.appium.io/coolvasanth/32/7085_2.png) [@coolvasanth](https://discuss.appium.io/u/coolvasanth)\
**Post date:** [April 21, 2020, 12:13pm UTC](https://discuss.appium.io/t/how-to-get-the-height-of-keyboard-in-android-and-ios/30326/7 "2020-04-21T12:13:28Z")

</div>

@abhiqa, thanks for the reply. I’m kind a aware of this approach, thanks for suggesting again, I have not tried it. Will test it and post the result here.
