def Test(self): accounts = OldTools.accounts_list("C:\\useraccount\\worklist.xlsx") for key in sorted(accounts.keys()): temp = accounts.get(key) for k in sorted(temp.keys()): lg = LoginTools() driver = lg.loginInitial_Chrome(self.testCaseID) #(driver,time_consumption[1]) x = OldTools.account_audit2(driver, k, temp.get(k)) driver = x[0] print('用户:' + k + '登陆,消耗: %f' % x[1]) time.sleep(1.2) # dropdown list location try: delta = driver.find_element_by_css_selector('#iconList') except Exception: assert 0, '找不到用户菜单按钮' if delta is not None: delta.click() time.sleep(2) try: logout = driver.find_element_by_id('btnLogout') logout.click() wait = WebDriverWait( driver, 30).until(lambda dr: dr.find_element_by_css_selector( '#divLanguage>a')) if wait: pass else: assert 0, '注销失败' except Exception: assert 0, '用户注销失败' driver.quit()
def Test(self): driver = self.driver ls = [ 'div[id="project-18-HuarunHK-undefined"]', 'div[project-id="18"]' ] OldTools.icon_view_login(driver, self.projectName, ls) try: driver.find_element_by_css_selector( '#ulPages > li:nth-child(3) > a > span.nav-btn-text').click() except Exception as e: assert 0, tag1 + '-Webpage is not available,maybe loading fails,please check it'
def checkDownLoadList(self, org_data): pointList = [] try: for data in org_data: pointList.append([data[0], data[1], data[2]]) except: print(data) org_data_temp = pointList[:] #xlxs = xlrd.open_workbook(self.downloadDir + '\\%s.xlsx' % self.projectName) lines = OldTools.xlsx(self.downloadDir + '\\%s.xlsx' % self.projectName) '''with open(self.downloadDir + '\\%s.csv' % self.projectName, encoding='utf-8') as csvFile: reader = csv.reader(csvFile) lines = [line for line in reader]''' #比对下载文件里的点的个数是否一样 if len(org_data) != len(lines): self.errors.append( "CaseID: %s 项目名称: %s, error: 数据管理--现场点---导出点表后点表数量与原始不一致!网页中点个数为%d, csv文件点个数为%d" % (self.testCaseID, self.projectName, len(org_data), (len(lines) - 1))) else: print('下载后的点表与web端显示的个数一致!') org_data_temp = sorted(org_data_temp) for index, line in enumerate(sorted(lines)): if line[0] in org_data_temp[index]: pass else: if 'mapping' in line: pass else: self.errors.append( 'CaseID: %s 项目名称: %s, error: 数据管理--现场点---导出点表后的csv中含有不存在的点!详细信息为%s' % (self.testCaseID, self.projectName, json.dumps(line)))
def Test(self): a = WebDriverTools() driver = self.driver ls = [ 'div[id="project-17-HuaweiPlant-undefined"]', 'div[project-id="17"]' ] OldTools.icon_view_login(driver, self.projectName, ls) time.sleep(3) '''iddics = {"#page-200000360": "运行诊断", "#page-210000364": "系统概况", "#page-210000365": "Cold W-System", "#page-210000366": "First Cold-S", "#page-210000367":"Second Cold-S"} if len(iddics.keys()) > 0: for x in sorted(iddics.keys()): driver.find_element_by_css_selector('#ulPages .caret').click() time.sleep(5) try: driver.find_element_by_css_selector(x).click() ins = DriverWaitTime() ins.calculateTime(driver, 'spinnerMask',tag1+">"+iddics.get(x)) except Exception: tag1+'Huawei System Surveillance--'+iddics.get(x)+'--loading fail,please check it,thank you ''' '' try: sv = driver.find_elements_by_css_selector( '#ulObserverScreenList.dropdown-menu li a') except Exception: assert 0, self.projectName + '-' + self.buzName + '页面不存在' index = 2 if len(sv) > 0: for i in range(2, len(sv)): try: driver.find_element_by_css_selector( '#ulPages .caret').click() except Exception: assert 0, self.projectName + '-' + self.buzName + '点击下拉页面无效' try: driver.find_elements_by_css_selector( '#ulObserverScreenList.dropdown-menu li a')[i].click() #a.find_spinner(driver,cur_time=time.time(),project=self.projectName,timeout="23") time.sleep(3) #index += 1 except Exception: assert 0, self.projectName + '-' + self.buzName + '-' + sv[ i].text + '点击无效'
def Test(self): driver = self.driver itemproject = 'Shanghai Huawei' # Login Item by clicking on Icon ls = ['div[id="project-1-hsimc-undefined"]', 'div[project-id="1"]'] time.sleep(2) OldTools.icon_view_login(driver, self.projectName, ls) # System Surveillance-drop down lists #div[id="scrollPages"] .dropdown-menu li a iddics = { "page-50000183": "主界面", "page-10000161": "系统总览", "page-10000163": "设备总览", "page-10000157": "热水系统", "page-124": "冷机参数", "page-40000179": "变频器参数", "page-50000184": "实时电量" } OldTools.login_defaultpage_load(driver, self.testCaseID, self.projectName + self.buzName, iddics)
def Test(self): driver = self.driver ls = [ 'div[id="project-72-shhuawei-undefined"]', 'div[project-id="72"]' ] t = OldTools.icon_how_present(driver, self.projectName, ls) if t[1] == '视图:图标导航模式靠右': try: lo = driver.find_elements_by_css_selector( 'div[id="map-canvas"] .map-marker') except Exception: assert 0, '地图上没有点显示' if len(lo) > 2: pass else: assert 0, '地图上没有点显示'
def Test(self): driver = self.driver itemproject = 'Shanghai Huawei' ls = [ 'div[id="project-72-shhuawei-undefined"]', 'div[project-id="72"]' ] OldTools.icon_view_login(driver, self.projectName, ls) # Data Analysis tag-loading OldTools.tag_load_via_click( driver, 'Case005:', itemname, tagname, '#ulPages.nav.nav-pills.navbar-left>li:nth-child(5) .nav-btn-text') # statistic via clicking on workbench hyperlink a = ActionChains(driver) hover_config = driver.find_element_by_css_selector( '#anlsPaneContain ol.breadcrumb li a') time.sleep(3) a.move_to_element(hover_config).perform() hover_config.click() time.sleep(3) try: original_bench = driver.find_elements_by_css_selector( '#anlsPane .wsCtn') except Exception: assert 0, 'Case-103:找不到默认工作空间' if len(original_bench) > 0: original_bench[0].click() time.sleep(2) try: add_slide_button = driver.find_element_by_css_selector( '#btnAddSlider .glyphicon-plus') except Exception: assert 0, '找不到添加Slider按钮' #Add slide if add_slide_button is not None: add_slide_button.click() time.sleep(4) # Data Analysis-Amount of icon text iconmixed = { "AnlzTendency": "AnlzTendency", "AnlzSpectrum": "AnlzSpectrum", "AnlzScatter": "AnlzScatter", "AnlzHistoryCompare": "AnlzHistoryCompare", "AnlzHistoryCompare_Line": "AnlzHistoryCompare_Line", "AnlzStack": "AnlzStack", "AnlzPieRealtime": "AnlzPieRealtime", "AnlzEnergy": "AnlzEnergy", # "AnlzCluster": "PatternAnalysis", "AnlzCluster_AHU": "AHUDiagnosis", # "AnlzCluster_Chiller": "Chiller Machine Diagnosis" } OldTools.get_texts_or_icons( 'Case-104:', driver, itemname, 'Data Analysis', 'div[id="anlsPane"] .anlsTemplate[templatetype=""] h3', iconmixed) # Calculate the amount of workbench '''ogn = 0