driver.findElement(By.id("ir.mci.ecareapp:id/roaming_status_switch_roaming_activity")).click(); String test1=driver.findElement(By.id("ir.mci.ecareapp:id/snackbar_text")).getText(); LOGGER.info("نتیجه رومینگ"); LOGGER.info(test1); if (test1.equals("عملیات موفقیت آمیز")) { LOGGER.info("PASS"); }else{ LOGGER.error("Test failed "); Assert.fail("Test failed "); } ///////// اگر پاپاپ را دید چه کند By snackbarTextLocator = By.id("ir.mci.ecareapp:id/snackbar_text"); boolean isElementPresent = driver.findElements(snackbarTextLocator).size() > 0; if (isElementPresent) { // If the element is present, take the desired action // Take a screenshot or perform any other operation // ... } else { // If the element is not present, take a different action // Continue with the rest of the testing or perform any other operation // ... }
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