def test_008_license(self): u'''电子授权(某些型号可能不支持)''' dayA = getAssertText('dayA') day2A = getAssertText('day2A') SelectFileA = getAssertText('SelectFileA') ImportA = getAssertText('ImportA') licenseP = getParameter('licenseP') Support = getExcelValue(licenseP) maintenance = MaintenancePage(self.driver, self.url) time.sleep(1) if Support == '√': try: self.driver.implicitly_wait(2) maintenance.click_license() time.sleep(1) except NoSuchElementException: CapPic(self.driver) logger.info(u'软件不支持电子授权,与参数表不相符') raise Exception('软件不支持电子授权,与参数表不相符') else: try: days1 = maintenance.getText_byXpath(maintenance.days1) self.assertIn(day2A, days1, msg='剩余时间 显示不为永久 ') except AssertionError: try: days = maintenance.getText_byXpath(maintenance.days2) self.assertIn(dayA, days, msg='剩余时间 显示不为 天数') except AssertionError: raise Exception('剩余时间不显示') chooseFile = str( maintenance.getText_byID(maintenance.chooseFile1)) innerput = str(maintenance.getText_byID(maintenance.innerput1)) self.assertEqual(chooseFile, SelectFileA, msg='选择文件 按钮有误') self.assertEqual(innerput, ImportA, msg='导入 按钮有误') elif Support == '×' or '--': try: self.driver.implicitly_wait(2) maintenance.click_license() except NoSuchElementException: logger.info('软件不支持电子授权,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持电子授权,与参数表不符') raise Exception(u'软件支持电子授权,与参数表不符') else: logger.info(u'参数表读取异常') logger.info(u'参数表读取值为:', Support) raise Exception(u'参数表读取异常') self.driver.quit() logger.info('test_008_license passed')
def test_002_license(self): u'''登录页面的license''' login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) maintenance = MaintenancePage(self.driver, self.url) maintenance.click_sysConfig() time.sleep(0.5) maintenance.click_Maintenance() time.sleep(1) maintenance.click_license() time.sleep(1) filename = ('//*[@id="iframe5"]/table/tbody/tr[6]/td[2]/input[2]') licensefilenow = getlicensefile() self.driver.find_element_by_xpath(filename).send_keys(licensefilenow) time.sleep(0.5) maintenance.click_innerput() time.sleep(100) self.driver.quit() logger.info('test_reboot1 passed')