想在键盘控件中添加完成按钮以隐藏ios中的键盘

时间:2016-07-01 11:26:27

标签: ios appium-ios

我想在字段中输入数据后隐藏键盘。对于设备键盘中有返回按钮的情况,下面的代码可以正常工作。

IOSDriver< WebElement> AD= (IOSDriver) driver;
AD.getKeyboard().sendKeys(Keys.RETURN);

但是当有一个完成按钮时它没有。我想我们必须添加这个按钮。

1 个答案:

答案 0 :(得分:1)

来自java-client的IOSDriver类:http://appium.github.io/java-client/

#import "IOKitLib.h"
#import <dlfcn.h>
#import <pthread.h>
#import <mach/mach.h>
#import <sys/ptrace.h>
#import <libkern/OSAtomic.h>


static     mach_port_t masterPort = 0;

extern "C" kern_return_t io_service_open_extended
(
mach_port_t service,
task_t owningTask,
uint32_t connect_type,
NDR_record_t ndr,
io_buf_ptr_t properties,
mach_msg_type_number_t propertiesCnt,
kern_return_t *result,
mach_port_t *connection
);

因此,您需要使用以下命令在键盘上按Done: public void hideKeyboard(String strategy, String keyName) Description copied from interface: IOSDeviceActionShortcuts Hides the keyboard if it is showing. Available strategies are PRESS_KEY and TAP_OUTSIDE. One taps outside the keyboard, the other presses a key of your choosing (probably the 'Done' key). Hiding the keyboard often depends on the way an app is implemented, no single strategy always works.

相关问题