コード例 #1
0
 def setUp(self):
     logger.info('setUp start')
     #开启web 认证
     login.loginWeb(self)  # admin账号登录
     self.driver.implicitly_wait(10)
     self.driver.maximize_window()
     freeauth = Organization_userAuthPage(self.driver, self.url)
     # 打开用户管理 - 用户认证
     freeauth.click_UserManage()
     time.sleep(0.5)
     freeauth.click_userAuth()
     time.sleep(1)
     # 开启web认证
     freeauth.click_WebAuthEn()
     time.sleep(0.5)
     # 断言 提示信息是否有误
     status1 = str(
         freeauth.getAttribute_byXpath(freeauth.WebAuthEs, 'checked'))
     self.assertEqual(status1, 'true', msg='web认证开启出错')
     print('web认证开启')
     time.sleep(1)
     #开启免认证
     freeauth.click_FreeAuthEn()
     time.sleep(0.5)
     # 断言 提示信息是否有误
     status2 = str(
         freeauth.getAttribute_byXpath(freeauth.FreeAuthEs, 'checked'))
     self.assertEqual(status2, 'true', msg='免认证开启出错')
     print('免认证开启')
コード例 #2
0
    def test_002_remoteAuth_FreeAuth(self):
        u'''认证弹窗测试&&免认证测试'''
        if Support == '√':
            logger.info(u'参数支持远程认证')
            saveSucess = getAssertText('saveSucess')

            self.driver = webdriver.Chrome()
            # self.driver.maximize_window()
            self.driver.implicitly_wait(10)
            #打开网页测试
            self.driver.get('http://www.utt.com.cn')
            time.sleep(2)
            title1 = self.driver.title
            now_url = self.driver.current_url
            print(title1, now_url)
            # self.assertEqual(title1, '艾泰科技', msg='认证页面跳转不正常') 如
            self.assertIn('http://auth.greenwifi.com.cn',
                          now_url,
                          msg='认证页面跳转不正常')
            self.driver.quit()
            print('远程认证 弹窗验证成功')

            #打开组织架构的免认证
            login.loginWeb(self)  # admin账号登录
            self.driver.implicitly_wait(10)
            remoteauth = Organization_userAuthPage(self.driver, self.url)
            remoteauth.click_UserManage()
            time.sleep(0.3)
            remoteauth.click_userAuth()
            time.sleep(1)
            # 免认证选择组织架构
            remoteauth.click_noConfig()
            time.sleep(1)
            remoteauth.click_usergroup()
            time.sleep(1)
            # 组织架构,这里选择的是ROOT 所有
            remoteauth.click_Root()
            time.sleep(0.5)
            remoteauth.click_save()
            time.sleep(1)
            # 开启免认证
            remoteauth.click_FreeAuthEn()
            time.sleep(2)
            # 断言 提示信息是否有误
            pageTip = str(remoteauth.getText_byClass(remoteauth.pageTip))
            time.sleep(1)
            self.assertEqual(pageTip, saveSucess, msg='免认证开启出错')
            self.driver.quit()
            print('免认证开启')

            # 打开网页测试
            time.sleep(5)
            self.driver = webdriver.Chrome()
            # self.driver.maximize_window()
            self.driver.implicitly_wait(10)
            self.driver.get('http://www.baidu.com')
            time.sleep(2)
            title3 = self.driver.title
            print(title3)
            self.assertEqual(title3, '百度一下,你就知道', msg='开启免认证后 不能直接打开网页')
            self.driver.quit()
        elif Support == '×':
            logger.info(u'参数不支持远程认证')
        logger.info('test_002_remoteAuth_FreeAuth passed')