io.appium
java-client
4.1.2
org.seleniumhq.selenium
selenium-server-standalone
2.53.0
org.seleniumhq.selenium
selenium-java
2.53.1
上jar包
pojo类
package com.ssm.pojo;
import org.openqa.selenium.WebElement;
import io.appium.java_client.android.AndroidDriver;
public class Appview {
private String code;
private String resourceid;
private String classname;
private String textname;
private String content;
private String apkname;
private String bundleid;
private String devicename;
private String platformversion;
private Integer num;
private Integer during;
private Integer spacing;
private AndroidDriver driver;
private Integer id;
private String home;
private String name;
private String url;
private String text;
private String strdirpath;
private String parentresourceid;
private String sonresourceid;
}
自己生成get set吧
Controller层
package com.ssm.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ssm.common.ExcelUtils;
import com.ssm.pojo.Appview;
import com.ssm.service.AppiumAutoTextService;
@Controller
@RequestMapping("/appAutoText")
public class AppiumAutoTextController {
@Autowired
private AppiumAutoTextService appiumAutoTextService;
/**
* 解析Excel文件
*
* @param inpStartfile
* @param request
* @return
*/
@RequestMapping("/appAutoTextFileAnalysis")
@ResponseBody
public String appAutoTextFileAnalysis(MultipartFile inpStartfile, HttpServletRequest request) {
// 获取Web项目的全路径
String strDirPath = request.getSession().getServletContext().getRealPath("/");
List
package com.ssm.service.impl;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.gson.Gson;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.rtf.RtfWriter2;
import com.ssm.mapper.AppiumAutoTextMapper;
import com.ssm.pojo.Appview;
import com.ssm.service.AppiumAutoTextService;
import io.appium.java_client.android.AndroidDriver;
@Service
public class AppiumAutoTextServiceImpl implements AppiumAutoTextService {
@Autowired
private AppiumAutoTextMapper appiumAutoTextMapper;
@Override
public String appAutoTextPythonAnalysis(String pyPath, String strDirPath) {
Process proc = null;
InputStreamReader stdin = null;
LineNumberReader input = null;
try {
String command = "python " + pyPath;
String[] split = pyPath.split("\\");
String fileName = split[split.length - 1];
proc = Runtime.getRuntime().exec(command); // 执行py文件
stdin = new InputStreamReader(proc.getInputStream());
input = new LineNumberReader(stdin);
String line;
Gson gson = new Gson();
List excelForList = new ArrayList<>();
while ((line = input.readLine()) != null) {
excelForList.add(gson.fromJson(line, Appview.class));
}
if (excelForList == null || excelForList.size() == 0) {
return "1";
}
XiaoyaAppTextServiceImpl appTextService = new XiaoyaAppTextServiceImpl();
// 第一行加载驱动
Appview app = (Appview) excelForList.get(0);
if (driver == null) {
return "1";
}
for (int i = 1; i < excelForList.size(); i++) {
Appview appv = (Appview) excelForList.get(i);
// 按文件中的code查询数据库
Appview appview = appiumAutoTextMapper.getAppviewByCode(appv.getCode());
// 把参数加入对象
appview.setDriver(driver);
appview.setStrdirpath(strDirPath);
if (appv.getClassname() != null && !"".equals(appv.getClassname())) {
appview.setClassname(appv.getClassname());
}
if (appv.getResourceid() != null && !"".equals(appv.getResourceid())) {
appview.setResourceid(appv.getResourceid());
}
if (appv.getTextname() != null && !"".equals(appv.getTextname())) {
appview.setTextname(appv.getTextname());
}
if (appv.getContent() != null && !"".equals(appv.getContent())) {
if (appv.getContent().contains("#")) {
appview.setContent(appv.getContent().replace("#", ""));
} else
appview.setContent(appv.getContent());
}
if (appv.getApkname() != null && !"".equals(appv.getApkname())) {
appview.setApkname(appv.getApkname());
}
if (appv.getDevicename() != null && !"".equals(appv.getDevicename())) {
appview.setDevicename(appv.getDevicename());
}
if (appv.getBundleid() != null && !"".equals(appv.getBundleid())) {
appview.setBundleid(appv.getBundleid());
}
if (appv.getDuring() != null && appv.getDuring() > 0) {
appview.setDuring(appv.getDuring());
}
if (appv.getNum() != null && appv.getNum() > 0) {
appview.setNum(appv.getNum());
}
if (appv.getSpacing() != null && appv.getSpacing() > 0) {
appview.setSpacing(appv.getSpacing());
}
System.out.println("getCode=== " + appview.getCode());
// 开始调用方法
String imgPath = methodInvocation(appTextService, appview);
}
return "0";
} catch (Exception e) {
e.printStackTrace();
return "1";
} finally {
try {
if (proc != null) {
proc.destroy();
}
if (input != null) {
input.close();
}
if (stdin != null) {
stdin.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public String appAutoTextFileAnalysis(List
具体方法的封装
package com.ssm.service.impl;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.springframework.stereotype.Service;
import com.ssm.pojo.Appview;
import com.ssm.service.XiaoyaAppTextService;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
@Service
public class XiaoyaAppTextServiceImpl implements XiaoyaAppTextService {
@Override
public AndroidDriver setUp(Appview appview) {
AndroidDriver driver;
try {
String serverURL = "http://127.0.0.1:4723/wd/hub";// appium测试服务的地址
// 新建一个DesiredCapabilities对象,是importorg.openqa.selenium.remote.DesiredCapabilities;作者个人赶脚是用来收集驱动初始化信息用的;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); // 指定浏览器的名字,我们测试的是APK所以没有浏览器,故而为空;
capabilities.setCapability("platformName", "Android"); // 指定平台,为安卓
capabilities.setCapability("deviceName", appview.getDevicename()); // 指定设备,"621QACQC38Z5K"这个属性作者认为是“安卓设备即可”
capabilities.setCapability("platformVersion", appview.getPlatformversion()); // 指定版本,作者的模拟器是4.4.2的
File classpathRoot = new File(appview.getStrdirpath());// 获得项目路径
File appDir = new File(classpathRoot, "apps");// 获得APK所在文件夹名称
File app = new File(appDir, appview.getApkname());// 获得APK文件
capabilities.setCapability("app", app.getAbsolutePath()); // 指定需要测试的APK,也就是需要安装的APK文件;
capabilities.setCapability("autoLaunch", "false"); // Appium是否需要自动安装和启动应用。
// support Chinese
capabilities.setCapability("unicodeKeyboard", "True");
capabilities.setCapability("resetKeyboard", "True");
// no need sign
capabilities.setCapability("noSign", "True");
// 核心关键步骤,创建驱动,指定服务地址,和初始化信息;
driver = new AndroidDriver(new URL(serverURL), capabilities);
return driver;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
@Override
public void appInstall(Appview appview) {
// apkName = "小雅APP_v1.4.8.apk"; // 安卓的安装包,被测软件
// bundleId = "com.orion.xiaoya.speakerclient";// 对应app的应用包
if (appview.getDriver().isAppInstalled(appview.getBundleid())) {
// 从设备中删除一个应用
appview.getDriver().removeApp(appview.getBundleid());
}
// java 安装应用到设备中去
appview.getDriver().installApp(
new File(appview.getStrdirpath(), File.separator + "apps" + File.separator + appview.getApkname())
.getAbsolutePath());
}
@Override
public void removeApp(Appview appview) {
if (appview.getDriver().isAppInstalled(appview.getBundleid())) {
// 从设备中删除一个应用
appview.getDriver().removeApp(appview.getBundleid());
}
}
@Override
public void launchApp(Appview appview) {
appview.getDriver().launchApp();
}
@Override
public void closeApp(Appview appview) {
appview.getDriver().closeApp();
}
@Override
public void forward(Appview appview) {
appview.getDriver().navigate().forward();
}
@Override
public void back(Appview appview) {
appview.getDriver().navigate().back();
}
@Override
public void swipeToUp(Appview appview) {
int width = appview.getDriver().manage().window().getSize().width;
int height = appview.getDriver().manage().window().getSize().height;
for (int i = 0; i < appview.getNum(); i++) {
appview.getDriver().swipe(width / 2, height * 3 / 4, width / 2, height / 4, appview.getDuring());
}
try {
Thread.sleep(appview.getSpacing() * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void swipeToDown(Appview appview) {
int width = appview.getDriver().manage().window().getSize().width;
int height = appview.getDriver().manage().window().getSize().height;
// System.out.println(width);
// System.out.println(height);
for (int i = 0; i < appview.getNum(); i++) {
appview.getDriver().swipe(width / 2, height / 4, width / 2, height * 3 / 4, appview.getDuring());
}
try {
Thread.sleep(appview.getSpacing() * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void swipeToLeft(Appview appview) {
// System.out.println(during);
int width = appview.getDriver().manage().window().getSize().width;
int height = appview.getDriver().manage().window().getSize().height;
for (int i = 0; i < appview.getNum(); i++) {
appview.getDriver().swipe(width * 3 / 4, height / 2, width / 4, height / 2, appview.getDuring());
}
try {
Thread.sleep(appview.getSpacing() * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void swipeToRight(Appview appview) {
int width = appview.getDriver().manage().window().getSize().width;
int height = appview.getDriver().manage().window().getSize().height;
for (int i = 0; i < appview.getNum(); i++) {
appview.getDriver().swipe(width / 4, height / 2, width * 3 / 4, height / 2, appview.getDuring());
}
try {
Thread.sleep(appview.getSpacing() * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void lockDevice(Appview appview) {
appview.getDriver().lockDevice();
}
// @Override
// public void pressKeyCode(Appview appview) {
// appview.getDriver().pressKeyCode(Integer.parseInt(appview.getKey()));
// }
@Override
public String takeScreenShot(Appview appview) {
String path = "C:\\eclipse-oriontest\\TestProject" + File.separator
+ new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date()) + ".jpg";
try {
// 获取screenshot文件
File screenShot = appview.getDriver().getScreenshotAs(OutputType.FILE);
// 文件copy到指定的文件夹
FileUtils.copyFile(screenShot, new File(path));
} catch (WebDriverException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return path;
}
@Override
public void homeLoginButtonClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void homeBtnRegisterClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void impowerBtnSsoAuthorizeClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void greetViewGuide1Click(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void greetViewGuide2Click(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void navigationTvContentClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void navigationTvMeClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void navigationTvSessionClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void navigationTvSkillClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public String getMessageByNewestQuery(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public void messageNewestQueryClick(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getResourceid());
findElements.get(findElements.size() - 1).click();
}
@Override
public String getMessageByNewestOtherWeatherAir(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestOtherWeatherDate(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestOtherWeatherWendu(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestTodayWeatherWenduAir(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestTodayWeatherWenduCur(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestTodayWeatherWenduMinMax(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestTodayWeatherAirPm(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
WebElement findElement = findElements.get(findElements.size() - 1)
.findElement(By.id(appview.getSonresourceid()));
return findElement.findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestTodayWeatherAirStatus(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
WebElement findElement = findElements.get(findElements.size() - 1)
.findElement(By.id(appview.getSonresourceid()));
return findElement.findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestClockDate(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public void messageNewestAlarmSettingClick(Appview appview) {
appview.getDriver().findElementsById(appview.getResourceid()).get(appview.getNum()).click();
}
@Override
public String getMessageByNewestClockTime(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestPayCount(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestPayMoney(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public String getMessageByNewestPayTitle(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getParentresourceid());
return findElements.get(findElements.size() - 1).findElement(By.id(appview.getResourceid())).getText();
}
@Override
public void messageNewestPayNowBtnClick(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getResourceid());
findElements.get(findElements.size() - 1).click();
}
@Override
public String getMessageByNewestTTS(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getResourceid());
return findElements.get(findElements.size() - 1).getText();
}
@Override
public String getMessageByNewestVoiceDesc(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getResourceid());
return findElements.get(findElements.size() - 1).getText();
}
@Override
public String getMessageByNewestVoiceTitle(Appview appview) {
List findElements = (List) appview.getDriver()
.findElementsById(appview.getResourceid());
return findElements.get(findElements.size() - 1).getText();
}
@Override
public void messageTvRightClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandClick(Appview appview) {
List findElementsByClassName = (List) appview.getDriver()
.findElementsByClassName(appview.getClassname());
findElementsByClassName.get(1).click();
}
@Override
public void skillAICommandAddClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandShowClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void skillAICommandSettingWordSendKeys(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).sendKeys(appview.getContent());
}
@Override
public void skillAICommandLayoutPlayMusicClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandLayoutPlayProgramClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandLayoutPlayRadioClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandNextStepClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandLayoutXiaoyaSayClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandXiaoyaSayWordSendKeys(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).sendKeys(appview.getContent());
}
@Override
public void skillAICommandGenerateClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void skillAICommandAccomplishClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meTvRightClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewAccountsAlarmClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewAccountsEquipmentClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewAccountsFavoritesClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewAccountsHelpClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewAddDeviceClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewContactUsClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewFeedbackClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewLogoutClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meViewVoxSettingClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meCollectTabTitleChants(Appview appview) {
appview.getDriver().findElementById(appview.getParentresourceid())
.findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meCollectTabTitleMusic(Appview appview) {
appview.getDriver().findElementById(appview.getParentresourceid())
.findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meCollectTabTitleProgram(Appview appview) {
appview.getDriver().findElementById(appview.getParentresourceid())
.findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meCollectTabTitleChantsAction(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meCollectTabTitleChantsChoice(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meCollectTabTitleChantsCancel(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meCollectTabTitleChantsChoose(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meCollectTabTitleChantsRemove(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmBtnAddClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmSeetingRingClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmTextSaveClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmTvRightClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmTypeLayoutClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmRingBroadcastingClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRingScripturesClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRingTextSavesClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmRepetitionFridayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionMondayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionSaturdayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionSundayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionThursdayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionTuesdayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionWednesdayClick(Appview appview) {
appview.getDriver().findElement(By.xpath("//*[contains(@text,'" + appview.getTextname() + "')]")).click();
}
@Override
public void meAlarmRepetitionCancelButtonClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmRepetitionTimeOkbuttonClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meAlarmChoiceClick(Appview appview) {
appview.getDriver().findElementsById(appview.getResourceid()).get(appview.getNum()).click();
}
@Override
public void meSmartHomeBtRetry(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpAwakenHelpClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpBlueHelpClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpCallLayoutClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpDeviceIntroClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpStartClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpTvNlpClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meHelpTvWifiClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meSpitslotTvRightClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meSpitslotConnectionSendKeys(Appview appview) {
appview.getDriver().findElementsByClassName(appview.getClassname()).get(1).sendKeys(appview.getContent());
}
@Override
public void meSpitslotProblemSendKeys(Appview appview) {
appview.getDriver().findElementsByClassName(appview.getClassname()).get(0).sendKeys(appview.getContent());
}
@Override
public void meSpitslotBluetoothNotEvenClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meSpitslotDiscernErrorClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meSpitslotDrunkClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meSpitslotMissWakeUpClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meSpitslotNetworkNoGoodClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meSpitslotTvSubmitClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meSpitslotTvSubmitAscertainClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meContactBtnSaveClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meContactIvQcodeClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
// @Override
// public void meContactLogoClick(Appview appview) {
// WebElement findElementById =
// appview.getDriver().findElementById(appview.getResourceid());
// for (int i = 0; i < 10; i++) {
// findElementById.click();
// }
// }
@Override
public void meContactQcodeSubTitleClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meContactViewTelClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meContactViewWeiboClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void meContactSwitchoverOfficialClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meContactSwitchoverProbationClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meViewLogoutCancelClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void meViewLogoutExitClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void PhysicalButtonsCALL(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_CALL);
}
@Override
public void PhysicalButtonsBACK(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_BACK);
}
@Override
public void PhysicalButtonsENDCALL(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_ENDCALL);
}
@Override
public void PhysicalButtonsHome(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_HOME);
}
@Override
public void PhysicalButtonsMENU(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_MENU);
}
@Override
public void PhysicalButtonsPOWER(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_POWER);
}
@Override
public void PhysicalButtonsVOLUMEDOWN(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_VOLUME_DOWN);
}
@Override
public void PhysicalButtonsVOLUMEUP(Appview appview) {
appview.getDriver().pressKeyCode(AndroidKeyCode.KEYCODE_VOLUME_UP);
}
@Override
public void findElementByXPathClick(Appview appview) {
appview.getDriver().findElementByXPath("//*[contains(@text,'" + appview.getTextname() + "')]").click();
}
@Override
public void findElementsByXPathClick(Appview appview) {
appview.getDriver().findElementsByXPath("//*[contains(@text,'" + appview.getTextname() + "')]")
.get(appview.getNum()).click();
}
@Override
public void findElementByIdClick(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).click();
}
@Override
public void findElementByIdSendKeys(Appview appview) {
appview.getDriver().findElementById(appview.getResourceid()).sendKeys(appview.getContent());
}
@Override
public void findElementsByIdClick(Appview appview) {
appview.getDriver().findElementsById(appview.getResourceid()).get(appview.getNum()).click();
}
@Override
public void findElementsByIdSendKeys(Appview appview) {
appview.getDriver().findElementsById(appview.getResourceid()).get(appview.getNum())
.sendKeys(appview.getContent());
}
@Override
public void findElementByClassNameClick(Appview appview) {
appview.getDriver().findElementByClassName(appview.getResourceid()).click();
}
@Override
public void findElementByClassNameSendKeys(Appview appview) {
appview.getDriver().findElementByClassName(appview.getResourceid()).sendKeys(appview.getContent());
}
@Override
public void findElementsByClassNameClick(Appview appview) {
appview.getDriver().findElementsByClassName(appview.getResourceid()).get(appview.getNum()).click();
}
@Override
public void findElementsByClassNameSendKeys(Appview appview) {
appview.getDriver().findElementsByClassName(appview.getResourceid()).get(appview.getNum())
.sendKeys(appview.getContent());
}
@Override
public void threadSleep(Appview appview) {
try {
Thread.sleep(appview.getSpacing() * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
方法封装的比较死,只是一个思路,自己看着改吧。。
Excel的格式
使用adb shell dumpsys window | findstr mCurrentFocus 命令查看当前运行的包名和Activity