zoukankan      html  css  js  c++  java
  • Appium应用

    1.Appium Inspector

    2.UiautometorView使用

    3.Appium+python

        一般模拟器的路径都是:127.0.0.1:62001、52001

    设置第三方代理的形式来抓取手机的包

    Inspector应用:
    当APP启动时,会重置数据,清楚缓存

    通过设置noReset为true即可解决


    uiautomatorviewer应用:
    1.与appium无法共存
    2.元素定位比较inspector而言更加细致
    3.通过FullIndexXpath获取元素
    4.将uiautomatorviewer.jar文件替换tools/lib/ 下的同名文件,用于显示UIAutomatorViewer的xpath路径

    from appium import webdriver
    from selenium.webdriver.support.wait import WebDriverWait

    #配置Capabilities
    caps = {}
    caps['deviceName'] = '127.0.0.1:62001'
    caps['platformName'] = 'Android'
    caps['playformVersion'] = '4.4.2'

    caps['appAcitity'] = 'com.tencent.mobileqq'
    caps['noReset'] = '.activity.SplashActivity'
    caps['noReset'] = True
    #支持输入中文
    caps['unicodeKeyboard'] = True
    caps['resetKeyboard'] = True

    #调用Appium
    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',caps)
    driver.implicitly_wait(10)
    #登录流程
    WebDriverWait(driver, 20, 0.5).until(lambda el: driver.find_element_by_id('com.tencent.mobileqq:id/dialogRightBtn'),
    message='获取失败')
    WebDriverWait(driver,20,0.5).until(lambda el:driver.find_element_by_id('com.tencent.mobileqq:id/dialogRightBtn'),message="获取失败")
    driver.find_element_by_id('com.tencent.mobileqq:id/dialogRightBtn').click()
    driver.find_element_by_id('com.tencent.mobileqq:id/btn_login').click()
    driver.find_element_by_accessibility_id('请输入QQ号码或手机或邮箱').click()
    driver.find_element_by_accessibility_id('请输入QQ号码或手机或邮箱').send_keys(3214409709)
    driver.find_element_by_id('com.tencent.mobileqq:id/password').send_keys('remix424023')
    driver.find_element_by_id('com.tencent.mobileqq:id/login').click()

    # 发布一条说说
    driver.find_element_by_xpath(
    "//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout["
    "1]/android.widget.FrameLayout[1]/android.widget.TabHost[1]/android.widget.FrameLayout["
    "1]/android.widget.FrameLayout[1]/android.widget.TabWidget[1]/android.widget.FrameLayout["
    "3]/android.widget.RelativeLayout[1]/android.view.View[1]").click()
    driver.find_element_by_xpath("//android.widget.RelativeLayout[@resource-id='com.tencent.mobileqq:id/qzone_feed_entry']")
    driver.find_element_by_xpath(
    "//android.widget.LinearLayout[@content-desc='写说说等按钮']/android.widget.ImageView[1]").click()
    driver.find_element_by_xpath(
    "//android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.RelativeLayout["
    "1]/android.widget.LinearLayout[1]/android.widget.ImageView[1]").click()
    driver.find_element_by_xpath("//android.widget.EditText[@resource-id='com.tencent.mobileqq:id/name']").send_keys(
    '123456')
    driver.find_element_by_xpath(
    "//android.widget.TextView[@resource-id='com.tencent.mobileqq:id/ivTitleBtnRightText']").click()
    driver.tap([46,81],500)#当获取不到坐标点时使用,其中[46,81]时坐标点,500ms是时间单位
    #滑动
    driver.swipe(start_x=50,start_y=50,end_x=350,end_y=80)


  • 相关阅读:
    线段树优化建图 && CF-786B.Legacy(优化建图,dijkstra)
    构建高性能JavaScript应用
    关于互联网应用前端架构的一些思考
    Router模块
    View模块
    Backbone源码解析系列
    Model模块
    Events模块
    Backbone源码风格
    jQuery选择器总结
  • 原文地址:https://www.cnblogs.com/Murraya/p/12588864.html
Copyright © 2011-2022 走看看