zoukankan      html  css  js  c++  java
  • appium获取一组元素

    from appium import webdriver
    import os
    import time
    import base64
    
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '7.1'
    desired_caps['devicesName'] = '192.168.50.101:5555'
    desired_caps['appPackage'] = 'com.android.settings'
    desired_caps['appActivity'] = '.Settings'
    
    #声明driver对象
    driver = webdriver.Remote('http:127.0.0.1:21503/wd/hub', desired_caps)
    
    #id、class、xpath
    
    
    #点击WLAN
    driver.find_element_by_xpath("//*[contains(@text, 'WLAN')]").click()
    
    
    # driver.find_element_by_id("com.android.settings:id/tile_item").click()
    
    #返回
    driver.find_element_by_class_name("android.widget.ImageButton").click()
    
    
    #查找一组元素
    driver.find_elements_by_class_name("android.widget.TextView")
    
    #强制等待
    time.sleep(4)
    
    
    #显示等待
    try:
        WebDriverWait(driver,5,1).until(lambda x: x.find_element_by_xpath("//*[contains(@text, '设置')]"))
        print("找到了")
    except:
        print("找不到超时了")
    
    print(driver.find_elements_by_xpath("//*[contains(@text, '设置')]"))
    
    
    #隐士等待,所有的操作页面默认等待3秒
    driver.implicitly_wait(3)
    print(driver.find_elements_by_xpath("//*[contains(@text, '设置')]"))
    
    
    driver.close_app()
    driver.quit()
    
    
  • 相关阅读:
    微信小程序——微信支付
    .Net 异步方法, await async 使用
    微信小程序路过——新手不要错过哦!
    关于文件的上传。
    网页源代码的获取方法
    PCPOP多功能外挂v1.0
    网站开发步骤
    关于系统的垃圾文件
    关于容器中的控件的使用
    POP气球机
  • 原文地址:https://www.cnblogs.com/gerenboke/p/13600834.html
Copyright © 2011-2022 走看看