//获取方法名
log.debug("Method start:" + Thread.currentThread().getStackTrace()[1].getMethodName());
//找元素
WebElement el = driver.findElement(By.xpath("android.widget.TextView[@text='登录']"));
20170109更新:
log4j:
log4j.rootLogger = debug,D,E
log4j.logger.zhou = debug,stdout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{HH:mm:ss} - %-10m - %l %n
Appium:
//基类:
public void setup(){
log.debug(Thread.currentThread() .getStackTrace()[1].getMethodName() + ": start!");
this.defaultConfig();
this.config();
this.initDriver();
log.debug(Thread.currentThread() .getStackTrace()[1].getMethodName() + ": finish!");
}
public void config(){
log.info("Using default configs!");
}
//子类:
@Override
public void config(){
log.debug("ETCTEST.config()!");
setCapabilities("appPackage", "package");
setCapabilities("appActivity", ".activity");
//查找元素:
driver.findElementByXPath("//android.widget.TextView[contains(@text,'中文')]")