Android_uiautomator支持输入中文
2015-11-03 20:08
387 查看
一、安装输入法:
1,去utf7ime的 github上把整个项目给下载下来,地址:https://github.com/sumio/uiautomator-unicode-input-helper
点击"Download ZIP"按钮进行 打包下载,如图:
2,下载完成 以后解压到本地磁盘的任意位置比如C:\uiautomator-unicode-input-helper-master
3,打开Eclipse(安装了adt,并且配置好sdk home in eclispe不然不能打包)
4,点击File->Import ->Existing Android Code Into Workspace->Next->点击Browser 选择uiautomator-unicode-input-helper-master\Utf7Ime文件夹>点击Done,这个提示发现不了project,请从别的android项目中复制根目录下的配置文件过来就ok了(配置文件.classpath .project proguard.cfg project.properties)
5,导入成功后,安装IME(input method Editor)到手机中;
6,设置-语言及输入法-在设置里面将本机的默认输入法设置成:UTF7 IME for UI Testing,同时取消第三方的输入法(如果你安装了);二、在测试工程中加入对应的代码1.将uiautomator-unicode-input-helper-master\helper-library 目录下的src拷贝到测试项目中2.可使用sample中代码做测试,如下:
[java] view plaincopypublic class UiAutomatorInputTest extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
// Press on the HOME button.
getUiDevice().pressHome();
// Launch the "Google" apps via the All Apps screen.
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
appsTab.click();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
UiObject testApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),
"Google");
testApp.clickAndWaitForNewWindow();
// Get the google search text box
UiObject searchBox = new UiObject(
new UiSelector().className("com.google.android.search.shared.ui.SimpleSearchText"));
// do Japanese Input!
searchBox.setText(Utf7ImeHelper.e("こんにちは!UiAutomatorで入力しています。"));
}
}
1,去utf7ime的 github上把整个项目给下载下来,地址:https://github.com/sumio/uiautomator-unicode-input-helper
点击"Download ZIP"按钮进行 打包下载,如图:
2,下载完成 以后解压到本地磁盘的任意位置比如C:\uiautomator-unicode-input-helper-master
3,打开Eclipse(安装了adt,并且配置好sdk home in eclispe不然不能打包)
4,点击File->Import ->Existing Android Code Into Workspace->Next->点击Browser 选择uiautomator-unicode-input-helper-master\Utf7Ime文件夹>点击Done,这个提示发现不了project,请从别的android项目中复制根目录下的配置文件过来就ok了(配置文件.classpath .project proguard.cfg project.properties)
5,导入成功后,安装IME(input method Editor)到手机中;
6,设置-语言及输入法-在设置里面将本机的默认输入法设置成:UTF7 IME for UI Testing,同时取消第三方的输入法(如果你安装了);二、在测试工程中加入对应的代码1.将uiautomator-unicode-input-helper-master\helper-library 目录下的src拷贝到测试项目中2.可使用sample中代码做测试,如下:
[java] view plaincopypublic class UiAutomatorInputTest extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
// Press on the HOME button.
getUiDevice().pressHome();
// Launch the "Google" apps via the All Apps screen.
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
appsTab.click();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
UiObject testApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),
"Google");
testApp.clickAndWaitForNewWindow();
// Get the google search text box
UiObject searchBox = new UiObject(
new UiSelector().className("com.google.android.search.shared.ui.SimpleSearchText"));
// do Japanese Input!
searchBox.setText(Utf7ImeHelper.e("こんにちは!UiAutomatorで入力しています。"));
}
}
相关文章推荐
- getRequestDispatcher()与sendRedirect()的区别
- [LeetCode] Longest Increasing Subsequence
- 利用insert,update和delete注入获取数据
- lock_guard和unique_lock的区别
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel (规律)
- android中子线程更新UI的方式浅析
- iOS(9) SDWebImage 里面给 UIImageView 加载图片的逻辑是什么样的
- Kqueue 实现非阻塞 Socket 通信
- HDU 5531 Rebuild
- Android Bluetooth Low Energy(Android低功耗蓝牙)
- Arduino小车学习与研究博客
- protocol isis issues(续1.2----地址转化相关)
- [转]runOnUiThread 、 Handler 对比(一)
- Source Code Tags and Builds
- USB core(一) - rh_queue_status与rh_call_control
- Deploy .Net project automatically with MsBuild and MsDeploy (0)
- uitableview使用优化
- View requires API level 14 (current min is 8)
- View requires API level 14 (current min is 8)
- EasyUI DataGrid 应用示例