• 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)





  • 相关阅读:
    黑马java课程2222
    屏幕亮度软件和一些自己必用的软件设置
    ahk保存
    天天洗一次澡还真是好方法
    自动化测试 就这两张图
    python __init__.py用途
    bash检查文件格式
    cygwin中运行命令提示command not found的解决方法
    Python批量插入SQL Server数据库
    怎样去掉FireFox的导入向导
  • 原文地址:https://www.cnblogs.com/huidoudeshuishui/p/6102696.html
Copyright © 2020-2023  润新知