记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);
        }
    }

 

 

 

posted @ 2019-07-12 11:37  Lozz  阅读(277)  评论(0)    收藏  举报