By byText = MobileBy.AndroidUIAutomator("new UiSelector().text(\"" + elementText + "\")"); WebElement element = driver.findElement(byText); element.click(); if (driver.getPageSource().contains("خرید")) { LOGGER.info("PASS"); } else { LOGGER.error("Test failed "); Assert.fail("Test failed "); } } //////////////////// WebElement element2 = driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().text(\"امکان فعالسازی همزمان دو بسته وجود ندارد.\")")); //////////////////// WebElement element4 = driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().text(\"خرید مودم\")")); ///////////////// public static void verifySnackbarText(WebDriver driver, String expectedText) { String snackbarText = driver.findElement(By.id("ir.mci.ecareapp:id/snackbar_text")).getText(); if (snackbarText.equals(expectedText)) { System.out.println("Pass"); } else { String pageName = getExecutingClassName(); Screenshot.takeScreenshotIfSnackbarVisible(driver, pageName); System.out.println("Fail"); Assert.fail("Test failed"); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter