• 感谢提供了这么多方法,已经解决问题啦

  • 反正我试了好几个 HTMLTestRunner 文件,都能生成报告,但是报告都没有 print 的内容

  • 我下了官方 python2 的改成 3 的,不行,然后又下了好几个也不行,你用 python3 么,有输出内容么,要是有,分享一个吧

  • 脚本如下:

    #! coding:utf-8
    #!/usr/bin/python

    @File: RA_Login.py

    import unittest #Python 单元测试框架
    from appium import webdriver # 导入 appium 库

    # 用 unittest 编写测试脚本框架
    class LoginTest(unittest.TestCase):

    def setUp(self):
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '8.0'
    desired_caps['automationName'] = 'UIAutomator2'
    desired_caps['deviceName'] = '9889db31544f393046'
    desired_caps['app'] = 'E:\Learn\Python\crediteaseTM_1-az-gw-zzb_20180423_2.8.7_488.apk'
    desired_caps['appPackage'] = 'com.yixin.itoumi'
    desired_caps['appActivity'] = 'com.yixin.itoumi.module.login.SplashActivity'
    #desired_caps['noReset'] = False
    #desired_caps['unicodeKeboard'] = "True"
    #desired_caps['resetKeyboard'] = 'True'

    self.wd = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    self.wd.implicitly_wait(10)

    def getSize(self):
    x = self.wd.get_window_size()['width']
    y = self.wd.get_window_size()['height']
    return (x, y)

    def SwipeLeft(self,duration):
    l = self.getSize()
    self.wd.swipe(l[0] * 0.5, l[1] * 0.75, l[0] * 0.5, l[1] * 0.25, duration)

    for i in range (0,4):
    self.SwipeLeft(300)

    def testLogin(self):

    self.wd.find_element_by_id('com.yixin.itoumi:id/tv_startUse').click()
    self.wd.find_element_by_id('com.yixin.itoumi:id/iv_bottom').click()
    self.wd.find_element_by_id('com.yixin.itoumi:id/rl_my_account').click()
    self.wd.find_element_by_id('com.yixin.itoumi:id/login_mobile').set_value('18600000195')
    self.wd.find_element_by_id('com.yixin.itoumi:id/login_finish').click()
    self.wd.find_element_by_id('com.yixin.itoumi:id/login_password').set_value('123456')
    self.wd.find_element_by_id('com.yixin.itoumi:id/login_finish').click()

    print("用户已登录成功!")

    def tearDown(self):
    self.wd.quit()

    if name == 'main':
    unittest.main()