Is there a way I can hide Soft Keyboar or Virtual Keyboard on Chrome on Android using Selenium or ChromeOptions or ADB. I did some searching but all solution were like if the keyboard is open then press back button to hide it. But is there a way to disable virtual keyboard from poping up during my entire execution.
So I found a way to disable and enable keybords using adb shell ime
commands. I wrote a Python script to enable/disable all keyboard inputs.
def enable_disable_android_input_methods(action):
p = subprocess.Popen(["adb", "devices"], stdout=subprocess.PIPE)
line = p.stdout.readline()
while line:
log.info(line)
if re.match("\S+\s+device", line):
break
line = p.stdout.readline()
else:
raise AssertionError, "Device not connected via USB"
p = subprocess.Popen("adb shell ime list -a".split(), stdout=subprocess.PIPE)
line = p.stdout.readline()
while line:
m = re.search("mId=(.*)", line)
if m:
if action.lower() == 'enable':
log.info("Enabling Keyboard layout: %s" % line)
cmd = "adb shell ime enable %s" % m.group(1)
else:
log.info("Disabling Keyboard layout: %s" % line)
cmd = "adb shell ime disable %s" % m.group(1)
q = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
out, err = q.communicate()
log.info(out)
line = p.stdout.readline()