Appium获取toast消息

Android获取toast,需要在参数里设置automationName:Uiautomator2

设置设备的信息

desired_caps = {
'platformName': 'Android',  # 平台
'platformVersion': '5.1',  # 版本号
'deviceName':
'appPackage':
'appActivity':
'unicodeKeyboard': 'True',  # 防止键盘中文不能输入
'resetKeyboard': 'True',  # 重置设置生效
'automationName': 'Uiautomator2', #识别toast
'noSign':'True'
}

运行脚本,如果提示Uiautomator2错误, 需要更新appium1.6.3以上才能识别toast.
https://github.com/appium/appium-desktop/releases

原文地址:https://www.cnblogs.com/lovesKey/p/11172971.html

时间: 2024-08-23 07:42:04

Appium获取toast消息的相关文章

Appium获取toast消息遇到的问题(一)

一.运行错误 Android获取toast,需要在参数里设置automationName:Uiautomator2 1 # 设置设备的信息 2 desired_caps = { 3 'platformName': 'Android', # 平台 4 'platformVersion': '5.1', # 版本号 5 'deviceName': 6 'appPackage': 7 'appActivity': 8 'unicodeKeyboard': 'True', # 防止键盘中文不能输入 9

Appium获取toast消息(二)

刚接触appium进行移动端设备的UI自动化,在遇到toast消息的时候很是苦恼了一阵,最后通过强大的搜索引擎找到了个相对解决方法,废话不多说,直接贴代码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓: 1 from selenium.webdriver.support.ui import WebDriverWait 2 from selenium.webdriver.support import expected_conditions as EC 3 4 def is_toast_exi

Python+Appium 获取 toast 方法的封装

获取toast内容方法封装如下: def get_Toast(self,message): #查找toast值 ''' method explain:查找toast的值,与find_Toast实现方法一样,只是不同的2种写法 parameter explain:[text]查找的toast值 Usage: device.get_Toast('再按一次退出iBer') ''' logging.info("查找toast值---'%s'" %(message)) try: message

appium定位toast消息的使用

定位使用xpath后,定位消息文本,然后使用text获取消息文本做断言.toast_loc = ("xpath", ".//*[contains(@text,'切换运营商成功')]")elm = WebDriverWait(self.driver, 5).until(EC.presence_of_element_located(toast_loc)) self.assertEqual(elm.text,'切换运营商成功') 进行断言 原文地址:https://www

使用appium框架测试安卓app时,获取toast弹框文字时,前一步千万不要加time.sleep等等待时间。

使用appium框架测试安卓app时,如果需要获取toast弹框的文案内容,那么再点击弹框按钮之前,一定记得千万不要加time.sleep()等待时间,否则有延迟,一直获取不到: 获取弹框的代码: message=self.driver.find_element_by_xpath("//*[contains(@text,'成功添加到购物车')]")   原文地址:https://www.cnblogs.com/zhouchuanlun/p/12687890.html

python appium 封装获取toast方法

获取toast text封装,传入toast 部分文本,返回全部文本 def get_toast_text(self,text): try: toast_loc = (By.XPATH, "//*[contains(@text,'"+text+"')]") logger.info(toast_loc) ele = WebDriverWait(self.driver, 10, 0.1).until(EC.presence_of_element_located(toas

appium之toast处理

注意 toast要appium1.6.3以上版本才支持,appium1.4的版本就别浪费时间了 toast定位 1.先看下toast长什么样,如下图,像这种弹出来的消息"再按一次退出",这种就是toast了. 2.想定位toast元素,这里一定要注意automationName的参数必须是Uiautomator2才能定位到. 'automationName': 'Uiautomator2' # coding:utf-8 from appium import webdriver from

python 怎样获取toast?

toast是什么? 想要获取toast的小伙伴们,肯定知道这个是一个什么玩意,例行还是加一个图,加以解释,下图的就是传说中的toast,它有一个特点,出现时间特别短,很难通过定位元素去获取这个toast. 不能通过明确的元素定位来获取,那要怎么获取到toast呢?在做app自动化的时候,toast出现率非常高,所以必须要获取到toast,方便后面的断言.那要怎么通过什么方式获取呢? 答案就是:采用Xpath + text 进行定位 python -appium -真机 是怎样工作的? 知道通过什

XMPP系列(四)---发送和接收文字消息,获取历史消息功能

今天开始做到最主要的功能发送和接收消息.获取本地历史数据. 先上到目前为止的效果图:              首先是要在XMPPFramework.h中引入数据存储模块: //聊天记录模块的导入 #import "XMPPMessageArchiving.h" #import "XMPPMessageArchivingCoreDataStorage.h" #import "XMPPMessageArchiving_Contact_CoreDataObje