Exemplo n.º 1
0
    def test_002_systemAccount(self):
        u'''系统账号不能删除/不能修改账号名'''

        CannotdeleteA = getAssertText('CannotdeleteA')
        Cannotdelete2A = getAssertText('Cannotdelete2A')
        UnableChangeA = getAssertText('UnableChangeA')
        account = NetworkSharingPage(self.driver, self.url)
        #系统账号不能删除
        account.click_listdel1()
        time.sleep(1)
        tips = str(account.getText_byClass(account.tips_show_in))
        self.assertEqual(tips, CannotdeleteA, msg='admin账号不能删除 异常')
        account.click_listdel2()
        time.sleep(1)
        tips = str(account.getText_byClass(account.tips_show_in))
        self.assertEqual(tips, Cannotdelete2A, msg='guest账号不能删除 异常')
        #系统账号名不能修改
        account.click_listedit1()
        time.sleep(1)
        try:
            account.input_username('1')
        except InvalidElementStateException:
            print('admin账号不可修改 验证通过')
            account.click_modal_hide()
            time.sleep(1)
        else:
            raise Exception('admin账号可修改')
        account.click_listedit2()
        time.sleep(1)
        account.input_username('guest1')
        account.click_save()
        time.sleep(1)
        try:
            tips = str(account.getText_byClass(account.tips_show_in))
            self.assertEqual(tips, UnableChangeA, msg='guest账号修改提示信息 异常')
        except NoSuchElementException:
            raise Exception('guest账号可修改')
        account.click_modal_hide()
        time.sleep(1)

        self.driver.quit()
        logger.info('test_002_systemAccount passed')
Exemplo n.º 2
0
    def test_001_AccountSettings(self):
        u'''账号设置:新建、删除、修改'''

        reachMaxA = getAssertText('reachMaxA')
        roleA = getAssertText('roleA')
        account = NetworkSharingPage(self.driver, self.url)
        #新建
        n = 2
        while n < 6:
            n += 1
            if n < 6:
                account.click_add()
                time.sleep(1)
                account.input_username(n)
                account.input_passwd1(n)
                account.input_passwd2(n)
                authority = account.selelement_byName(account.authority)
                Select(authority).select_by_value('1')  #0 读 1 读写
                account.click_save()
                time.sleep(1)
            else:
                account.click_add()
                time.sleep(1)
                account.input_username(n)
                account.input_passwd1(n)
                account.input_passwd2(n)
                authority = account.selelement_byName(account.authority)
                Select(authority).select_by_value('0')  # 0 读 1 读写
                account.click_save()
                time.sleep(1)
                tips = str(account.getText_byClass(account.tips_show_in))
                self.assertEqual(tips, reachMaxA, msg='最大账号为5个 验证失败')
                account.click_modal_hide()
                time.sleep(1)
        Acc3 = str(account.getText_byXpath(account.Acc3))
        auth3 = str(account.getText_byXpath(account.auth3))
        self.assertEqual(Acc3, '3', msg='新增账号失败')
        self.assertEqual(auth3, roleA, msg='新增账号权限失败')
        Acc4 = str(account.getText_byXpath(account.Acc4))
        auth4 = str(account.getText_byXpath(account.auth4))
        self.assertEqual(Acc4, '4', msg='新增账号名失败')
        self.assertEqual(auth4, roleA, msg='新增账号权限失败')
        Acc5 = str(account.getText_byXpath(account.Acc5))
        auth5 = str(account.getText_byXpath(account.auth5))
        self.assertEqual(Acc5, '5', msg='新增账号名失败')
        self.assertEqual(auth5, roleA, msg='新增账号权限失败')

        self.driver.quit()
        logger.info('test_001_AccountSettings passed')