/** 返回至首页。 */ @Override public void backToHomePage(String[] contents) { int times = 0; while (!waitForText(5, contents)) { if (times >= 30) { Log.logInfo("尝试多次未能返回到首页,终止操作!"); break; } Log.logInfo("点击返回按钮"); driver.pressKeyCode(AndroidKeyCode.BACK); sendKeyEvent(AndroidKeyCode.BACK, "点击返回按钮"); times++; } }
/** * override original method 按下指定的键,在原生方法执行时添加日志。 * * @param keyEvent the element to be found. * @param LogText input log text. */ public void sendKeyEvent(int keyEvent, String LogText) { Log.logStep("[" + LogText + "] "); Log.logInfo("[" + LogText + "] "); driver.pressKeyCode(keyEvent); }