运行多个测试用例,第二个需要第一个基础上执行,请问是调用错误吗?执行到第二个报告失败

#coding:utf-8
import unittest
import os
import HTMLTestRunner
from selenium import webdriver
from appium import webdriver
from time import sleep
import time
from appium.webdriver.common.touch_action import TouchAction

class CalTestCase(unittest.TestCase):
def setUp(self):
print('start setup')

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '18'
desired_caps['deviceName'] = 'EJLDU16903008253'
desired_caps['appPackage'] = 'com.dlin.ruyi.patient'
desired_caps['appActivity'] = 'com.dlin.ruyi.patient.ui.activitys.AppstartAnimationActivity'
desired_caps["unicodeKeyboard"]="True"
desired_caps["resetKeyboard"]="True"

self.dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
time.sleep(5)

def __int__(self,value):
self.value=value

def test_case_01(self):
#输入账号
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/edt_logon").click()
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/edt_logon").send_keys(u"18221582880")
time.sleep(2)
el = self.dr.find_element_by_id("com.dlin.ruyi.patient:id/edt_logon").text
print(el)
assert el==u'18221582880'

#输入密码
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/edt_logon_pwd").click()
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/edt_logon_pwd").send_keys(u"111111")
time.sleep(2)

#点击登录
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/btn_log_on").click()
time.sleep(5)
print('登录成功')

def test_case_02(self):
self.test_case_01()
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/img_account_avatar").click()
time.sleep(1)

#向上滑动
self.dr.swipe(333,1390, 333,950, 1000)

'''
#获取机器屏幕大小
def getSize(self):
x =driver.get_window_size()['width']
y =driver.get_window_size()['height']
return(x,y)
#向上滑动
def swipe_up(self,t):
screen = getSize()
driver.swipe(screen[0]*0.5,screen[1]*0.75,screen[0]*0.5,screen[1]*0.25,t)
'''

#点击设置按钮
self.dr.find_element_by_name("设置").click()
time.sleep(5)
#退出
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/btn_logout").click()
#确定退出
self.dr.find_element_by_id("com.dlin.ruyi.patient:id/dialog_confirm_ok").click()
print('成功退出')

def tearDown(self):
#退出应用
self.dr.quit()

if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(CalTestCase('test_case_01'))
suite.addTest(CalTestCase('test_case_02'))
fp = open('C:/report/result.html', 'wb')
runner=HTMLTestRunner.HTMLTestRunner(stream=fp,title='测试',description='情况')
runner.run(suite)
fp.close()
请先 登录 后评论

1 个回答

桃之妖妖 - 从2.5小白开始

报错信息贴一下 亲

请先 登录 后评论
  • 1 关注
  • 0 收藏,840 浏览
  • 句号 提出于 2017-09-20 10:50

相似问题