习惯性伸手党区 请问 selenium 中如何隐藏键盘呢

云飞凌风 · August 21, 2014 · Last by Archer_小A replied at August 21, 2014 · 1199 hits

在输入数据时,输入完成后,我要隐藏键盘,下面是语句:
但是隐藏ios应用键盘需要点击return键,java中的return是保留字,输入就出错
导入包:import org.openqa.selenium.interactions.Actions;
语句如下:
Actions action = new Actions(driver);
action.sendKeys(Keys.return);
请问怎么隐藏ios应用的键盘,请大神帮忙,谢谢!

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 4 条回复 时间 点赞

hidekeyboard方法

#1楼 @qddegtya action调不出来hidekeyboard方法
action.sendKeys(Keys.RETURN);

#1楼 @qddegtya
我现在试了用Actions类来对键盘操作,好像根本行不通
键盘如下:

#3楼 @wangcityboy

def hide_keyboard(self, key_name=None, key=None, strategy=None):
"""Hides the software keyboard on the device. In iOS, use `key_name` to press
a particular key, or `strategy`. In Android, no parameters are used.

:Args:
- key_name - key to press
- strategy - strategy for closing the keyboard (e.g., `tapOutside`)
"""

data = {}
if key_name is not None:
data['keyName'] = key_name
elif key is not None:
data['key'] = key
else:
# defaults to `tapOutside` strategy
strategy = 'tapOutside'
data['strategy'] = strategy
self.execute(Command.HIDE_KEYBOARD, data)
return self

这个方法属于Driver实例,用driver实例去调,源码里面写的够清楚了

Hides the software keyboard on the device. In iOS, use key_name to press
a particular key, or strategy. In Android, no parameters are used.

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up