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)





  • 相关阅读:
    linux终端发送邮件
    ubuntu交换Caps 和 ESC
    pycharm快捷键
    python catch socket timeout
    pgsql restart
    python re.sub
    文件写入与缓存
    HTTP协议再分析
    leetcode-45
    Java的锁
  • 原文地址:https://www.cnblogs.com/huidoudeshuishui/p/6102696.html
Copyright © 2011-2022 走看看