[android]uiautomator中文輸入解決方案
UiAutomator不支援中文輸入。
通過設定中文輸入法為預設,UiObject.setText("pinyin ") 的方式,可以實現中文輸入,但是隻能輸入一些固定的片語。
github上發現了一個 utf7ime 的好東西,可以實現中文輸入,英文輸入,中英文混合輸入。簡單來說,支援輸入任何unicode編碼的字元。
原理是:UiObject.setText( String) 只能接受ASCII碼,整個過程是輸入的unicode編碼的字串decode成ASCIl碼,setText接受這些ASCll碼再通過utf7ime這個輸入法encode成unicode編碼的字串輸出。
前置條件:手機裝入此輸入法並將之設為預設輸入法
簡單說一說整個過程,
打包下載 https://github.com/sumio/uiautomator-unicode-input-helper
匯入其中的Utf7Ime , 生成apk並安裝設定成預設輸入法
把 helper-library 裡面的Utf7ImeHelper.java匯入自己的公用方法庫,用於把字串decode成ASCII碼
最後生成指令碼是這樣的:
下一步考慮如何將這個功能整合到指令碼錄製工具中去。
文章轉載於:http://testerhome.com/topics/408
有空驗證的同學,驗證完後記得在部落格上留言驗證結果。
通過設定中文輸入法為預設,UiObject.setText("pinyin ") 的方式,可以實現中文輸入,但是隻能輸入一些固定的片語。
github上發現了一個 utf7ime 的好東西,可以實現中文輸入,英文輸入,中英文混合輸入。簡單來說,支援輸入任何unicode編碼的字元。
原理是:UiObject.setText( String) 只能接受ASCII碼,整個過程是輸入的unicode編碼的字串decode成ASCIl碼,setText接受這些ASCll碼再通過utf7ime這個輸入法encode成unicode編碼的字串輸出。
前置條件:手機裝入此輸入法並將之設為預設輸入法
簡單說一說整個過程,
打包下載 https://github.com/sumio/uiautomator-unicode-input-helper
匯入其中的Utf7Ime , 生成apk並安裝設定成預設輸入法
把 helper-library 裡面的Utf7ImeHelper.java匯入自己的公用方法庫,用於把字串decode成ASCII碼
最後生成指令碼是這樣的:
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.sn.test.testUtil.AppAPI;
import com.sn.test.testUtil.Utf7ImeHelper;
public class TestInput extends UiAutomatorTestCase {
private String caseName = this.getClass().getSimpleName();
private String caseDetail = "";
private String description = "";
private boolean result = false;
protected void setUp() throws Exception {
super.setUp();
AppAPI.setUp(caseName);
}
public void testDemo() throws UiObjectNotFoundException, RemoteException {
new UiObject(new UiSelector().className("android.widget.TextView")
.text("資訊")).clickAndWaitForNewWindow();
sleep(1000);
new UiObject(new UiSelector().className("android.widget.RadioButton")
.text("新資訊")).clickAndWaitForNewWindow();
sleep(1000);
new UiObject(new UiSelector().className("android.widget.EditText"))
.setText(Utf7ImeHelper.e("test test yingwen 中文一起輸入"));
sleep(1000);
下一步考慮如何將這個功能整合到指令碼錄製工具中去。
文章轉載於:http://testerhome.com/topics/408
有空驗證的同學,驗證完後記得在部落格上留言驗證結果。
相關文章
- Android輸入鍵盤隱藏解決方案Android
- Android多個EditText輸入效果解決方案Android
- Ubuntu 版本的 Sublime 升級後無法輸入中文解決方案Ubuntu
- fcitx(小企鵝中文輸入法)在GNOME中無法顯示輸入框但可以輸入中文的問題解決方案
- oracle 輸出中文亂碼問題解決方案Oracle
- 解決 React 中的 input 輸入框在中文輸入法下的 bugReact
- Unity3D Android鍵盤輸入內容為白色解決方案Unity3DAndroid
- 解決Ubuntu 18.04中文輸入法的問題Ubuntu
- 解決ubuntu下sublime無法輸入中文問題Ubuntu
- 頁面無法輸入多個空格解決方案
- Ubuntu下解決Eclipse無法輸入中文問題UbuntuEclipse
- win10系統下中文輸入法無法輸入中文如何解決Win10
- 5、中文的輸出(GBK不可對映字元的解決方案)字元
- jive中文問題解決方案
- 解決 Intellij IDEA 中文輸入法不跟隨游標IntelliJIdea
- Win10提示已禁用IME輸入不了中文解決方法Win10
- windows XP CMD中無法輸入中文的解決辦法Windows
- 輸入框軟鍵盤遮擋問題解決方案
- EditText輸入框自動頂上去2種解決方案
- 【Android Studio】解決 Android Studio2.2 無法輸入中文標點符號的問題Android符號
- Win10電腦搜狗輸入法無法輸入中文及輸入法欄不見了的解決方法Win10
- win10網頁無法輸入中文怎麼解決_win10網頁不能輸入中文怎麼辦Win10網頁
- react輸入框輸入中文bugReact
- Android輸入事件詳解Android事件
- 怎麼解決Ubuntu中spyder不能輸入中文的問題阿Ubuntu
- Linux Mint下Qt Creator無法輸入中文解決辦法LinuxQT
- SOLIDWORKS交通運輸解決方案Solid
- android 軟鍵盤 輸入法 彈出引起的各種不適終極解決方案Android
- cmd 命令列模式下輸出中文時顯示亂碼的解決方案命令列模式
- Android 介面滑動卡頓分析與解決方案(入門)Android
- MySql中表單輸入資料出現中文亂碼的解決方法MySql
- win10系統下Cortana無法輸入中文怎麼解決Win10
- win10中文輸入法只能輸入英文怎麼解決 win10微軟輸入法打不出漢字修復方法Win10微軟
- 由使用者輸入系列對稱的點的解決方案
- manjaro中文輸入法JAR
- mysql 插入中文亂碼解決方案 轉MySql
- Android測試工具 UIAutomator入門與介紹AndroidUI
- android自動化測試_uiautomator方案實現要點AndroidUI