zoukankan      html  css  js  c++  java
  • appium+Python 启动app(三)登录

    我们根据前面的知识点,用uiautomatorviewer工具来获取我们当前的元素

    (注:uiautomatorviewer 是 android sdk 自带的)

    知识点:appium的webdriver有11种元素定位方法

    1、find_element_by_id()

    2、find_element_by_name()

    3、find_element_by_class_name()

    4、find_element_by_tag_name()

    5、find_element_by_link_text()

    6、find_element_by_partial_link_text()

    7、find_element_by_xpath()

    8、find_element_by_css_selector()

    9、find_element_by_accessibility_id()

    10、find_element_by_android_uiautomator()

    11、find_element_by_ios_uiautomation()

    下面进行QQ的登录测试

    #coding=utf-8
    from appium import webdriver
    import time
    desired_caps ={
        'platformName': 'Android',
        'deviceName': '127.0.0.1:62001',
        'platformVersion': '4.4.2',
        'appPackage': 'com.tencent.mobileqq',
        'appActivity': 'com.tencent.mobileqq.activity.SplashActivity',
        'unicodeKeyboard': 'True',  # unicodeKeyboard是使用unicode编码方式发送字符串
        'resetKeyboard': 'True'  # resetKeyboard是将键盘隐藏起来
    }
    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    time.sleep(5)
    driver.find_element_by_id("com.tencent.mobileqq:id/btn_login").click()
    driver.find_elements_by_class_name("android.widget.EditText").send_keys(u"3060382351")
    driver.find_element_by_id("com.tencent.mobileqq:id/password").send_keys(u"123456")
    driver.find_element_by_id("com.tencent.mobileqq:id/login").click()
    View Code
  • 相关阅读:
    dotnet Framework 源代码 类库的意思
    dotnet Framework 源代码 类库的意思
    dotnet Framework 源代码 · Ink
    dotnet Framework 源代码 · Ink
    dotnet core 用值初始化整个数组
    dotnet core 用值初始化整个数组
    dotnet core 隐藏控制台
    dotnet core 隐藏控制台
    PHP mt_rand() 函数
    PHP mt_getrandmax() 函数
  • 原文地址:https://www.cnblogs.com/cnblogsadmin/p/8392197.html
Copyright © 2011-2022 走看看