//方法中只允许传xpath,只要稍作修改就可以以其他的定位方式来操作 public static boolean waitForWebView(String xpath) { long endtime_2 = SystemClock.uptimeMillis() + 10000; do { try { Web.onWebView().forceJavascriptEnabled(); Web.onWebView().withElement(DriverAtoms.findElement(Locator.XPATH, xpath)); return true; } catch (Throwable e) { if (!e.getMessage().equals("java.lang.RuntimeException: Atom evaluation returned null!")) { throw new RuntimeException("Util.waitForWebView()抛出异常:" + e.getMessage()); } } if (SystemClock.uptimeMillis() > endtime_2) { return false; } } while (true); }