def check_district_block_cluster(self): cal = GetData() cal.click_on_state(self.driver) cal.page_loading(self.driver) management = self.driver.find_element_by_id('name').text name = management[16:].strip().lower() self.year, self.month = cal.get_student_month_and_year_values() 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 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(1, len(select_cluster.options)): select_cluster.select_by_index(z) cal.page_loading(self.driver) value = self.driver.find_element_by_name( 'myCluster').get_attribute('value') cluvalue = (value[3:] + '_').replace(':', '').strip() markers = self.driver.find_elements_by_class_name( Data.dots) files = file_extention() 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( ) + files.student_clusterwise_download( ) + name + '_schoolPerClusters_of_cluster_' + cluvalue.strip( ) + self.month + "_" + self.year + '_' + 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: df = pd.read_csv(self.filename) student = df['Number Of Students'].sum() students = self.driver.find_element_by_id( "students").text std = re.sub('\D', "", students) school = self.driver.find_element_by_id("schools").text sc = re.sub('\D', "", school) if int(std) != 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") 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 os.remove(self.filename) return count
def check_district(self): cal = GetData() cal.click_on_state(self.driver) cal.page_loading(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(4) time.sleep(3) self.year, self.month = cal.pat_year_month_firstselected() cal.page_loading(self.driver) select_district = Select(self.driver.find_element_by_id('choose_dist')) 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) value = self.driver.find_element_by_id( 'choose_dist').get_attribute('value') value = value[4:] + '_' markers = self.driver.find_elements_by_class_name(Data.dots) time.sleep(3) 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() time.sleep(4) p = pwd() file = file_extention() self.filename = p.get_download_dir( ) + "/" + file.pat_districtwise( ) + management + "_" + self.year + '_' + self.month + '_allGrades__blocks_of_district_' + 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 + "csv is not downloaded") count = count + 1 else: values = pd.read_csv(self.filename) school = int(values['Total Schools']) students = int(values['Total Students']) attend = int(values['Students Attended']) schools = self.driver.find_element_by_id('schools').text scs = re.sub('\D', '', schools) student = self.driver.find_element_by_id('students').text stds = re.sub('\D', '', student) attended = self.driver.find_element_by_id( 'studentsAttended').text attds = re.sub('\D', '', attended) if int(scs) != int(school): print( "schools count in footer and csv file records count mismatched", int(scs), int(schools)) count = count + 1 if int(stds) != int(students): print( "student count in footer and csv file records count mismatched", int(scs), int(schools)) count = count + 1 if int(attds) != int(attend): print( "Attended count in footer and csv file records count mismatched", int(scs), int(schools)) count = count + 1 os.remove(self.filename) return count
def check_csv_download4(self): cal = GetData() 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(int(3 * len(select_district.options) / 4), len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) for y in range(1, len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) for z in range(1, len(select_cluster.options)): select_cluster.select_by_index(z) cal.page_loading(self.driver) time.sleep(2) 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 self.driver.find_element_by_id('download').click() time.sleep(3) p = pwd() self.filename = p.get_download_dir_SR_Download4( ) + "/School_per_cluster_report_sem_2.csv" 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_csv4() return count
def setUpClass(self): self.data = GetData() self.driver = self.data.get_driver() self.data.open_cqube_appln(self.driver) self.data.page_loading(self.driver)
def test_schoolinfra(self): self.p = GetData() self.driver.find_element_by_xpath(Data.hyper_link).click() self.p.page_loading(self.driver)
def click_on_blocks_click_on_home_icon(self): self.driver.find_element_by_id(Data.sr_block_btn).click() cal = GetData() cal.page_loading(self.driver)
def check_markers_on_clusters_map(self): self.driver.find_element_by_id(Data.sr_cluster_btn).click() cal = GetData() cal.page_loading(self.driver) dots = self.driver.find_elements_by_class_name(Data.dots) return dots
def courserecords_of_last7days(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) timeperiod = Select(self.driver.find_element_by_name('timePeriod')) timeperiod.select_by_visible_text(' Last 7 Days ') self.data.page_loading(self.driver) if self.msg.no_data_available() in self.driver.page_source: print("Last 7 days dont have records") else: self.data.page_loading(self.driver) collnames = Select( self.driver.find_element_by_name('collectionName')) for i in range(1, len(collnames.options)): time.sleep(1) collnames.select_by_index(i) name = "collectionType_textbook_data_of" + collnames.options[ i].text fname = name.replace(' ', '_') time.sleep(2) self.driver.find_element_by_id(Data.Download).click() time.sleep(3) cname = fname.rstrip('_') print(cname, "cname") self.filename = self.p.get_download_dir( ) + '/' + cname + '.csv' file = os.path.isfile(self.filename) if file == True: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) content = 0 for row in csv.reader(fin): content += int(row[4]) usage = self.driver.find_element_by_id( "totalCount").text tsc = re.sub('\D', "", usage) if int(tsc) != content: print(collnames.options[i].text, ":", int(content), int(tsc), "usage content mismatch found") count = count + 1 os.remove(self.filename) else: alname = fname[:-1] + '.csv' print('current fname', alname) self.filename = self.p.get_download_dir() + '/' + alname with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) content = 0 for row in csv.reader(fin): content += int(row[4]) usage = self.driver.find_element_by_id( "totalCount").text tsc = re.sub('\D', "", usage) if int(tsc) != content: print(collnames.options[i].text, ":", int(content), int(tsc), "usage content mismatch found") count = count + 1 os.remove(self.filename) return count
def setUpClass(self): self.data = GetData() self.logger = self.data.get_regression_log("sr") self.driver = self.data.get_driver() self.data.open_cqube_appln(self.driver) self.data.login_cqube(self.driver)
def test_districtwise(self): self.p = GetData() self.driver.find_element_by_xpath(Data.hyper_link).click() self.p.page_loading(self.driver) self.driver.find_element_by_id(Data.Download).click() self.p.page_loading(self.driver)
def test_logout(self): self.p = GetData() self.driver.find_element_by_xpath(Data.hyper).click() self.p.page_loading(self.driver) self.driver.find_element_by_id(Data.logout).click()
def check_district_block_cluster(self): self.cal = GetData() self.driver.implicitly_wait(50) self.cal.click_on_state(self.driver) 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(1, len(select_district.options)): 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) time.sleep(2) 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("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 self.driver.find_element_by_id('download').click() time.sleep(3) p = pwd() self.filename = p.get_download_dir( ) + "/School_per_cluster_report.csv" 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 schools = 0 for row in csv.reader(fin): total += int(row[9]) # schools += int(row[5]) 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 ,select_cluster.first_selected_option.text + "school count mismatched") # count = count + 1 self.remove_csv() return count
def setUpClass(self): self.cal = GetData() self.log_summary = self.cal.get_s3_files("log_summary")
def test_options_times(self): data = GetData() data.page_loading(self.driver) times = Select(self.driver.find_element_by_id('period')) count = len(times.options) return count
def setUpClass(self): self.data = GetData() self.driver = self.data.get_driver() self.driver.implicitly_wait(100) self.driver.get( 'https://www.mponline.gov.in/Portal/Services/NTSE/NTSEReport.aspx')
def check_csv_download(self): p = pwd() self.cal = GetData() self.fname =file_extention() self.driver.implicitly_wait(60) self.driver.find_element_by_xpath(Data.hyper_link).click() self.cal.page_loading(self.driver) self.year,self.month = self.cal.get_crc_month_and_year_values() management_name = self.driver.find_element_by_id('nm').text name = management_name[16:].strip().lower() select_district = Select(self.driver.find_element_by_name('myDistrict')) select_block = Select(self.driver.find_element_by_name('myBlock')) 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(1, len(select_block.options)): select_block.select_by_index(y) self.cal.page_loading(self.driver) cluval = self.driver.find_element_by_name('myBlock').get_attribute('value') cluval = cluval.split(":") value = cluval[1].strip() 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,"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.crc_blockwise()+name+"_"+self.year+"_"+str(self.month)+'_clusters_of_block_' + value.strip() +"_"+ self.cal.get_current_date() + '.csv' print(self.filename) if not os.path.isfile(self.filename): print(select_block.options[y].text, " csv file not downloaded") else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) tschools = 0 vsts = 0 vstd = 0 for row in csv.reader(fin): tschools += int(row[0]) vsts += int(row[2]) vstd += int(row[1]) totalschools = self.driver.find_element_by_id("schools").text visited = self.driver.find_element_by_id("visited").text visits = self.driver.find_element_by_id("visits").text tsc = re.sub('\D', "", totalschools) vs = re.sub('\D', "", visits) vd = re.sub('\D', "", visited) if int(tsc) != tschools: print(select_district.options[x].text, ":", "total no of schools :", tschools, int(tsc), "records are mismatch found") count = count + 1 if int(vs) != vsts: print(select_district.options[x].text, ":", "total no of visits :", int(vs), vsts, "records are mismatch found") count = count + 1 if int(vd) != vstd: print(select_district.options[x].text, ":", "total no of visits :", int(vd), vstd, "records are mismatch found") count = count + 1 os.remove(self.filename) return count
def test_graph_and_table_present_on_school_infra(self): self.p = GetData() self.driver.find_element_by_xpath(Data.hyper).click() self.p.page_loading(self.driver)
def get_each_management_wise_exception_list(self): self.data = GetData() self.driver.implicitly_wait(200) management_types = Select(self.driver.find_element_by_id('management')) # count = len(management_types.options)-1 count = 0 management_types.select_by_index(1) name = management_types.options[1].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) overall = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(3) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(2) name = management_types.options[2].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) central = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(3) name = management_types.options[3].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) Govt = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(4) name = management_types.options[4].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) granted = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(5) name = management_types.options[5].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) model = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(6) name = management_types.options[6].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) private = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(7) name = management_types.options[7].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) social = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) management_types = Select(self.driver.find_element_by_id('management')) management_types.select_by_index(8) name = management_types.options[8].text time.sleep(4) self.driver.find_element_by_id('isdata').click() time.sleep(4) print(name, 'is selected and downloading csv file') self.driver.find_element_by_xpath( '//*[@id="table"]/tbody/tr/td[2]/button').click() time.sleep(30) self.p = pwd() self.filename = self.p.get_download_dir() + '/school_invalid_data.csv' if os.path.isfile(self.filename) != True: print(name, 'Download exception list 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) tribal = row_count if int(row_count) > 0: print(name, row_count, 'Exception records are present ') else: print(name, 'exception records are not present') count = count + 1 # overall = 0+row_count # if management_types.options[i].text in data: # print(name , 'having exception list') # else: # print(name,"selected management exception is not present in downloaded file") # count = count + 1 os.remove(self.filename) self.driver.find_element_by_id('homeBtn').click() time.sleep(5) total_managemnt = int(social + tribal + granted + Govt + central + private + model) if int(overall) != total_managemnt: print(overall, total_managemnt, 'exceptions list are not equal to all other management') count = count + 1 return count
def click_HomeButton(self): self.driver.find_element_by_id(Data.homeicon).click() cal = GetData() cal.page_loading(self.driver) return self.driver.page_source
def test_link(self): self.p = GetData() self.driver.implicitly_wait(10) self.driver.find_element_by_css_selector('p >span').click() self.p.page_loading(self.driver)
def check_last30_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(2) 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(1, 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.sr_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: 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_school_level_csv_download(self): cal = GetData() cal.click_on_state(self.driver) 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 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(1, len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) time.sleep(2) for z in range(1, len(select_cluster.options)): select_cluster.select_by_index(z) cal.page_loading(self.driver) time.sleep(2) 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(5) p = pwd() self.filename = p.get_download_dir( ) + "/Schools_per_cluster_report_" + self.month + "_" + self.year + ".csv" 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 schools = 0 for row in csv.reader(fin): total += int(row[9].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, int(res), total, "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 + "school count mismatched") count = count + 1 self.remove_csv() return count
def setUpClass(self): self.data = GetData() self.driver = self.data.get_driver() self.data.open_cqube_appln(self.driver) self.data.login_cqube(self.driver)
def check_csv_download(self): cal = GetData() cal.click_on_state(self.driver) cal.page_loading(self.driver) management_name = self.driver.find_element_by_id('name').text name = management_name[16:].strip().lower() self.year, self.month = cal.get_student_month_and_year_values() select_district = Select( self.driver.find_element_by_name('myDistrict')) select_block = Select(self.driver.find_element_by_name('myBlock')) count = 0 files = file_extention() for x in range( len(select_district.options) - 2, len(select_district.options)): select_district.select_by_index(x) cal.page_loading(self.driver) for y in range(1, len(select_block.options)): select_block.select_by_index(y) cal.page_loading(self.driver) value = self.driver.find_element_by_name( 'myBlock').get_attribute('value') value = value[4:] + '_' time.sleep(2) 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 time.sleep(2) self.driver.find_element_by_id('download').click() time.sleep(4) p = pwd() self.filename = p.get_download_dir( ) + '/' + files.teacher_blockwise_download( ) + name + '_clusterPerBlocks_of_block_' + value.strip( ) + self.month + "_" + self.year + '_' + 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[7].replace(',', '')) schools += int(row[8].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, int(res), total, "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_csv_download(self): p = pwd() self.cal = GetData() self.fname = file_extention() 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 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) 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.crc_clusterwise() if not os.path.isfile(self.filename): print(select_cluster.options[z].text, " csv file not downloaded") else: with open(self.filename) as fin: csv_reader = csv.reader(fin, delimiter=',') header = next(csv_reader) tschools = 0 vsts = 0 vstd = 0 for row in csv.reader(fin): tschools += int(row[0]) vsts += int(row[2]) vstd += int(row[1]) totalschools = self.driver.find_element_by_id( "schools").text visited = self.driver.find_element_by_id( "visited").text visits = self.driver.find_element_by_id( "visits").text tsc = re.sub('\D', "", totalschools) vs = re.sub('\D', "", visits) vd = re.sub('\D', "", visited) if int(tsc) != tschools: print(select_district.options[x].text, ":", "total no of schools :", tschools, int(tsc), "records are mismatch found") count = count + 1 if int(vs) != vsts: print(select_district.options[x].text, ":", "total no of visits :", int(vs), vsts, "records are mismatch found") count = count + 1 if int(vd) != vstd: print(select_district.options[x].text, ":", "total no of visits :", int(vd), vstd, "records are mismatch found") count = count + 1 self.remove_csv1() return count
def test_districtwise(self): p = pwd() self.cal = GetData() self.driver.implicitly_wait(20) 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')) count = 0 self.fname = file_extention() for x in range(1, 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') distval = value[3:] + '_' 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.crc_districtwise() + distval.strip( ) + self.cal.get_current_date() + '.csv' if os.path.isfile(self.filename) != True: print(select_district.options[x].text, '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) tschools = 0 vsts = 0 vstd = 0 for row in csv.reader(fin): tschools += int(row[0]) vsts += int(row[2]) vstd += int(row[1]) totalschools = self.driver.find_element_by_id( "schools").text visited = self.driver.find_element_by_id( "visited").text visits = self.driver.find_element_by_id("visits").text tsc = re.sub('\D', "", totalschools) vs = re.sub('\D', "", visits) vd = re.sub('\D', "", visited) if int(tsc) != tschools: print(select_district.options[x].text, ":", "total no of schools :", tschools, int(tsc), "records are mismatch found") if int(vs) != vsts: print(select_district.options[x].text, ":", "total no of visits :", int(vs), vsts, "records are mismatch found") if int(vd) != vstd: print(select_district.options[x].text, ":", "total no of visits :", int(vd), vstd, "records are mismatch found") os.remove(self.filename) return count
def setUpClass(self): self.data = GetData() self.logger = self.data.get_functional_log("crc") self.driver = self.data.get_driver() self.data.open_cqube_appln(self.driver) self.data.login_cqube(self.driver)
def test_base_directory_created(self): data = GetData() os.chdir(data.get_basedir()) self.assertTrue(os.path.isdir("cqube"), "cQube base directory is not created")
def setUpClass(self): self.cal = GetData()
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) management_name = self.driver.find_element_by_id('nm').text name = management_name[16:].strip().lower() 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') 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( ) + "/" + self.fname.scmap_clusterwise( ) + name + '_schools_of_cluster_' + value[1].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!") count = count + 1 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