• appium自动化测试(3)-控件定位&中文输入



    ◆ 控件定位就是精确的描述控件特征并告诉机器的过程。控件的特征就是控件的属性,可以通过上一讲中的uiautomatorviewer去获取。以下是方法:
    1、通过resourceID获取 driver.find_element_by_id("com.android.contacts:id/menu_add_contact").click()
    2、通过name:findElementByName( "name")
    3、findElementByClassName(”classname“)
    4、findElementByAccessibilityId()在安卓上等同于contentDescription
     
     
    ◆ 中文输入法:乱码&输入中文报错的解决方法
    1. #coding=utf-8
    2. import time
    3. from appium import webdriver
    4. desired_caps ={}
    5. desired_caps['platformName']='Android'
    6. desired_caps['platformVersion']='4.4.4'
    7. desired_caps['deviceName']='Android Emulator'
    8. desired_caps['appPackage']='com.XX.activity'
    9. desired_caps['appActivity']='.XXSearchActivity'
    10. desired_caps['unicodeKeyboard']=True
    11. desired_caps['resetKeyboard']=True
    12. driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    13. driver.find_elements_by_name("搜索话题")
    14. driver.find_element_by_class_name("android.widget.EditText").send_keys(u"可爱")
    15. # driver.find_element_by_id('et_searchactivity_search').send_keys(u"可爱")
    16. driver.find_element_by_name("搜索").click()
    17. time.sleep(5)//在页面暂停5秒
    18. driver.quit()
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     





    多点坚持~期待优雅~
  • 相关阅读:
    POJ 1325 Machine Schedule(待整理)
    URAL 1109 Conference
    结构体排序初始化最傻最傻的错误
    Radar Installation
    关于Eclipse中插件的安装和文件导出
    贪心算法概述
    今年暑假不AC(水题)
    100197C
    100722C
    树状数组
  • 原文地址:https://www.cnblogs.com/qingxd/p/5533748.html
Copyright © 2020-2023  润新知