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

云飞凌风 · 2014年08月21日 · 最后由 Archer 回复于 2014年08月21日 · 1706 次阅读

在输入数据时,输入完成后,我要隐藏键盘,下面是语句:
但是隐藏 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.

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册