def click_download_icon_of_district(self): cal = GetData() count = 0 files = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() cal.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() time.sleep(3) p = pwd() self.filename = p.get_download_dir() + '/' + files.teacher_download( ) + cal.get_current_date() + ".csv" print(self.filename) if not os.path.isfile(self.filename): print("Districtwise csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) total = 0 schools = 0 for row in csv.reader(fin): total += int(row[3].replace(',', '')) schools += int(row[4].replace(',', '')) students = self.driver.find_element_by_id("students").text res = re.sub('\D', "", students) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) if int(res) != total: print(int(res), total, "Teacher count mismatched") count = count + 1 if int(sc) != schools: print(int(sc), schools, "school count mismatched") count = count + 1 os.remove(self.filename) return count
def Blocks_select_box(self): self.p = pwd() self.load = GetData() count = 0 self.fname = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() self.load.page_loading(self.driver) dists = Select(self.driver.find_element_by_id(Data.district_dropdown)) Blocks = Select(self.driver.find_element_by_id(Data.blocks_dropdown)) for i in range(len(dists.options) - 1, len(dists.options)): dists.select_by_index(i) self.load.page_loading(self.driver) for j in range(len(Blocks.options), len(Blocks.options)): Blocks.select_by_index(j) self.load.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = self.p.get_download_dir( ) + '/' + self.fname.lpd_cluster() file = os.path.isfile(self.filename) if file != True: print(dists.options[i].text, Blocks.options[j].text, 'Cluster wise records csv file is not downloaded ') count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) data = list(csv_reader) row_count = len(data) os.remove(self.filename) time.sleep(2) if row_count == 0: print("records are not found in csv file ") count = count + 1 self.load.page_loading(self.driver) return count
def test_Enrollment_overall(self): self.data = GetData() self.p = pwd() self.msg = file_extention() count = 0 self.driver.find_element_by_xpath(Data.hyper_link).click() self.data.page_loading(self.driver) course_type = Select(self.driver.find_element_by_id(Data.coursetype)) course_type.select_by_visible_text(' Enrollment ') self.data.page_loading(self.driver) ctype = (self.driver.find_element_by_id(Data.coursetype).text).strip() timeseries = Select(self.driver.find_element_by_name(Data.timeperiods)) timeseries.select_by_visible_text(' Overall ') self.data.page_loading(self.driver) times = (self.driver.find_element_by_name( Data.timeperiods).text).strip() if self.msg.no_data_available() in self.driver.page_source: print('No Data Available for overall') else: self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = self.p.get_download_dir( ) + '/' + 'enrollment_completion_enrollment_all_district_overall_' + self.data.get_current_date( ) + '.csv' print(self.filename) self.data.page_loading(self.driver) collnames = Select(self.driver.find_element_by_id(Data.coll_names)) counter = len(collnames.options) - 1 for i in range(len(collnames.options), len(collnames.options) - 5): collnames.select_by_index(i) self.data.page_loading(self.driver) if os.path.isfile(self.filename) != True: print('Enrollment Over all csv file is not downloaded ') count = count + 1 self.data.page_loading(self.driver) os.remove(self.filename) return counter, count
def test_last_day(self): self.data = GetData() fname = file_extention() self.p = pwd() count = 0 self.driver.find_element_by_xpath(Data.hyper_link).click() self.data.page_loading(self.driver) timeperiod = Select(self.driver.find_element_by_name('timePeriod')) # timeperiod.select_by_visible_text(' Last 30 Days ') timeperiod.select_by_index(1) self.data.page_loading(self.driver) self.data.page_loading(self.driver) self.driver.find_element_by_id('download').click() time.sleep(3) self.filename = self.p.get_download_dir( ) + "/" + fname.location_textbook() if not os.path.isfile(self.filename): print( "Diksha course type of last 30 days data csv file not downloaded" ) else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) contentplays = 0 for row in csv.reader(fin): contentplays += int(row[0]) play_count = self.driver.find_element_by_id('totalCount').text pc = re.sub('\D', "", play_count) if int(pc) != int(contentplays): print( "Course type of last 30 days has difference between screen count value and csv file count " ) count = count + 1 self.data.page_loading(self.driver) os.remove(self.filename) return count
def test_all_districtwise(self): self.p = pwd() self.load = GetData() count = 0 self.driver.implicitly_wait(100) self.fname = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() self.load.page_loading(self.driver) dists = Select(self.driver.find_element_by_id(Data.district_dropdown)) period = Select(self.driver.find_element_by_id(Data.timeperiods)) period.select_by_visible_text(' All ') self.load.page_loading(self.driver) for i in range(len(dists.options)-3, len(dists.options)): dists.select_by_index(i) time.sleep(2) self.load.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = self.p.get_download_dir() +"/"+ self.fname.lpd_block() file = os.path.isfile(self.filename) if file != True: print(dists.options[i].text, 'District wise records csv file is not downloaded') count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) data = list(csv_reader) row_count = len(data) os.remove(self.filename) time.sleep(2) if row_count == 0: print("records are not found in csv file ") count = count + 1 return count return count
def check_districtwise_csv_download(self): p = pwd() self.cal = GetData() self.driver.implicitly_wait(60) self.driver.find_element_by_xpath(Data.hyper_link).click() self.cal.page_loading(self.driver) management = self.driver.find_element_by_id('nm').text management = management[16:].lower().strip() select_district = Select( self.driver.find_element_by_name('myDistrict')) count = 0 self.fname = file_extention() for x in range( int(len(select_district.options)) - 5, int(len(select_district.options))): select_district.select_by_index(x) self.cal.page_loading(self.driver) value = self.driver.find_element_by_name( 'myDistrict').get_attribute('value') value = value[4:] + '_' nodata = self.driver.find_element_by_id("errMsg").text if nodata == "No data found": print(select_district.options[x].text, "no data found!") count = count + 1 else: self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = p.get_download_dir( ) + "/" + self.fname.composite_districtwise( ) + management + '_blocks_of_district_' + value.strip( ) + self.cal.get_current_date() + '.csv' print(self.filename) self.cal.page_loading(self.driver) self.file = os.path.isfile(self.filename) os.remove(self.filename) return self.file
def click_download_icon_of_district(self): cal = GetData() count = 0 files = file_extention() cal.click_on_state(self.driver) cal.page_loading(self.driver) self.year ,self.month = cal.get_student_month_and_year_values() self.driver.find_element_by_id(Data.Download).click() time.sleep(3) p = pwd() self.filename = p.get_download_dir()+files.student_download()+self.month+'_'+self.year+'_'+cal.get_current_date()+".csv" print(self.filename) if not os.path.isfile(self.filename): print("Districtwise csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) total = 0 schools = 0 for row in csv.reader(fin): total += int(row[3]) schools += int(row[4]) students = self.driver.find_element_by_id("students").text res = re.sub('\D', "", students) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) if int(res) != total: print("student count mismatched") count = count + 1 if int(sc) != schools: print("school count mismatched") count = count + 1 os.remove(self.filename) return count
def check_time_series_last_30_days(self): cal = GetData() self.p = pwd() count = 0 self.file = file_extention() cal.click_on_state(self.driver) timeperiods = Select(self.driver.find_element_by_id('period')) timeperiods.select_by_visible_text(' Last 30 Days ') cal.page_loading(self.driver) markers = self.driver.find_elements_by_class_name(Data.dots) dots = len(markers) - 1 if markers == 0: print('Markers are not present on screen ') count = count + 1 else: cal.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() time.sleep(5) self.filename = self.p.get_download_dir( ) + '/' + self.file.exception_district() if os.path.isfile(self.filename) != True: print(" Last 30 Days time series csv file is not downloaded") else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) schools = 0 for row in csv.reader(fin): schools += int(row[3]) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) if int(sc) != int(schools): print("school count mismatched", int(sc), int(schools)) count = count + 1 os.remove(self.filename) return count
def select_level_as_Clusters_text(self): self.data = GetData() count = 0 cnames = file_extention() self.data.page_loading(self.driver) levels = Select(self.driver.find_element_by_id(Data.levels)) self.data.page_loading(self.driver) levels.select_by_visible_text(" Cluster ") self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.search).send_keys(cnames.health_card_c1_name()) self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.submt).click() self.data.page_loading(self.driver) actual_name = self.driver.find_element_by_xpath(Data.Cluster_name).text expected_name = cnames.health_card_c1_name() self.data.page_loading(self.driver) if actual_name == expected_name: print(expected_name, "is displayed in health cards ") else: print(actual_name,expected_name,'Passed input records are not displayed in health cards ') count = count + 1 self.driver.refresh() self.data.page_loading(self.driver) return count
def select_level_as_School_id(self): self.data = GetData() count = 0 levels = Select(self.driver.find_element_by_id(Data.levels)) self.data.page_loading(self.driver) levels.select_by_visible_text(" School ") self.data.page_loading(self.driver) sids = file_extention() self.driver.find_element_by_id(Data.search).send_keys(sids.health_card_S1_id()) self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.submt).click() self.data.page_loading(self.driver) if sids.health_card_S1_id() in self.driver.page_source: print(sids.health_card_S1_id(), "is displayed in health cards ") else: print('Passed input records are not displayed in health cards ') count = count + 1 itags = self.driver.find_elements_by_xpath("//div[@id='div3']/div/span") for i in range(len(itags)): print(itags[i].text) self.data.page_loading(self.driver) self.driver.refresh() self.data.page_loading(self.driver) return count
def check_markers_on_block_map(self): cal = GetData() self.fname = file_extention() management = self.driver.find_element_by_id('name').text management = management[16:].lower().strip() self.driver.find_element_by_xpath(Data.hyper_link).click() cal.page_loading(self.driver) self.driver.find_element_by_id('blockbtn').click() cal.page_loading(self.driver) dots = self.driver.find_elements_by_class_name(Data.dots) markers = len(dots) - 1 self.driver.find_element_by_id(Data.Download).click() time.sleep(2) p = pwd() self.filename = p.get_download_dir( ) + "/" + self.fname.exception_block( ) + management + "_overall_allGrades__allBlocks_" + cal.get_current_date( ) + ".csv" if os.path.isfile(self.filename) != True: os.remove(self.filename) return "File Not Downloaded" if os.path.isfile(self.filename) == True: os.remove(self.filename) return markers
def select_subjects_dropdown(self): self.data = GetData() p = pwd() count = 0 self.driver.find_element_by_xpath(Data.hyper_link).click() self.data.page_loading(self.driver) grade = Select(self.driver.find_element_by_id(Data.Grade)) subjects = Select(self.driver.find_element_by_id(Data.Subject)) subcount = len(subjects.options) - 1 files = file_extention() for i in range(len(grade.options)): grade.select_by_index(i) self.data.page_loading(self.driver) gradename = (grade.options[i].text).strip() gradenum = re.sub('\D', '', gradename) for j in range(len(subjects.options)): subjects.select_by_index(j) self.data.page_loading(self.driver) sub = (subjects.options[j].text).strip() self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = p.get_download_dir( ) + '/' + files.pat_gradewise() + gradenum.strip( ) + '_' + sub + '_alldistrict_' + self.data.get_current_date( ) + '.csv' print(self.filename) if os.path.isfile(self.filename) != True: print(files.pat_gradewise() + gradenum.strip(), ' wise csv file is not downloaded') else: file = open(self.filename) read = file.read() os.remove(self.filename) if grade.options[j].text in read: print(grade.options[j].text, "is present") self.data.page_loading(self.driver)
def infra_score_dropdown(self): self.fname = file_extention() self.cal = GetData() self.driver.find_element_by_css_selector('p >span').click() self.cal.page_loading(self.driver) infraoptions = Select(self.driver.find_element_by_id('choose_infra')) for i in range(1, len(infraoptions.options)): infraoptions.select_by_index(i) self.cal.page_loading(self.driver) self.driver.find_element_by_id('download').click() time.sleep(2) p = pwd() self.filename = p.get_download_dir( ) + "/" + self.fname.scmap_district() row_count = 0 with open(self.filename, 'rt') as f: reader = csv.reader(f) data = list(reader) row = len(data) row_count = row print(infraoptions.options[i].text, "is selected and csv file is downloaded") os.remove(self.filename) return row_count - 1
def check_markers_on_clusters_map(self): self.driver.find_element_by_id('clusterbtn').click() cal = GetData() count = 0 management = self.driver.find_element_by_id('name').text management = management[16:].lower().strip() self.fname = file_extention() cal.page_loading(self.driver) dots = self.driver.find_elements_by_class_name(Data.dots) markers = len(dots) - 1 cal.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() time.sleep(3) p = pwd() self.filename = p.get_download_dir( ) + "/" + "teacher_attendance_exception_" + management + "_allClusters_overall_" + cal.get_current_date( ) + ".csv" print(self.filename) if os.path.isfile(self.filename) != True: return "File Not Downloaded" else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) schools = 0 teacher = 0 for row in csv.reader(fin): teacher += int(row[6]) teach = self.driver.find_element_by_id("students").text ta = re.sub('\D', "", teach) print("no of missing data", teacher, ta) if int(teacher) != int(ta): print("Teacher count mismatched", int(teacher), int(ta)) count = count + 1 os.remove(self.filename) return markers, count
def check_last_7_days_districtwise_download(self): self.data = GetData() self.p = pwd() count = 0 self.fname = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() self.data.page_loading(self.driver) periods = Select(self.driver.find_element_by_id(Data.timeperiods)) # periods.select_by_visible_text(' Last 7 Days ') periods.select_by_index(2) self.data.page_loading(self.driver) if self.fname.no_data_found() in self.driver.page_source: print('No Data found for last 7 days') else: self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = self.p.get_download_dir( ) + "/" + self.fname.tpd_teacher_lastweek( ) + self.data.get_current_date() + ".csv" print(self.filename) if os.path.isfile(self.filename) != True: print('Last Day Districtwise csv file is not downloaded ') count = count + 1 else: print('Last day districtwise csv file is downloaded') with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) data = list(csv_reader) row_count = len(data) os.remove(self.filename) time.sleep(2) if row_count == 0: print("records are not found in csv file ") count = count + 1 return count
def check_csv_download(self): p = pwd() self.cal = GetData() self.driver.implicitly_wait(60) self.driver.find_element_by_xpath(Data.hyper_link).click() self.cal.page_loading(self.driver) select_district = Select( self.driver.find_element_by_name('myDistrict')) select_block = Select(self.driver.find_element_by_name('myBlock')) select_cluster = Select(self.driver.find_element_by_name('myCluster')) count = 0 self.fname = file_extention() for x in range(1, int(len(select_district.options)) - 30): select_district.select_by_index(x) self.cal.page_loading(self.driver) for y in range(1, len(select_block.options)): select_block.select_by_index(y) self.cal.page_loading(self.driver) for z in range(1, len(select_cluster.options)): select_cluster.select_by_index(z) self.cal.page_loading(self.driver) nodata = self.driver.find_element_by_id("errMsg").text if nodata == "No data found": print(select_district.options[x].text, select_block.options[y].text, select_cluster.options[z].text, "no data found!") count = count + 1 else: self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = p.get_download_dir( ) + "/" + self.fname.composite_clusterwise() self.cal.page_loading(self.driver) self.file = os.path.isfile(self.filename) os.remove(self.filename) return self.file
def test_districts(self): self.data = GetData() self.p = pwd() self.msg = file_extention() count = 0 self.driver.find_element_by_xpath(Data.hyper_link).click() self.data.page_loading(self.driver) times = Select(self.driver.find_element_by_name('timePeriod')) times.select_by_index(3) self.data.page_loading(self.driver) if self.msg.no_data_found() in self.driver.page_source: print("last 30 days showing no records") else: districts = Select(self.driver.find_element_by_id('choose_dist')) for x in range(len(districts.options) - 3, len(districts.options)): time.sleep(1) districts.select_by_index(x) self.data.page_loading(self.driver) if self.msg.no_data_found() in self.driver.page_source: print(districts.options[x].text, " does not last month records") count = count + 1 self.data.page_loading(self.driver) return count
def test_donwload(self): self.p = GetData() cal = pwd() count = 0 self.fname = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() self.p.page_loading(self.driver) managment_name = self.driver.find_element_by_id('nm').text name = managment_name[16:].strip().lower() self.driver.find_element_by_id(Data.home).click() time.sleep(2) self.p.navigate_to_school_infrastructure_map() self.p.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = cal.get_download_dir( ) + '/' + self.fname.scmap_district( ) + name + '_allDistricts_' + self.p.get_current_date() + '.csv' self.p.page_loading(self.driver) if not os.path.isfile(self.filename): print("Districtwise csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) schools = 0 for row in csv.reader(fin): schools += int(row[0]) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) if int(sc) != int(schools): print("school count mismatched") count = count + 1 os.remove(self.filename) return count
def select_level_as_School_text(self): self.data = GetData() count = 0 snames = file_extention() levels = Select(self.driver.find_element_by_id(Data.levels)) self.data.page_loading(self.driver) levels.select_by_visible_text(" School ") self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.search).send_keys( snames.health_card_S2_name()) self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.submt).click() time.sleep(3) expected_name = snames.health_card_S2_name() self.data.page_loading(self.driver) if expected_name in self.driver.page_source: print(expected_name, "is displayed in health cards ") else: print(expected_name, 'Passed input records are not displayed in health cards ') count = count + 1 self.driver.refresh() self.data.page_loading(self.driver) return count
def test_districts(self): self.data = GetData() self.p = pwd() self.msg = file_extention() count = 0 self.driver.find_element_by_xpath(Data.hyper_link).click() self.data.page_loading(self.driver) times = Select(self.driver.find_element_by_name('timePeriod')) # times.select_by_visible_text(' Last 7 Days ') times.select_by_index(1) time.sleep(2) if self.msg.no_data_found() in self.driver.page_source: print("Last 7 Day are not having records") else: districts = Select(self.driver.find_element_by_id('choose_dist')) for x in range(len(districts.options) - 1, len(districts.options)): time.sleep(1) districts.select_by_index(x) self.data.page_loading(self.driver) if self.msg.no_data_found() in self.driver.page_source: print(districts.options[x].text, " does not last week records") count = count + 1 return count
def check_district_block_cluster(self): cal = GetData() self.fname = file_extention() cal.click_on_state(self.driver) cal.page_loading(self.driver) select_district = Select(self.driver.find_element_by_id('choose_dist')) select_block = Select(self.driver.find_element_by_id('choose_block')) select_cluster = Select( self.driver.find_element_by_id('choose_cluster')) count = 0 for x in range( len(select_district.options) - 1, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) for y in range( len(select_block.options) - 1, len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) for z in range(len(select_cluster.options), len(select_cluster.options)): select_cluster.select_by_index(z) time.sleep(2) cal.page_loading(self.driver) markers = self.driver.find_elements_by_class_name( Data.dots) if len(markers) - 1 == 0: print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "No data") count = count + 1 time.sleep(2) self.driver.find_element_by_id('download').click() time.sleep(3) p = pwd() self.filename = p.get_download_dir( ) + "/" + self.fname.sr_clusterwise() if not os.path.isfile(self.filename): print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) total = 0 for row in csv.reader(fin): row = row[15].strip('\"') row1 = row.replace(',', "") total += int(row1) students = self.driver.find_element_by_id( "students").text res = re.sub('\D', "", students) school = self.driver.find_element_by_id( "schools").text sc = re.sub('\D', "", school) if int(res) != total: print( "District" + select_district. first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "student count mismatched") count = count + 1 if int(sc) != len(markers) - 1: print( "District" + select_district. first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "school count mismatched") count = count + 1 self.remove_csv() return count
def check_district_block_cluster(self): cal = GetData() self.fname = file_extention() cal.click_on_state(self.driver) cal.page_loading(self.driver) select_district = Select(self.driver.find_element_by_id('choose_dist')) select_block = Select(self.driver.find_element_by_id('choose_block')) select_cluster = Select( self.driver.find_element_by_id('choose_cluster')) count = 0 for x in range( len(select_district.options) - 1, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) for y in range( len(select_block.options) - 1, len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) for z in range(len(select_cluster.options), len(select_cluster.options)): select_cluster.select_by_index(z) time.sleep(2) cal.page_loading(self.driver) value = self.driver.find_element_by_id( 'choose_cluster').get_attribute('value') value = value[3:] + '_' markers = self.driver.find_elements_by_class_name( Data.dots) if len(markers) - 1 == 0: print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "No data") count = count + 1 time.sleep(2) self.driver.find_element_by_id('download').click() time.sleep(3) p = pwd() self.filename = p.get_download_dir( ) + "/" + self.fname.sr_clusterwise() + value.strip( ) + '_' + cal.get_current_date() + '.csv' print(self.filename) if not os.path.isfile(self.filename): print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) data = list(csv_reader) row_count = len(data) dots = len(markers) - 1 if dots != row_count: print( 'Markers records and csv file records are not matching ', dots, row_count) count = count + 1 self.remove_csv() return count
def check_districts_block(self): cal = GetData() self.fname = file_extention() cal.click_on_state(self.driver) cal.page_loading(self.driver) select_district = Select(self.driver.find_element_by_id('choose_dist')) select_block = Select(self.driver.find_element_by_id('choose_block')) count = 0 for x in range( len(select_district.options) - 1, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) for y in range(len(select_block.options), len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) value = self.driver.find_element_by_id( 'choose_block').get_attribute('value') value = value[3:] + '_' markers = self.driver.find_elements_by_class_name(Data.dots) if len(markers) - 1 == 0: print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "No Data") count = count + 1 else: time.sleep(2) self.driver.find_element_by_id('download').click() time.sleep(2) p = pwd() self.filename = p.get_download_dir( ) + "/" + self.fname.sr_blockwise() + value.strip( ) + '_' + cal.get_current_date() + '.csv' print(self.filename) if not os.path.isfile(self.filename): print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) total = 0 schools = 0 for row in csv.reader(fin): total += int(row[13].replace(',', '')) schools += int(row[14].replace(',', '')) students = self.driver.find_element_by_id( "students").text res = re.sub('\D', "", students) school = self.driver.find_element_by_id( "schools").text sc = re.sub('\D', "", school) if int(res) != total: print("District" + select_district. first_selected_option.text + "Block" + select_block.first_selected_option.text + "student count mismatched") count = count + 1 if int(sc) != schools: print("District" + select_district. first_selected_option.text + "Block" + select_block.first_selected_option.text + "school count mismatched") count = count + 1 self.remove_csv() return count
def check_with_clusters_all_report(self): self.data = GetData() count = 0 dnames = file_extention() levels = Select(self.driver.find_element_by_id(Data.levels)) self.data.page_loading(self.driver) levels.select_by_visible_text(" Cluster ") self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.search).send_keys( dnames.health_card_c2_name()) self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.submt).click() time.sleep(5) self.data.page_loading(self.driver) self.driver.find_element_by_id(Data.access_infra).click() time.sleep(5) self.data.page_loading(self.driver) if 'school-infra-map' in self.driver.current_url: print("School infrastructure map report is displayed ") else: print("Access to School infra report is failed ") count = count + 1 self.driver.find_element_by_id(Data.report_infracard).click() self.data.page_loading(self.driver) if dnames.health_card_c2_name() in self.driver.page_source: print("Reverting back to health card page is displayed ") else: print( "Failed in revert back from report page to health card page ") count = count + 1 self.data.page_loading(self.driver) time.sleep(5) self.driver.find_element_by_id(Data.access_student).click() time.sleep(5) self.data.page_loading(self.driver) if 'student-attendance' in self.driver.current_url: print("Student Attendance report is displayed ") else: print("Access to Student Attendance report is failed ") count = count + 1 self.driver.find_element_by_id(Data.report_stdcard).click() self.data.page_loading(self.driver) if dnames.health_card_c2_name() in self.driver.page_source: print("Reverting back to health card page is displayed ") else: print( "Failed in revert back from report page to health card page ") count = count + 1 self.data.page_loading(self.driver) time.sleep(5) self.driver.find_element_by_id(Data.access_semester).click() time.sleep(5) self.data.page_loading(self.driver) if 'semester-report' in self.driver.current_url: print("semester-report is displayed ") else: print("Access to semester-report is failed ") count = count + 1 self.driver.find_element_by_id(Data.report_semcard).click() self.data.page_loading(self.driver) if dnames.health_card_c2_name() in self.driver.page_source: print("Reverting back to health card page is displayed ") else: print( "Failed in revert back from report page to health card page ") count = count + 1 self.data.page_loading(self.driver) time.sleep(5) self.driver.find_element_by_id(Data.access_pat).click() time.sleep(5) self.data.page_loading(self.driver) if 'pat-report' in self.driver.current_url: print("pat-report is displayed ") else: print("Access to pat-report is failed ") count = count + 1 self.driver.find_element_by_id(Data.report_patcard).click() self.data.page_loading(self.driver) if dnames.health_card_c2_name() in self.driver.page_source: print("Reverting back to health card page is displayed ") else: print( "Failed in revert back from report page to health card page ") count = count + 1 self.data.page_loading(self.driver) time.sleep(5) self.driver.find_element_by_id(Data.access_crc).click() time.sleep(5) self.data.page_loading(self.driver) if 'crc-report' in self.driver.current_url: print("crc-report is displayed ") else: print("Access to crc-report is failed ") count = count + 1 self.driver.find_element_by_id(Data.report_crccard).click() self.data.page_loading(self.driver) if dnames.health_card_c2_name() in self.driver.page_source: print("Reverting back to health card page is displayed ") else: print( "Failed in revert back from report page to health card page ") count = count + 1 self.data.page_loading(self.driver) time.sleep(5) self.driver.find_element_by_id(Data.access_udise).click() time.sleep(5) self.data.page_loading(self.driver) if 'udise-report' in self.driver.current_url: print("UDISE-report is displayed ") else: print("Access to udise-report is failed ") count = count + 1 self.driver.find_element_by_id(Data.report_udisecard).click() self.data.page_loading(self.driver) if dnames.health_card_c2_name() in self.driver.page_source: print("Reverting back to health card page is displayed ") else: print( "Failed in revert back from report page to health card page ") count = count + 1 self.driver.refresh() self.data.page_loading(self.driver) return count
def check_download_csv1(self): p = pwd() self.cal = GetData() self.driver.implicitly_wait(100) self.driver.find_element_by_xpath(Data.hyper_link).click() self.cal.page_loading(self.driver) select_district = Select(self.driver.find_element_by_id('choose_dist')) select_block = Select(self.driver.find_element_by_id('choose_block')) select_cluster = Select( self.driver.find_element_by_id('choose_cluster')) count = 0 management = self.driver.find_element_by_id('nm').text management = management[16:].lower().strip() self.fname = file_extention() for x in range( int(len(select_district.options)) - 1, int(len(select_district.options))): select_district.select_by_index(x) self.cal.page_loading(self.driver) for y in range( len(select_block.options) - 1, len(select_block.options)): select_block.select_by_index(y) self.cal.page_loading(self.driver) time.sleep(2) for z in range(1, len(select_cluster.options)): select_cluster.select_by_index(z) self.cal.page_loading(self.driver) time.sleep(2) value = self.driver.find_element_by_id( 'choose_cluster').get_attribute('value') # values = value[3:]+'_' value = value.split(":") nodata = self.driver.find_element_by_id("errMsg").text markers = self.driver.find_elements_by_class_name( Data.dots) if len(markers) - 1 == 0: print(select_cluster.options[z].text, "does not contains markers on map") else: self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = p.get_download_dir( ) + "/" + "UDISE_report_" + management + "_Infrastructure_Score_schools_of_cluster_" + value[ 1].strip() + '_' + self.cal.get_current_date( ) + '.csv' print(self.filename) if not os.path.isfile(self.filename): print(select_district.options[x].text, select_block.options[y].text, select_cluster.options[z].text, "csv file is not downloaded!") count = count + 1 schools = self.driver.find_element_by_id('footer').text sc = re.sub('\D', '', schools) if len(markers) - 1 != int(sc): print( 'Total no of school mis match found with no of markers ', len(markers), sc) count = count + 1 os.remove(self.filename) return count
def Clusters_select_box(self): self.p = pwd() self.load = GetData() count = 0 management = self.driver.find_element_by_id('nm').text management = management[16:].lower().strip() self.fname = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() self.load.page_loading(self.driver) self.year, self.month = self.load.get_pat_month_and_year_values() clust = Select(self.driver.find_element_by_id(Data.cluster_dropdown)) dists = Select(self.driver.find_element_by_id(Data.district_dropdown)) Blocks = Select(self.driver.find_element_by_id(Data.blocks_dropdown)) grade = Select(self.driver.find_element_by_id(Data.grade)) self.load.page_loading(self.driver) for m in range(2, len(grade.options)): grade.select_by_index(m) gradename = grade.options[m].text gradenum = re.sub('\D', '', gradename).strip() self.load.page_loading(self.driver) for i in range(len(dists.options) - 1, len(dists.options)): dists.select_by_index(i) self.load.page_loading(self.driver) for j in range(len(Blocks.options) - 1, len(Blocks.options)): Blocks.select_by_index(j) self.load.page_loading(self.driver) for k in range(1, len(clust.options)): clust.select_by_index(k) self.load.page_loading(self.driver) value = self.driver.find_element_by_id( Data.cluster_dropdown).get_attribute('value') values = value[3:] + '_' self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = self.p.get_download_dir() + '/' + self.fname.patlo_schools()+management+'_' + gradenum + "_schools_of_cluster_" + values.strip() + self.month + '_' + self.year + '_' + \ self.load.get_current_date() + '.csv' print(self.filename) file = os.path.isfile(self.filename) if file != True: print( clust.options[k].text, 'Cluster wise records csv file is not downloaded' ) count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) data = list(csv_reader) row_count = len(data) os.remove(self.filename) tablecount = self.driver.find_elements_by_tag_name( 'tr') records = int(len(tablecount)) - 2 time.sleep(2) if row_count != records: print( dists.options[i].text, Blocks.options[j].text, clust.options[k].text, "records count mismatch in downloaded file and table records" ) count = count + 1 return count
def check_last7_district_block_cluster(self): cal = GetData() self.fname = file_extention() cal.click_on_state(self.driver) management = self.driver.find_element_by_id('name').text management = management[16:].lower().strip() period = Select(self.driver.find_element_by_id('period')) period.select_by_index(3) time.sleep(3) if 'No Data found' in self.driver.page_source: print(period.first_selected_option.text, ' is not having data') else: timeseries = period.first_selected_option.text timeseries = timeseries.lower().replace(" ", '_') select_district = Select( self.driver.find_element_by_id('choose_dist')) select_block = Select( self.driver.find_element_by_id('choose_block')) select_cluster = Select( self.driver.find_element_by_id('choose_cluster')) count = 0 for x in range( len(select_district.options) - 1, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) for y in range( len(select_block.options) - 1, len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) for z in range( len(select_cluster.options) - 2, len(select_cluster.options)): select_cluster.select_by_index(z) time.sleep(2) cal.page_loading(self.driver) value = self.driver.find_element_by_id( 'choose_cluster').get_attribute('value') value = value.split(":") values = value[1].strip() + '_' markers = self.driver.find_elements_by_class_name( Data.dots) if len(markers) - 1 == 0: print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "No data") count = count + 1 time.sleep(2) self.driver.find_element_by_id('download').click() time.sleep(3) p = pwd() self.filename = p.get_download_dir( ) + "/" + self.fname.pat_clusterwise( ) + management + '_' + timeseries + '_allGrades__schools_of_cluster_' + values + cal.get_current_date( ) + '.csv' print(self.filename) if not os.path.isfile(self.filename): print("District" + select_district.first_selected_option.text + "Block" + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + "csv is not downloaded") count = count + 1 else: data = pd.read_csv(self.filename) student = data['Total Students'].sum() schools = data['Total Schools'].sum() attended = data['Students Attended'].sum() students = self.driver.find_element_by_id( "students").text studs = re.sub('\D', "", students) students = self.driver.find_element_by_id( "students").text studs = re.sub('\D', "", students) school = self.driver.find_element_by_id( "schools").text sc = re.sub('\D', "", school) attend = self.driver.find_element_by_id( "studentsAttended").text atd = re.sub('\D', "", attend) print('value on footer', student, schools, attended) print('value on csv file', studs, sc, atd) if int(studs) != int(student): print( "District " + select_district.first_selected_option.text + "Block " + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + " student count mismatched", int(studs), int(student)) count = count + 1 if int(sc) != int(schools): print( "District " + select_district.first_selected_option.text + "Block " + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + " school count mismatched", int(sc), int(schools)) count = count + 1 if int(atd) != int(attended): print( "District " + select_district.first_selected_option.text + "Block " + select_block.first_selected_option.text + "Cluster" + select_cluster.first_selected_option.text + " student attended mismatched", int(atd), int(attended)) count = count + 1 os.remove(self.filename) return count
def check_last_7_days_districts(self): cal = GetData() count = 0 self.fname = file_extention() self.driver.find_element_by_xpath(Data.hyper_link).click() cal.page_loading(self.driver) times = Select(self.driver.find_element_by_id('period')) management = self.driver.find_element_by_id('name').text management = management[16:].lower().strip() for i in range(3, len(times.options)): times.select_by_index(i) timeseries = times.options[i].text timeseries = timeseries.replace(' ', '_') time.sleep(3) select_district = Select( self.driver.find_element_by_id('choose_dist')) count = 0 for x in range(1, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) value = self.driver.find_element_by_id( 'choose_dist').get_attribute('value') value = value.split(":") values = value[1].strip() markers = self.driver.find_elements_by_class_name(Data.dots) if (len(markers) - 1) == 0: print("District " + select_district.first_selected_option.text + " no data") count = count + 1 else: self.driver.find_element_by_id('download').click() p = pwd() time.sleep(5) self.filename = p.get_download_dir( ) + "/" + self.fname.pat_districtwise( ) + management + '_' + timeseries.lower( ) + '_allGrades__blocks_of_district_' + values + '_' + cal.get_current_date( ) + '.csv' print(self.filename) if not os.path.isfile(self.filename): print("District " + select_district.first_selected_option.text + " csv is not downloaded") count = count + 1 else: # with open(self.filename) as fin: # csv_reader = csv.reader(fin, delimiter=',') # header = next(csv_reader) # student = 0 # schools = 0 # attended = 0 # for row in csv.reader(fin): # student += int(row[5]) # schools += int(row[7]) # attended += int(row[6]) # print(self.filename, ':', student, schools, attended) data = pd.read_csv(self.filename) student = data['Total Students'].sum() schools = data['Total Schools'].sum() attended = data['Students Attended'].sum() students = self.driver.find_element_by_id( "students").text studs = re.sub('\D', "", students) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) attend = self.driver.find_element_by_id( "studentsAttended").text atd = re.sub('\D', "", attend) print('value on footer', student, schools, attended) print('value on csv file', studs, sc, atd) if int(studs) != int(student): print( "District " + select_district.first_selected_option.text + " student count mismatched", int(studs), int(student)) count = count + 1 if int(sc) != int(schools): print( "District " + select_district.first_selected_option.text + " school count mismatched", int(sc), int(schools)) count = count + 1 if int(atd) != int(attended): print( "District " + select_district.first_selected_option.text + " student attended mismatched", int(atd), int(attended)) count = count + 1 os.remove(self.filename) return count
def check_download_csv1(self): p = pwd() self.cal = GetData() self.fname = file_extention() self.driver.implicitly_wait(100) self.driver.find_element_by_xpath(Data.hyper_link).click() self.cal.page_loading(self.driver) select_district = Select(self.driver.find_element_by_id('choose_dist')) select_block = Select(self.driver.find_element_by_id('choose_block')) select_cluster = Select( self.driver.find_element_by_id('choose_cluster')) count = 0 for x in range( int(len(select_district.options)) - 1, int(len(select_district.options))): select_district.select_by_index(x) self.cal.page_loading(self.driver) for y in range( len(select_block.options) - 1, len(select_block.options)): select_block.select_by_index(y) self.cal.page_loading(self.driver) for z in range(1, len(select_cluster.options)): select_cluster.select_by_index(z) self.cal.page_loading(self.driver) value = self.driver.find_element_by_id( 'choose_cluster').get_attribute('value') cvalue = value[3:] + '_' nodata = self.driver.find_element_by_id("errMsg").text markers = self.driver.find_elements_by_class_name( Data.dots) if len(markers) - 1 == 0: print(select_cluster.options[z].text, "does not contains markers on map") else: self.driver.find_element_by_id(Data.Download).click() time.sleep(3) self.filename = p.get_download_dir( ) + "/" + self.fname.scmap_clusterwise( ) + cvalue.strip() + self.cal.get_current_date( ) + '.csv' print(self.filename) if not os.path.isfile(self.filename): print(select_cluster.options[z].text, "csv file is not downloaded!") else: with open(self.filename) as fin: csv_reader = csv.reader(fin) data = list(csv_reader) countrecords = len(data) # header = next(csv_reader) # total = 0 # for row in csv.reader(fin): # total += int(row[2]) school = self.driver.find_element_by_id( "schools").text sc = re.sub('\D', "", school) if int(sc) != int(countrecords) - 1: print(select_block.options[y].text, "schools:", int(countrecords) - 1, int(sc), "mismatch found") count = count + 1 os.remove(self.filename) return count
def check_districts_csv_download(self): cal = GetData() files = file_extention() cal.click_on_state(self.driver) self.year, self.month = cal.get_student_month_and_year_values() cal.page_loading(self.driver) timeseries = Select(self.driver.find_element_by_id('period')) timeseries.select_by_visible_text(' Year and Month ') select_district = Select( self.driver.find_element_by_name('myDistrict')) count = 0 for x in range( len(select_district.options) - 5, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) val = self.driver.find_element_by_name('myDistrict').get_attribute( 'value') distval = val[5:] + '_' markers = self.driver.find_elements_by_class_name(Data.dots) if len(markers) - 1 == 0: print("District" + select_district.first_selected_option.text + "no data") count = count + 1 time.sleep(2) self.driver.find_element_by_id('download').click() time.sleep(2) p = pwd() self.filename = p.get_download_dir( ) + files.student_districtwise_download() + distval.strip( ) + self.month + "_" + self.year + '_' + cal.get_current_date( ) + ".csv" if not os.path.isfile(self.filename): print("District" + select_district.first_selected_option.text + "csv is not downloaded") count = count + 1 else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) total = 0 schools = 0 for row in csv.reader(fin): total += int(row[5]) schools += int(row[6]) students = self.driver.find_element_by_id("students").text res = re.sub('\D', "", students) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) if int(res) != total: print("District" + select_district.first_selected_option.text + "student count mismatched") count = count + 1 if int(sc) != schools: print("District" + select_district.first_selected_option.text + "school count mismatched") count = count + 1 self.remove_csv() return count