zoukankan      html  css  js  c++  java
  • appium知识点

    1 appium元素获取技巧

    # 就是页面滑动
    driver.swipe(x1, y1, x1, y2, t)
    # 拿到所有跟元素有关的标签,其实是个列表
    driver.find_elements_by_class_name('android.widget.TextView')
    # 按照下标拿数据并点击
    driver.find_elements_by_class_name('android.widget.TextView')[0].click()
    #层及定位
    element = driver.
    find_element_by_class_name('android.support.v4.view.ViewPager')
    print(element)
    element = element.find_element_by_class_name('android.view.View')
    print(element)
    element = element.find_element_by_class_name('android.widget.TextView')
    element.click()
    #注 当在一个层级中定位多个元素的时候,可以使用下标来精准定位
    # uiautomator进行定位,直接看ui界面的元素
    def into_by_uiautomator():
    driver.find_element_by_android_uiautomator('new UiSelector().text("立刻进入体验")').click()
    # 清空输入框中的数据
    driver.find_element_by_android_uiautomator('new UiSelector().text("18513199586")').clear()
    # 向输入框中输入数据
    driver.find_element_by_android_uiautomator('new UiSelector().text("手机号/邮箱")').send_keys('18513199587')
    #注括号中的text可以替换成index,resource-id,class-name
    #x_path
    # 查找整个目录下面包含这个文本的标签
    driver.find_element_by_xpath('//*[contains(@text,"登录")]').click()
    # 通过子节点
    driver.find_element_by_xpath('//android.widget.TextView[@resource-id="cn.com.open.mooc:id/login_lable"]/../preceding-sibling::android.widget.RelativeLayout').send_keys('123123')
    #tost
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    def get_tost():
    time.sleep(2)
    driver.find_element_by_id('cn.com.open.mooc:id/account_edit').send_keys('18513199586')
    tost_element = ("xpath","//*[contains(@text,'请输入密码')]")
    WebDriverWait(driver,10,0.1).until(EC.presence_of_element_located(tost_element))

    2 python读取配置文件

    import os
    from configparser import ConfigParser
    read_ini = ConfigParser()
    # 获取文件配置文件路径
    print(os.path.join(os.path.join(os.path.dirname(os.getcwd()),'config'),'LocalElement.ini'))
    # 读配置文件
    read_ini.read(os.path.join(os.path.join(os.path.dirname(os.getcwd()), 'config'), 'LocalElement.ini'))
    # 读出数据
    print(read_ini.get('login_element', 'username'))

    3 运行appium并打印日志

    appium -p {appium_port_list[i]} -bp {bootstrap_port_list[i]} -U {device_list[i]} --no-reset --session-override --log D:ouyangAppiumChezhudianping/log/test02.log
  • 相关阅读:
    NIOS II常用函数整理
    C指针
    YCbCrYUV
    指针与引用的区别
    Pacman 命令详解
    DDR工作原理
    关于C/C++中的点操作符和箭头操作符
    千兆以太网芯片88E1111 RGMII模式的驱动
    关于建立时间和保持时间
    ECE 576 UDP Hardware
  • 原文地址:https://www.cnblogs.com/ouyang99-/p/12039745.html
Copyright © 2011-2022 走看看