• 八、appium+python 获取toast弹窗信息


    以微信登录界面的toast弹窗为例:

    我的appium版本是1.17.1,服务器运行时日志有这样的打印信息

     所以我的desired_caps如下(如果是之前的版本,需要安装uiautomator2,并且在初始化时指定automationName为uiautomator2):

    desired_caps_a = {'platformName': "Android",
                          'platFormVersion': "10",
                          'deviceName': "dd",
                          'udid': "648d4f29",
                          'automationName': "UiAutomator2",
                          'noReset': False,
                          'unicodeKeyboard': True,
                          'resetKeyboard': True,
                          'appPackage': "com.tencent.mm",
                          'appActivity': "com.tencent.mm.ui.LauncherUI",
                          'autoGrantPermissions': True,
                          'chromedriverExecutable': r"C:Usersv_yddchenDesktopchromedriver_win32 77.0chromedriver.exe",
                          'chromeOptions': {'androidProcess': "com.tencent.mm:toolsmp"}  # webview的进程名字,不然会报错
        }

    填写登录信息,获取toast(有时来不及获取登录界面的toast信息,会拿到登录成功后,加载数据的toast):

    device_a = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps_a)
        my_logging = output_log(logging.DEBUG)
    # toast弹窗处理
        device_a.find_element_by_android_uiautomator('new UiSelector().text("登录")').click()
        time.sleep(1)
        device_a.find_element_by_android_uiautomator('new UiSelector().textContains("用微信号")').click()
        time.sleep(1)
        username_input = device_a.find_element_by_android_uiautomator('new UiSelector().textContains("请填写微信号")')
        username_input.clear()
        username_input.send_keys('xxx')
        pwd_input = device_a.find_element_by_android_uiautomator('new UiSelector().textContains("请填写密码")')
        pwd_input.clear()
        pwd_input.send_keys('xxx')
        device_a.find_element_by_android_uiautomator('new UiSelector().text("登录")').click()
        toast_el = WebDriverWait(device_a, 5, 0.00001).
            until(lambda x: x.find_element_by_xpath("//*[contains(@text,'正在')]"))
        # toast_el = WebDriverWait(device_a, 5, 0.000001).
        #     until(lambda x: x.find_element_by_xpath('//*[@class="android.widget.Toast"]'))
        print(toast_el.text)
        device_a.quit()

    当密码填写信息错误时,不管改定时器的间隔为多小,都找不到toast,比较奇怪。如果点击【登录】--登录完成,跳转,这个过程很短,也有可能获取不到toast。

    一个未完成的更新......

  • 相关阅读:
    catalina.sh详解
    jenkins环境变量问题
    张量或维度表示数学理解思路
    YOLO v3重点理解、单元格坐标系、偏移量以及放缩、置信度
    YOLO v3重点理解、单元格坐标系、偏移量以及放缩、置信度
    yolo v3好的想法和一些很好的见解
    损失函数的选择,交叉熵函数的分类以及为什么使用这种损失函数可以提升效果,为什么划分格子grid大小最后是变化的,不是固定的。
    多维python切片,和yolo最后结构1,3,16,16,85的理解
    进度条
    .argmax(-1)理解
  • 原文地址:https://www.cnblogs.com/Cc905/p/13402499.html
Copyright © 2020-2023  润新知