首页 > 代码库 > appium基础框架
appium基础框架
1 #-*-ecoding:utf-8 -*- 2 from appium import webdriver 3 from selenium.webdriver.support.wait import WebDriverWait 4 import unittest 5 from time import sleep 6 import time 7 import HTMLTestRunner 8 import io 9 10 class WebCat_Open(unittest.TestCase): 11 def setUp(self): 12 desired_caps={"platformName":"Android", 13 "platformVersion":"6.0", 14 "deviceName":"ZTEBV0710", 15 "appPackage":"com.tencent.mm", 16 "appActivity":"com.tencent.mm.ui.LauncherUI ", 17 "unicodeKeyboard":"true"} 18 self.driver=webdriver.Remote("http://192.168.2.226:4723/wd/hub",desired_caps) 19 def tearDown(self): 20 self.driver.quit() 21 22 def test_open(self): 23 dr=self.driver 24 qh=WebDriverWait(dr,10).until(lambda dr:dr.find_element_by_name(u"我")) 25 qh.click() 26 dr.find_element_by_name(u"设置").click() 27 print(dr.current_context) 28 print(dr.current_activity) 29 sleep(10) 30 def test_xy(self): 31 pass 32 def test_wc(self): 33 pass 34 35 unitsuits=unittest.defaultTestLoader.discover(start_dir=r"C:\Users\syf1225\PycharmProjects\appium", 36 pattern="web*.py", 37 top_level_dir=None) 38 unitsuit=unittest.TestSuite() 39 for suits in unitsuits: 40 print(suits) 41 for suit in suits: 42 unitsuit.addTests(suit) 43 print(suit) 44 45 if __name__=="__main__": 46 now = time.strftime("%y%m%d%H%M%S", time.localtime()) 47 filename = "C:\\Users\\syf1225\\PycharmProjects\\appium\\htmereport\\" + now+"result.html" 48 file = open(filename, "wb") 49 runner=HTMLTestRunner.HTMLTestRunner(stream=file, 50 title=u"微信测试", 51 verbosity=1, 52 description=u"python脚本,安卓6.0,windows10") 53 runner.run(unitsuit)
以上代码是做一些测试时用的,照着此代码基本可以完成大部分基于UI的测试
appium基础框架
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。