灰豆的水水

导航

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)





posted on 2016-11-25 18:45  灰豆的水水  阅读(268)  评论(0编辑  收藏  举报