How to enable keyboard in android native apps

I have requirement to verify the text box is focused and keyboard is displayed when click on comment button.

but i have disabled the keyboard by using below capabilities in suite level(permanently disabled keyboard for all scripts).
capabilities.setCapability(“unicodeKeyboard”, true);
capabilities.setCapability(“resetKeyboard”, true);

now I required for one test script to verify the keyboard.please help me on this.(is there any specific method to enable the keyboard at script level)

to check keyboard:

// java
((AndroidDriver) driver).isKeyboardShown();

I want to enable the keyboard(it should be visible) on screen.

Dont use those capabilities for that specific test

In my project, we are creating driver once and using for all the scripts.so we cannot set capabilities at the script level.

then no chance :slight_smile: just wonder how tests are written with only one driver opening? if error happens in one test - all after will fail?

Sorry, Actually in my framework we are giving the capabilities at suite level and we are creating the new driver for each script with same capabilities.So we can’t modify the capabilities at the script level.

then overwrite your capabilities at TEST level (or even method level for testNG). example:

<test name="execute_tests_oldAndroid_1">
        <parameter name="runDestination" value="emulator"/>
        <parameter name="devicePlatform" value="android fullReset"/>
        <parameter name="deviceName" value="Nexus5_API18"/>
        <classes>
            <class name="com.xxxx.tests.android.oldAndroid">
                <methods>
                    <include name="login"></include>
                </methods>
            </class>
        </classes>
    </test>
2 Likes

((AndroidDriver) driver).isKeyboardShown(); this method is not available in appium-java client 4.1.2 version and I am able to see this method in appium java-client 5.1.9 beta.

Thanks for the solution. Now I am able to overwrite the capabilities at script level.

@Aleksei

Hi Aleksei,
are you suggesting to kill driver at end of the test class file and create a new driver ? could you quote example of approach you have taken.

I am closing driver in afterMethod of testNG function. Example here (although here in afterClass) https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/BaseAndroidTest.java

1 Like

@Aleksei
I tried switching between Appium and Android driver by closing Appium Service and calling quit on driver but it does not works, however closing and opening same driver type (Android driver) works fine.

After lot of struggle i found one solution in application manager one application will be downloaded you can unintall that it show the keyboard back again.