How to capture the Toast in Android with appium

落爺英雄遲暮 提交于 2019-12-13 04:22:32

问题


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:

WebDriverWait wait = new WebDriverWait(androidDriver, 3); WebElement toastView = wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath(".//*[contains(@text,'" + toast + "')]")));

But it works well in the condition of you has known the toast text.


回答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!



来源:https://stackoverflow.com/questions/46088919/how-to-capture-the-toast-in-android-with-appium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!