当前位置:网站首页>E regression test of this featured app
E regression test of this featured app
2022-06-11 07:52:00 【zljun8210】
2013 In E people E This is a regression automation test for the characteristic applications in the tablet , Automated scripts use Java Language writing . The code is as follows :
/*
* Copyright (C)2013 Ebensz Auto Test
*
* create by [email protected]
*
* V0.2(20131108): optimize and Refactoring code:With an array called;
* V0.1(20131105): create this program;
*
* Function:
* 1. connect wlan network;
* 2. set launage;
* 3. run apps;
* 4. screencap to sdcard;
*
*/
package com.ebensz.regressiontest;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class AppTest extends UiAutomatorTestCase
{
// set varilable
static String SSID = "QAC_TS";
static String PASSWORD = "8888888888";
static String[] LEFT_SCREEN_NAME = {"Camera","device","People","Messaging","EReader","Eben Security Guards",
"Gallery"};
static String[] MID_SCREEN_NAME = {"Handwriting suite","Calendar","HwOffice","Browser","HwMail"};
public void testDemo() throws UiObjectNotFoundException
{
// press home key
int i;
getUiDevice().pressHome();
wifiConnect();
deviceInfo();
for (i=0; i<=LEFT_SCREEN_NAME.length; i++)
{
leftMove();
startLaunchApk(LEFT_SCREEN_NAME[i]);
}
for (i=0; i<=MID_SCREEN_NAME.length; i++)
{
startLaunchApk(MID_SCREEN_NAME[i]);
}
startAllApp("EnoteWriter");
startAllApp("ThemeController");
}
private void wifiConnect() throws UiObjectNotFoundException
{
getUiDevice().pressHome();
// select all apps
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
// select all apps tab
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
// click all apps tab
appsTab.click();
// set screen display mode
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
// set horiz mode
// appViews.setAsHorizontalList();
if (allAppsButton.exists() && allAppsButton.isEnabled()) {
// allAppsButton not display,don't exec it
allAppsButton.click();
}
// find "settings" and click it
UiObject settingsApp = appViews.getChildByText(
new UiSelector().className(android.widget.TextView.class.getName()), "Settings");
settingsApp.clickAndWaitForNewWindow();
// verify Open screen is Settings
UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.android.settings"));
// if not exists,then print error message
assertTrue("Unable to detect Settings", settingsValidation.exists());
// click WLAN switch wifiOn
UiObject wifiText = new UiObject(new UiSelector().text("WLAN"));
wifiText.click();
getUiDevice().click(150,150);
sleep(2000);
UiObject wifiSsid = new UiObject(new UiSelector().text(SSID));
wifiSsid.click();
// set the SSID's password
UiObject passWord = new UiObject(new UiSelector().index(1).className("android.widget.EditText"));
passWord.setText(PASSWORD);
// connect the network
UiObject connBotton = new UiObject(new UiSelector().text("Connect"));
connBotton.click();
sleep(2000);
getUiDevice().pressHome();
}
private void deviceInfo() throws UiObjectNotFoundException
{
getUiDevice().pressHome();
// select all apps
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
// select all apps tab
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
// click all apps tab
appsTab.click();
// set screen display mode
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
// set horiz mode
// appViews.setAsHorizontalList();
if (allAppsButton.exists() && allAppsButton.isEnabled()) {
// allAppsButton not display,don't exec it
allAppsButton.click();
}
// find "settings" and click it
UiObject settingsApp = appViews.getChildByText(
new UiSelector().className(android.widget.TextView.class.getName()), "Settings");
settingsApp.clickAndWaitForNewWindow();
// verify Open screen is Settings
UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.android.settings"));
// if not exists,then print error message
assertTrue("Unable to detect Settings", settingsValidation.exists());
getUiDevice().swipe(100,900,100,200,2);
UiObject devicesInfo = new UiObject(new UiSelector().text("About phone"));
devicesInfo.click();
sleep(500);
Screencap("deviceInfo");
sleep(1000);
getUiDevice().pressHome();
}
private void startLaunchApk(String apks) throws UiObjectNotFoundException
{
// move to left home page
//leftMove();
UiObject apksButton = new UiObject(new UiSelector().text(apks));
apksButton.clickAndWaitForNewWindow();
Screencap(apks);
getUiDevice().pressBack();
getUiDevice().pressHome();
}
private void startAllApp(String apks) throws UiObjectNotFoundException
{
// run all apps page apk
// press home key
getUiDevice().pressHome();
// select all apps
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
// select all apps tab
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
// click all apps tab
appsTab.click();
// set screen display mode
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
// set horiz mode
// appViews.setAsHorizontalList();
if (allAppsButton.exists() && allAppsButton.isEnabled()) {
// allAppsButton not display,don't exec it
allAppsButton.click();
}
// find "settings" and click it
UiObject startApps = appViews.getChildByText(
new UiSelector().className(android.widget.TextView.class.getName()), apks);
startApps.clickAndWaitForNewWindow();
sleep(2000);
Screencap(apks);
getUiDevice().pressBack();
getUiDevice().pressHome();
}
private void leftMove() throws UiObjectNotFoundException
{
// press home key
getUiDevice().pressHome();
getUiDevice().pressHome();
sleep(1000);
getUiDevice().swipe(200,500,700,500,2);
sleep(1000);
}
private void Screencap(String apps) throws UiObjectNotFoundException
{
SimpleDateFormat idt = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
String SCREENCAP_PATH = "/sdcard/EAT/" + apps + "_" + idt.format(new Date());
File screen_path = new File(SCREENCAP_PATH + ".png");
sleep(1000);
getUiDevice().takeScreenshot(screen_path);
assertTrue("Screenshot file not detected in store", screen_path.exists());
sleep(1000);
}
}
边栏推荐
- 自定义ViewGroup的知识点总结-持续更新
- [software testing] 90% of the interviewers have been brushed out of such resumes
- 零基础自学SQL课程 | UNION 联合查询
- Summary of evaluation index knowledge points in target detection: summary of IOU cross overlap unit and map/ap/tp/fp/np
- forEach 中 return 和 for 中 break
- Sort - select sort
- Rabin Miller prime test
- Bladed入門教程(視頻)
- Request request object and response response object
- Switch statement
猜你喜欢

