問題
使用Appium進(jìn)行Android測試時(shí),使用send_keys()發(fā)送中文匙铡,輸入框沒有輸入任何文本
1. 解決辦法
使用Appium鍵盤,appium執(zhí)行時(shí),會在Android手機(jī)安裝一個特殊鍵盤(即Appium Android lnput Manager for Unicode)
在Appum config中增加下列代碼:
'unicodeKeyboard':True,
'resetKeyboard':True
解釋:
- 使用unicode的編碼方式發(fā)送字符
- Unicode鍵盤并非虛擬鍵盤拧咳,在界面上不會顯示出來
2. 說明
Android tests allow for Unicode input by installing and using a specialized keyboard
that allows the text to be passed as ASCII text between Appium and the application
being tested.
In order to utilize this functionality, set the unicodeKeyboard desired capability is
set to true. If the keyboard should be returned to its original state, the resetKeyboard
desired capability should also be set to true. Otherwise Appium’s Unicode keyboard will
remain enabled on the device after the tests are completed.
Then tests can pass Unicode text to editable fields using send_keys
本文作者原創(chuàng)伯顶,禁止轉(zhuǎn)載。