예제 #1
0
class First_Case(unittest.TestCase):
    def setUp(self):
        '''前置条件'''
        self.driver = webdriver.Chrome()
        self.driver.get('http://ht.test.by-998.com/index/login')
        self.LB = Login_Business(driver=self.driver)

    def tearDown(self):
        '''后置条件'''
        self.driver.close()

    def test_login_succeed(self):
        '''测试登录成功'''
        error_login = self.LB.login_succeed(username='******',
                                            password='******')
        print(error_login)
        self.assertTrue(expr=error_login, msg='用例失败')

    def test_login_username_error(self):
        '''测试用户名错误'''
        error_username = self.LB.login_username_error(username='******',
                                                      password='******')
        print(error_username)
        self.assertFalse(expr=error_username, msg='用例通过')

    def test_login_password_error(self):
        '''测试密码错误'''
        error_password = self.LB.login_password_error(username='******',
                                                      password='******')
        print(error_password)
        self.assertFalse(expr=error_password, msg='用例通过')
예제 #2
0
class First_Case(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.log = Logs()
        cls.logger = cls.log.user_log()
        cls.driver = webdriver.Chrome()
        cls.driver.get('http://ht.test.by-998.com/index/login')

    def setUp(self):
        '''前置条件'''
        self.LB = Login_Business(driver=self.driver)

    def tearDown(self):
        '''后置条件'''
        time.sleep(2)
        #此方法获取到用例error时候截图待调整
        for method_name, error in self._outcome.errors:
            if error:
                print(error)
                case_name = self._testMethodName
                filename = os.path.join(os.getcwd() + '/report/' + case_name +
                                        '.png')
                self.driver.save_screenshot(filename=filename)
        self.driver.close()

    @classmethod
    def tearDownClass(cls):
        cls.logger.close_handle()

    # @ddt.data(
    #     ['leon2017','passnew2017','login_succeed','请输入您的登录信息'],
    #     ['leon2018', 'passnew2017','username_error','用户名或密码错误'],
    #     ['leon2017', 'passnew2018','username_error','用户名或密码错误']
    # )

    @ddt.data(*data)
    def test_register_case(self, data):
        username, password, assertCode, assertText = data
        print(data)
        self.logger.info('the is a 用例')
        error_register = self.LB.register_function(username, password,
                                                   assertCode, assertText)
        self.assertFalse(error_register, '测试失败')
예제 #3
0
 def setUp(self):
     '''前置条件'''
     self.driver = webdriver.Chrome()
     self.driver.get('http://ht.test.by-998.com/index/login')
     self.LB = Login_Business(driver=self.driver)
예제 #4
0
 def setUp(self):
     '''前置条件'''
     self.LB = Login_Business(driver=self.driver)