美文网首页
常用adb命令学习:查看和修改设备的输入法

常用adb命令学习:查看和修改设备的输入法

作者: R_zb | 来源:发表于2021-02-20 10:09 被阅读0次

在自动化测试过程中,有时可能会需要设置Android设备的输入法的场景时

如:运行了appium后,会自动切换到appium的输入法(io.appium.settings/.UnicodeIME),在之后的手动使用时,每次均需要去手机设置内调整输入法,较为麻烦,即可借助adb命令来实现自动化修改

如:使用airtest输入时,需切换到airtest输入法(com.netease.nie.yosemite/.ime.ImeService)

  • 获取设备当前使用的输入法

    adb shell settings get secure default_input_method
    
    # 会输出当前设备正在使用的输入法
    
  • 获取当前设备已安装的输入法

    # 会输出当前设备的全部输入法的详细信息
    adb shell ime list
    
    # 仅输出当前设备的全部输入法名称
    adb shell ime list -s
    
  • 修改当前设备的输入法

    方法一:
      adb shell ime set xxxxxx
    
        如:
            adb shell ime set io.appium.settings/.UnicodeIME  # 切换至appium UnicodeIME输入法
            adb shell ime set com.netease.nie.yosemite/.ime.ImeService    # 切换至airtest yosemite输入法
      
    方法二:
      adb shell settings put secure default_input_method  xxxxxx
        如:
            adb shell settings put secure default_input_method io.appium.settings/.UnicodeIME # 切换至appium UnicodeIME输入法
            adb shell settings put secure default_input_method com.netease.nie.yosemite/.ime.ImeService   # 切换至airtest yosemite输入法
    
  • Python + airtest 的使用示例

    def setting_writing_type(self, var):
        """
        设置设备的输入法
        :param var: sou_gou, appium, air_test
        """
        writing = {
        'sou_gou': 'com.sohu.inputmethod.sogou.xiaomi/.SogouIME',
        'appium': 'io.appium.settings/.UnicodeIME',
        'air_test': 'com.netease.nie.yosemite/.ime.ImeService'
        }
    
        shell(f'settings put secure default_input_method {writing[var]}')
        
    
    # 使用示例
    
    # 设置输入法为yosemite
    self.setting_writing_type('air_test')
    """
    完成输入行为,完成测试
    """
    # 修改为默认搜狗输入法
    self.setting_writing_type('sou_gou')
    

相关文章

  • 常用adb命令学习:查看和修改设备的输入法

    在自动化测试过程中,有时可能会需要设置Android设备的输入法的场景时 如:运行了appium后,会自动切换到a...

  • 常见的adb 和 mankey 命令

    一、常用adb命令 1、adb devices:查看已连接的设备 2、adb version:查看adb的版本序列...

  • adb 常用命令详解

    如下解释下ADB常用的几个命令 1 查看设备 adb devices 这个命令是查看当前连接的设备, 连接到计算机...

  • adb,logcat使用及对Android设备的操作

    adb,logcat使用及对Android设备的操作 adb常用命令 查看连接到本机的所有的设备命令:adb de...

  • android 简记

    adb常用命令 查看设备信息:adb shell dumpsys display | findstr Displa...

  • 常用 adb 命令

    常用 adb 命令,不断更新 adb devices 查看连接电脑的手机设备 adb install xxx.a...

  • Appium学习13-adb常用命令补充

    Appium学习笔记目录 本文包含内容: adb常用命令 1. 查看当前PC端连接有多少设备adb devices...

  • adb命令详解

    以下是我工作中总结出来的常用的adb命令: 1.adb devices 查看连接的设备 2.adb help 查看...

  • adb常用命令

    ADB常用命令 adb connect+ip 远程连接Android设备 adb devices 获取设备列表和设...

  • monkey稳定性

    adb shell的一些命令: adb devices查看连上的设备 adb shell进入到设备shell命令 ...

网友评论

      本文标题:常用adb命令学习:查看和修改设备的输入法

      本文链接:https://www.haomeiwen.com/subject/juwaxltx.html