Figure seamless database integration tushare interface

Detailed explanation of shift operator and bit operator in C language

wordcloud的使用

After 4 years of naked resignation from the test, the test post of 15K interview was rubbed on the ground, and the result made me collapse and cry

2022.6.7 特长生模拟

Summary of evaluation index knowledge points in target detection: summary of IOU cross overlap unit and map/ap/tp/fp/np

C- print 99 multiplication table
![[codeforces1019e] raining season](/img/8e/4a96954ee7dae5f81eaae05b5a075b.png)
[codeforces1019e] raining season

Using Tkinter to realize guessing numbers game

二本畢業,銀行外包測試工作 4 個月有餘。聊聊一些真實感受 ...
随机推荐
[cluster] haproxy load balancing
JSP technology: JSP overview, JSP basic syntax, JSP instructions, JSP implicit objects, JSP action elements
The solution of "no startup device" after running Bochs
Xshell7 和 Xftp7要继续使用此程序,您必须应用最新的更新或者使用新版本
Modular linear equations (Chinese remainder theorem + general solution)
mpi
Classes and objects (medium)
Storage of floating point in memory
Rabin-Miller素数测试
Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)
multi-sig SC
运筹学导论
134. 加油站
Detailed explanation of character function and string function (including simulation implementation)
Implementation of queue (C language)
Note: JDBC
远程办公经验 | 社区征文
After 4 years of naked resignation from the test, the test post of 15K interview was rubbed on the ground, and the result made me collapse and cry
Wc2020 guessing game
2021-10-24