Verify Toast Message Using Page Source

    0

    0

    Yogesh Wankhede

    The code first checks to see if the toast message is present in the page source. If it is present, the code then loops through the eight Toast instances and verifies that the toast message is present in each of them. Finally, the code calls the Thread.sleep() method to delay for 300 milliseconds to simulate user interaction.

    Library: appium

    public void verifyToastMessageUsingPageSource(String toastmsg) throws InterruptedException {
      boolean found = false;
      for(int i =0 ; i <8; i++){
        if(getDriver().getPageSource().contains("class=\"android.widget.Toast\" text=\""+toastmsg+"\"")){
        found = true;
        break;
        }
        Thread.sleep(300);
      }
      Assert.assertTrue(found,"toast message "+toastmsg+" is present");
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.