记java实现验证toast的方法
此方法可用于验证手机端toast内容
/** * 判断toast是否出现 * by the2ndindec * @param toast toast内容 */ public static void isToastExist(String toast) { String verityStr = "Assert验证toast内容{" + toast + "}是否出现"; log.info(verityStr); try { final WebDriverWait wait = new WebDriverWait(driver, 5); Assert.assertNotNull(wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[contains" + "(@text,'" + toast + "')]")))); log.info("查找toast成功!"); assertPassLog(); ASSERT_INFOL_LIST.add(verityStr + ":pass"); } catch (Exception e) { assertFailedLog(); errorIndex++; Assertion.snapshotInfo(); throw new AssertionError("找不到" + toast); } }


浙公网安备 33010602011771号