|
新人求大神帮忙,不胜感激!
脚本代码如下:(我的HTMLTestRunner已经改成python3.x适用的了,撱用的是python3.5)
from appium import webdriver
import unittest
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import HTMLTestRunner
class Dttest(unittest.TestCase):
def setUpClass():
print('start setup')
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='4.4.2'
desired_caps['deviceName']='HUAWEI P7-L00'
desired_caps['appPackage']='com.tuniu.app.ui'
desired_caps['appActivity']='.homepage.LaunchActivity'
driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
def tearDown():
driver.close_app()
driver.quit()
def test_click1():
driver.find_element_by_id('com.tuniu.app.ui:id/iv_style3_card_1').click()
print('click1 passed')
def test_click2():
driver.find_element_by_id('com.tuniu.hotel:id/tv_query').click()
print('click2 passed')
def test_click3():
driver.find_element_by_id('com.tuniu.hotel:id/iv_product_small_image').click()
print('click3 passed')
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(Dttest('test_click1'))
suite.addTest(Dttest('test_click2'))
suite.addTest(Dttest('test_click3'))
#unittest.TextTestRunner(verbosity=1).run(suite)
timestr = time.strftime('%Y-%m-%d %X',time.localtime(time.time()))
filename = 'D:\\report\\'+timestr+'.html'
fp = open(filename,'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream=fp,
title='result',
description='report'
)
runner.run(suite)
fp.close()
driver.quit()
报错信息:
Traceback (most recent call last):
File "C:\Users\zhengtao\AppData\Local\Programs\Python\Python35\lib\unittest\case.py", line 392, in __init__
testMethod = getattr(self, methodName)
AttributeError: 'Dttest' object has no attribute 'test_click1'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\appium\workspace\new test\Simple-test.py", line 54, in <module>
suite.addTest(Dttest('test_click1'))
File "C:\Users\zhengtao\AppData\Local\Programs\Python\Python35\lib\unittest\case.py", line 398, in __init__
(self.__class__, methodName))
ValueError: no such test method in <class '__main__.Dttest'>: test_click1
|
|