qqTest.py 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # -*- coding: utf-8 -*-
  2. from appium import webdriver#倒入 webdriver
  3. def changeListTree(listTree):
  4. listTreeName = []
  5. if len(listTree) > 0 :
  6. for i in listTree:
  7. listTreeName.append(i.text)
  8. return listTreeName
  9. def listIsDif(newListName,oldListName):
  10. # newListName = changeListTree(newList)
  11. # oldListName = changeListTree(oldList)
  12. # newListName中有而oldListName中没有的
  13. difListName = list(set(newListName).difference(set(oldListName)))
  14. print '不同路径的长度',len(difListName)
  15. for i in difListName:
  16. print i
  17. return difListName
  18. def listQD(onelist):
  19. newlist = []
  20. for i in onelist:
  21. if not i in newlist:
  22. newlist.append(i)
  23. for i in newlist:
  24. print i
  25. def listD(newList,oldList):
  26. for iold in oldList:
  27. for inew in newList:
  28. if iold == inew:
  29. newList.remove(inew)
  30. for i in newList:
  31. print i
  32. return newList
  33. list1 =['财务中心','运营中心']
  34. list2 =['特别关注','我的客服','我的单位','浙江万赛软件集团(筹)','总裁办', '综合办', '财务中心', '运营中心']
  35. list4 =['浙江万赛软件集团(筹)','总裁办', '综合办', '财务中心', '运营中心','研发中心','质管中心','丽水万赛','云南万赛', '宁夏万赛', '测试账号']
  36. if len(listD(list1,list2)) == 0:
  37. print 'ok'
  38. #
  39. # class apptestlogin(unittest.TestCase):
  40. # def setUp(self):#初始化
  41. # self.desired_caps={}
  42. # self.desired_caps['platformName'] = 'Android'
  43. # self.desired_caps['deviceName']='7bbe99db'
  44. # self.desired_caps['preformVersion']='4.3'
  45. # self.desired_caps['appPackage'] ='com.tencent.mobileqq'
  46. # self.desired_caps['appActivity'] ='.activity.SplashActivity'
  47. # self.driver=webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)#启动 app
  48. # self.driver.implicitly_wait(1) # 全局方法最长超时时间
  49. #
  50. # def tearDown(self):#还原测试环境
  51. # self.driver.find_element_by_id('com.tencent.mobileqq:id/conversation_head').click()
  52. # self.driver.find_element_by_id('com.tencent.mobileqq:id/settings').click()
  53. # self.driver.find_element_by_id('com.tencent.mobileqq:id/account_switch').click()
  54. # self.driver.find_element_by_id('com.tencent.mobileqq:id/logoutBtn').click()
  55. # self.driver.find_element_by_id('com.tencent.mobileqq:id/dialogRightBtn').click()
  56. # self.driver.quit()
  57. #
  58. # def testLogin1(self): # 测试用例
  59. # self.driver.find_element_by_id('com.tencent.mobileqq:id/btn_login').click()#登录,定位方式 id
  60. # # time.sleep(2)
  61. # me = self.driver.find_element_by_android_uiautomator('new UiSelector().textContains("QQ")')# 定位输入qq号,使用uiautomator定位
  62. # me.clear() # 输入框输入前最好先清空下
  63. # me.send_keys('121354090')
  64. # password = self.driver.find_element_by_id('com.tencent.mobileqq:id/password')
  65. # password.clear()
  66. # password.send_keys('xxx..')
  67. # self.driver.find_element_by_id('com.tencent.mobileqq:id/login').click()#点击登录
  68. # m = self.driver.find_element_by_id('com.tencent.mobileqq:id/conversation_head')
  69. # if m is not None:
  70. # print('login is sucess')
  71. # else:
  72. # print('login is Flase')
  73. # print(self.driver.find_element_by_id('com.tencent.mobileqq:id/dialogText ').text)
  74. #
  75. # if __name__ == '__main__':
  76. # suiteTest = unittest.TestSuite()
  77. # suiteTest.addTest(apptestlogin("testLogin1"))
  78. # unittest.TextTestRunner(verbosity=1).run(suiteTest)
  79. # # now = time.strftime('%Y-%m%d', time.localtime(time.time()))
  80. # # report_dir = r'%s.html' % now
  81. # # re_open = open(report_dir, 'wb')
  82. # # runner = HTMLTestRunner.HTMLTestRunner(stream=re_open, title = 'QQ 测试', description = '测试结果')
  83. # # runner.run(suiteTest)