Exemplo n.º 1
0
class AddUserTest(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.driver = BoxDriver()
        self.logger = GetLogger(
            r'D:\workspace\selenium\ranzhi\report\ranzhi_adduser.log')
        addUser = AddUser(self.driver)
        addUser.login()
        self.logger.info('登录完毕!')
        addUser.switch_to()
        self.addUser = addUser

    @classmethod
    def tearDownClass(self):
        self.driver.close()
        self.logger.info('执行完毕!')

    def tearDown(self):
        self.addUser.add_user_again()
        self.logger.info('添加下一个用户!')

    @parameterized.expand(GetExcel().get(
        r'D:\workspace\selenium\ranzhi\config\data.xlsx', 'adduser_success'))
    def test_adduser_seccess(self, username, realname, email):
        '''添加用户成功用例'''
        addUser = self.addUser
        addUser.add_user(username, realname, email)
        self.logger.info('添加用户完毕!')
        realname_get = addUser.get_realname(
            'x /html/body/div/div/div/div[2]/div/div/table/tbody/tr/td[3]')
        self.assertEqual(realname_get, realname, '添加用户成功用例失败')
        self.logger.info('断言完毕!')
Exemplo n.º 2
0
 def setUpClass(self):
     self.driver = BoxDriver()
     self.logger = GetLogger(
         r'D:\workspace\selenium\ranzhi\report\ranzhi_adduser.log')
     addUser = AddUser(self.driver)
     addUser.login()
     self.logger.info('登录完毕!')
     addUser.switch_to()
     self.addUser = addUser
Exemplo n.º 3
0
class LoginTest(unittest.TestCase):
    logger = GetLogger('./report/ranzhi.log')

    @classmethod
    def setUpClass(self):
        self.driver = BoxDriver()
        self.logger.info('打开了浏览器,输入项目网址')
        self.page = LoginPage(
            self.driver)  # page其实也是个装有浏览器的对象(因为LoginPage类继承了BasePage类的构造函数)

    @classmethod
    def tearDownClass(self):
        self.logger.info('退出浏览器')
        self.driver.quit()

    @parameterized.expand(GetExcel().load(r'./data/data.xlsx',
                                          'login_success'))
    # @parameterized.expand((GetCsv().load(r'./data/homework.csv'))[:4])
    def test_login_success(self, username, password):
        '''登录成功功能测试用例'''
        try:
            self.logger.info('登录项目')
            self.page.login(username, password)
            # 断言
            real_name = self.page.get_login_name()
            self.logger.info('获取到的真名是%s' % real_name)
            # assert element.text == 'admin'
            self.assertEqual(real_name, username, '登陆失败!')
        except:
            raise NameError('测试失败!')
        finally:
            self.page.logout()

        # self.page.login('user14','123456')
        # # 断言
        # real_name = self.page.get_login_name()
        # # assert element.text == 'user0'
        # self.assertEqual(real_name,'user0','登陆失败!')
        # self.page.logout()

    @parameterized.expand(GetExcel().load(r'./data/data.xlsx', 'login_fail'))
    # @parameterized.expand((GetCsv().load(r'./data/homework.csv'))[4:])
    def test_login_fail(self, username, password):
        '''登陆失败功能测试用例'''
        # 断言
        try:
            self.page.login(username, password)
            self.logger.info('登录完毕!')
            tip = self.page.get_fail_tips()
            self.assertEqual(tip, '登录失败,请检查您的成员名或密码是否填写正确。', '断言失败!')
        except:
            self.logger.error('代码出错了,赶紧排查!')
            raise NameError('测试失败!')
        finally:
            self.page.confirm()
Exemplo n.º 4
0
 def setUpClass(cls):
     cls.driver = BoxDriver(
         'http://localhost/ranzhi/www/sys/user-login.html')
     cls.page = LoginPage(cls.driver)
     # 创建日志
     cls.logger = GetLogger(
         r'D:\workspace\selenium\ranzhi\report\rhzhi.log')
Exemplo n.º 5
0
 def test(self):
     driver = BoxDriver()
     # LoginPage(driver).login()
     # AddUser(driver).add_user()
     add = AddUser(driver)
     add.login()
     add.add_user()
Exemplo n.º 6
0
class AddProject:
    @classmethod
    def setUpClass(self):
        self.driver = BoxDriver()
        self.logger = GetLogger(
            r'D:\workspace\selenium\ranzhi\report\ranzhi_addproject.log')
        addproject = AddProject(self.driver)
        addproject.login()
        self.logger.info('登录完毕!')
        addproject.switch_to()
        self.addproject = addproject

    def setUp(self):
        self.addproject.add_project_start()
        self.logger.info('添加任务开始!')

    def tearDown(slef):
        self.logger.info('添加任务结束!')

    @classmethod
    def tearDownClass(self):
        self.driver.close()
        self.logger.info('执行完毕!')

    @parameterized.expand(GetExcel().get(
        r'D:\workspace\selenium\ranzhi\config\data.xlsx',
        'addproject_success'))
    def test_project(self, name):
        '''添加项目用例'''
        addproject = self.addproject
        # 添加项目
        addproject.add_project(name)
        # 断言
        dataname = addproject.get_dataname(
            'x //*[@id="dashboard"]/div[1]/div/div[1]')
        self.assertEqual(dataname, name, '添加项目用例失败')
        self.logger.info('断言完毕!')
Exemplo n.º 7
0
    def adduser_test(self):
        '''
        添加成员测试用例
        '''
        # driver = BoxDriver()
        #登陆
        # login = LoginPage(driver)
        # login.login('admin','123456')
        #添加用户
        # add = AddUserPage(driver)
        # add.adduser()

        add = AddUserPage(
            BoxDriver('http://localhost/ranzhi/www/sys/user-login.html'))
        add.login('admin', '123456')
        add.adduser()
Exemplo n.º 8
0
        # 登陆
        driver.input(self.config['LoginPage']['ACCOUNT'], uname)
        driver.input(self.config['LoginPage']['PASSWORD'], upwd)
        driver.click(self.config['LoginPage']['SUBMIT'])

        driver.wait(2)

    def logout(self):
        # 登陆成功后退出
        self.driver.click('p 签退')

    def confirm(self):
        # 登陆失败后确认提示信息
        self.driver.click('x /html/body/div[2]/div/div/div[2]/button')

    def get_real_name(self):
        # 获取登陆以后的真实姓名
        element = self.driver.locate_element(
            'x //*[@id="mainNavbar"]/div/ul[1]/li/a')
        return element.text

    def get_tips(self):
        element = self.driver.locate_element(
            'x /html/body/div[2]/div/div/div[1]/div')
        return element.text


if __name__ == "__main__":
    LoginPage(BoxDriver()).login()
Exemplo n.º 9
0
        driver.click(self.config['LoginPage']['SUBMIT'])

        driver.wait(1)

    def logout(self):
        '''签退'''
        self.driver.click('l,签退')
        self.driver.wait(1)

    def confirm(self):
        '''失败时点击 '确认' '''
        self.driver.click('x,/html/body/div[2]/div/div/div[2]/button')
        self.driver.wait(1)

    def get_realname(self):
        '''获取用户真名'''
        element = self.driver.locate_element(
            'x,//*[@id="mainNavbar"]/div/ul[1]/li/a')
        return element.text

    def get_msg(self):
        '''获取失败时的提示信息'''
        element = self.driver.locate_element(
            'x,/html/body/div[2]/div/div/div[1]/div')
        return element.text


if __name__ == "__main__":
    url = 'http://localhost/ranzhi/www/sys/user-login.html'
    LoginPage(BoxDriver(url)).login('admin', '123456')
Exemplo n.º 10
0
 def setUpClass(self):
     self.driver = BoxDriver()
     self.logger.info('打开了浏览器,输入项目网址')
     self.page = LoginPage(
         self.driver)  # page其实也是个装有浏览器的对象(因为LoginPage类继承了BasePage类的构造函数)
Exemplo n.º 11
0
 def setUpClass(self):
     self.driver = BoxDriver()
     self.page = LoginPage(self.driver)
     self.logger = GetLogger('./report/ranzhi.log')
     self.logger.info('打开浏览器,输入网址完毕')