Skip to content Skip to sidebar Skip to footer

How To Capture The Toast In Android With Appium

I used like this,but not found. WebElement element = androidDriver.findElementByClassName(android.widget.Toast); So I search in every major forum and portal,they solved it by blow:

Solution 1:

Here is my finally solution:

WebElement toastView = androidDriver.findElement(By.xpath("//android.widget.Toast[1]")); String text = toastView.getAttribute("name");

Thanks for the xpath grammar!

Solution 2:

Here is an updated answer:

WebElement toastView = androidDriver.findElement(By.xpath("//android.widget.Toast[1]"));
//USE THE RETRIEVED TEXT TO ASSERT ETC
System.out.println("TOAST = " + toastView.getText());

Post a Comment for "How To Capture The Toast In Android With Appium"