0
0
YWYogesh 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");