zoukankan      html  css  js  c++  java
  • Android循环滑动寻找元素,直接代码

    #coding=utf-8


    from appium import webdriver
    import time,unittest


    class Android_test(unittest.TestCase):

    def setUp(self):
    #手机和应用配置信息
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '4.3'
    desired_caps['deviceName'] = '2462981d'
    desired_caps['appPackage'] = 'com.newspeaches.tr'
    desired_caps['appActivity'] = 'com.grape.global.mvp.main.SplashActivtiy'

    self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)


    def tearDown(self):
    self.driver.quit()

    def test_mobile_gestures(self):


    time.sleep(5)

    uesr_data = self.driver.find_element_by_id("com.newspeaches.tr:id/fixed_bottom_navigation_title").text

    print uesr_data

    assert uesr_data=="Ana Sayfa","ssssssssssssssss"

    if uesr_data=="Ana Sayfa":
    print "获取成功"
    else:
    print "获取失败"

    time.sleep(3)

    self.driver.find_element_by_xpath("//android.widget.TextView[@text='Öneriler']").click()





    time.sleep(3)

    self.driver.swipe(500,500,80,500,500)

    time.sleep(3)

    self.driver.find_element_by_xpath("//android.widget.LinearLayout[@index='0']").click()

    time.sleep(3)


    booldata=True

    while booldata:
    try:
    if self.driver.find_elements_by_id("com.newspeaches.tr:id/source_tv"):
    self.driver.swipe(500,500,500,400,500)
    break

    else:
    self.driver.swipe(500,500,500,100,500)
    except Exception,e:
    print str(e)
    # booldata = True
    // def INput(self):
    // self.driver.find_element_by_id("ad").send_keys()


    if __name__ == '__main__':

    suite = unittest.TestLoader().loadTestsFromTestCase(Android_test)
    unittest.TextTestRunner(verbosity=2).run(suite)





  • 相关阅读:
    python操作json来存储简单的数据,pickle来操作复杂的数据
    python元组,列表,字典练习
    python文件实现增删改查操作
    socket模拟服务器,客户端下载东西(ftp)
    optiontransferselect标签
    doubleselect标签联动选择框
    datetimepicker标签日期选择器
    combobox标签复合框
    checkboxlist标签多选框组
    使用动态数据的autocomplete标签
  • 原文地址:https://www.cnblogs.com/huidoudeshuishui/p/6102696.html
Copyright © 2011-2022 走看看