Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
15 changes: 15 additions & 0 deletions src/main/java/io/appium/java_client/HasOnScreenKeyboard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.appium.java_client;

import static io.appium.java_client.MobileCommand.isKeyboardShownCommand;

public interface HasOnScreenKeyboard extends ExecutesMethod {

/**
* Check if the keyboard is displayed.
*
* @return true if keyboard is displayed. False otherwise
*/
default boolean isKeyboardShown() {
return CommandExecutionHelper.execute(this, isKeyboardShownCommand());
}
}
10 changes: 10 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,14 @@ public static ImmutableMap<String, Object> prepareArguments(String[] params,
new String(img2Data, StandardCharsets.UTF_8), options.build()};
return new AbstractMap.SimpleEntry<>(COMPARE_IMAGES, prepareArguments(parameters, values));
}

/**
* This method forms a {@link Map} of parameters for the checking of the keyboard state (is it shown or not).
*
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
*/
public static Map.Entry<String, Map<String, ?>> isKeyboardShownCommand() {
return new AbstractMap.SimpleEntry<>(
IS_KEYBOARD_SHOWN, ImmutableMap.<String, Object>of());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.FindsByAndroidUIAutomator;
import io.appium.java_client.HasOnScreenKeyboard;
import io.appium.java_client.LocksDevice;
import io.appium.java_client.PressesKeyCode;
import io.appium.java_client.android.connection.HasNetworkConnection;
Expand Down Expand Up @@ -51,8 +52,8 @@
public class AndroidDriver<T extends WebElement>
extends AppiumDriver<T>
implements PressesKeyCode, HasNetworkConnection, PushesFiles, StartsActivity,
FindsByAndroidUIAutomator<T>, LocksDevice, HasAndroidSettings, HasDeviceDetails,
HasSupportedPerformanceDataType, AuthenticatesByFinger,
FindsByAndroidUIAutomator<T>, LocksDevice, HasAndroidSettings, HasAndroidDeviceDetails,
HasSupportedPerformanceDataType, AuthenticatesByFinger, HasOnScreenKeyboard,
CanRecordScreen, SupportsSpecialEmulatorCommands,
SupportsNetworkStateManagement, ListensToLogcatMessages, HasAndroidClipboard {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface should be added to AndroidDriver as well


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,6 @@ public class AndroidMobileCommandHelper extends MobileCommand {
GET_SYSTEM_BARS, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link Map} of parameters for the checking of the keyboard state (is it shown or not).
*
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
*/
public static Map.Entry<String, Map<String, ?>> isKeyboardShownCommand() {
return new AbstractMap.SimpleEntry<>(
IS_KEYBOARD_SHOWN, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* finger print authentication invocation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.appium.java_client.android;

import static io.appium.java_client.android.AndroidMobileCommandHelper.getDisplayDensityCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.getSystemBarsCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.isKeyboardShownCommand;

import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.ExecutesMethod;

import java.util.Map;

public interface HasDeviceDetails extends ExecutesMethod {
import static io.appium.java_client.android.AndroidMobileCommandHelper.getDisplayDensityCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.getSystemBarsCommand;

public interface HasAndroidDeviceDetails extends ExecutesMethod {

/*
Retrieve the display density of the Android device.
*/
Expand All @@ -24,12 +24,4 @@ default Map<String, String> getSystemBars() {
return CommandExecutionHelper.execute(this, getSystemBarsCommand());
}

/**
* Check if the keyboard is displayed.
*
* @return true if keyboard is displayed. False otherwise
*/
default boolean isKeyboardShown() {
return CommandExecutionHelper.execute(this, isKeyboardShownCommand());
}
}
3 changes: 2 additions & 1 deletion src/main/java/io/appium/java_client/ios/IOSDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.appium.java_client.FindsByIosClassChain;
import io.appium.java_client.FindsByIosNSPredicate;
import io.appium.java_client.FindsByIosUIAutomation;
import io.appium.java_client.HasOnScreenKeyboard;
import io.appium.java_client.HidesKeyboardWithKeyName;
import io.appium.java_client.LocksDevice;
import io.appium.java_client.remote.MobilePlatform;
Expand Down Expand Up @@ -54,7 +55,7 @@
*/
public class IOSDriver<T extends WebElement>
extends AppiumDriver<T>
implements HidesKeyboardWithKeyName, ShakesDevice, HasIOSSettings,
implements HidesKeyboardWithKeyName, ShakesDevice, HasIOSSettings, HasOnScreenKeyboard,
FindsByIosUIAutomation<T>, LocksDevice, PerformsTouchID, FindsByIosNSPredicate<T>,
FindsByIosClassChain<T>, PushesFiles, CanRecordScreen, HasIOSClipboard, ListensToSyslogMessages {

Expand Down
6 changes: 6 additions & 0 deletions src/test/java/io/appium/java_client/ios/IOSDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ public void getDeviceTimeTest() {
byte[] data = driver.pullFile("Library/AddressBook/AddressBook.sqlitedb");
assert (data.length > 0);
}

@Test public void keyboardTest() {
MobileElement element = driver.findElementById("IntegerA");
element.click();
assertTrue(driver.isKeyboardShown());
}
}