def TaskFilter_for_PDM(self, status): self.log.log_to_file("INFO", "Executing ProductionDataMonitoring.TaskFilter()") report_file_utility_object = ReportFileUtility(self.v_task_type) v_row_count = self.v_input_sheet.max_row if status == 'InProgress': self.log.log_to_file("INFO", "Select InProgress task from input sheet from ProductionDataMonitoring.TaskFilter()") excel_operations_object = ExcelOperations(self.v_task_type, self.v_input_sheet) for count in range(1, v_row_count + 1): v_start_time = time.time() if ((self.v_input_sheet.cell(row=count, column=5).value) == "InProgress"): try: v_supplier_name = self.v_input_sheet.cell(row=count, column=1).value v_retailer_name = self.v_input_sheet.cell(row=count, column=2).value v_doc_type=self.v_input_sheet.cell(row=count, column=3).value v_date=self.v_input_sheet.cell(row=count, column=4).value self.search_process_for_PDM(v_supplier_name,v_retailer_name,v_doc_type,v_date, self.v_input_sheet,count) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) v_end_time = time.time() report_file_utility_object.update_sheet(self.v_username, 1, math.floor(v_end_time - v_start_time),str(datetime.date.today()),"PASS") v_found_parcels= self.v_input_sheet.cell(row=count, column=6).value #logic for change status of task if int(v_found_parcels)>=4: excel_operations_object.set_value(count,5,"Monitoring done") self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) except Exception: self.log.log_to_file("ERROR", "Error in ProductionDataMonitoring.TaskFilter()") v_end_time = time.time() report_file_utility_object.update_sheet(self.v_username, 1, math.floor(v_end_time - v_start_time), str(datetime.date.today()), "FAIL") self.v_driver.refresh() time.sleep(4)
def TaskFilter(self, path, status): self.lo.log_to_file("INFO", "Executing ProductionDataMonitoring.TaskFilter()") rf = ReportFileUtility(self.v_task_type) row_count = self.v_input_sheet.max_row if status == 'InProgress': self.lo.log_to_file( "INFO", "select InProgress task from input sheet from ProductionDataMonitoring.TaskFilter()" ) eo = ExcelOperations(self.v_task_type, self.v_input_sheet) for count in range(1, row_count + 1): v_start_time = time.time() if ((self.v_input_sheet.cell(row=count, column=5).value) == "InProgress"): supplier_name = self.v_input_sheet.cell(row=count, column=1).value retailer_name = self.v_input_sheet.cell(row=count, column=2).value doc_type = self.v_input_sheet.cell(row=count, column=3).value date = self.v_input_sheet.cell(row=count, column=4).value tto = TransactionTrackerOperations(self.v_task_type, self.v_driver, self.lo) tto.search_process_for_PDM(supplier_name, retailer_name, doc_type, date, self.v_input_sheet, count) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) v_end_time = time.time() rf.update_sheet(self.v_username, 1, math.floor(v_end_time - v_start_time), str(datetime.date.today())) found_parcels = self.v_input_sheet.cell(row=count, column=6).value #logic for change status of task if int(found_parcels) >= 4: eo.set_value(count, 5, "Monitoring done") self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) if status == 'Monitoring done': for count in range(1, row_count + 1): if ((self.v_input_sheet.cell( row=count, column=5).value) == "Monitoring done"): print(self.v_input_sheet.cell(row=count, column=2).value)
def get_parcel(self, input_sheet,row): self.lo.log_to_file("INFO", "Executing method 'get_parcel' from TransactionTrackerOperations") so = SeleniumOperations(self.v_task_type, self.driver, self.lo) eo = ExcelOperations(self.v_task_type, input_sheet) comment = ' ' #print("========================================================================================") parcel_count = int(self.driver.find_element_by_xpath("html/body/div[1]/section/section/div/div/section/div/spsui-feedback-container[4]/result-feedback/div/div/div/div[1]/strong").text) print("Total unique parcel count is: "+str(parcel_count)) for i in range (parcel_count): document_id=self.driver.find_element_by_xpath(".//*[@id='parentTablesContainer']/div[2]/table/tbody[1]/tr["+str(i+1)+"]/td[5]").text status=self.driver.find_element_by_xpath(".//*[@id='parentTablesContainer']/div[2]/table/tbody[1]/tr["+str(i+1)+"]/td[1]").text parcel_ID=self.driver.find_element_by_xpath(".//*[@id='parentTablesContainer']/div[1]/table/tbody/tr["+str(i+1)+"]/td[2]/span/a").text print(str(i+1)+") Parcel ID: "+str(parcel_ID)+" (Document ID: "+str(document_id)+") with status: "+str(status)) comment=comment+str(i+1)+") Parcel ID: "+str(parcel_ID)+" (Document ID: "+str(document_id)+") with status: "+str(status)+"\n" if "CM" in document_id: eo.set_value(row, 8, "Data found for CREDIT MEMO") #comment=comment+"Credir Memo not found in Search result"+"\n" #comment = comment + str(i + 1) + ") Parcel ID: " + str(parcel_ID) + " (Document ID: " + str(document_id) + ") with status: " + str(status) #print("========================================================================================") eo.set_value(row,6,parcel_count) eo.set_value(row, 7, comment) self.driver.get("https://commerce.spscommerce.com/transaction-tracker/prod/transactions/") #so.click_element_by_xpath("html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[5]/div/a") time.sleep(5)
def get_CM_parcels(self, input_sheet, row): time.sleep(2) whilevalue = 1 while (whilevalue): try: so = SeleniumOperations(self.v_task_type, self.driver, self.lo) eo = ExcelOperations(self.v_task_type, input_sheet) error_parcel_comment = '' without_error_parcel_comment = '' without_error_parcel_count = 0 error_parcel_count = 0 j = 1 while (1): i = 1 parcel_id = self.driver.find_element_by_xpath( LocalElementLocator.PARCEL_ID_1 + str(i) + LocalElementLocator.PARCEL_ID_2) while (parcel_id.is_enabled()): try: parcel_id1 = self.driver.find_element_by_xpath( LocalElementLocator.PARCEL_ID_1 + str(i) + LocalElementLocator.PARCEL_ID_2).text except NoSuchElementException: break status = self.driver.find_element_by_xpath( LocalElementLocator.STATUS_1 + str(i) + LocalElementLocator.STATUS_2).text document_id = self.driver.find_element_by_xpath( LocalElementLocator.DOCUMENT_ID_1 + str(i) + LocalElementLocator.DOCUMENT_ID_2).text if "CM" in document_id: if "Completed w/o Errors" in status: without_error_parcel_count = without_error_parcel_count + 1 without_error_parcel_comment = without_error_parcel_comment + str( without_error_parcel_count ) + ") Parcel ID: " + str( parcel_id1) + " (Document ID: " + str( document_id) + ") with status: " + str( status) + "\n" if "Completed w/Errors" in status: error_parcel_count = error_parcel_count + 1 error_parcel_comment = error_parcel_comment + str( error_parcel_count ) + ") Parcel ID: " + str( parcel_id1) + " (Document ID: " + str( document_id) + ") with status: " + str( status) i = i + 1 j = j + 1 try: parcel_id = self.driver.find_element_by_xpath( LocalElementLocator.PARCEL_ID_1 + str(i) + LocalElementLocator.PARCEL_ID_2) except NoSuchElementException: print("No element found") next_button = self.driver.find_element_by_xpath( LocalElementLocator.NEXT_SEARCH_BTN) if (next_button.is_enabled()): next_button = self.driver.find_element_by_xpath( LocalElementLocator.NEXT_SEARCH_BTN) next_button.click() time.sleep(2) else: print("---------------No Errors Data--------------") print(without_error_parcel_comment) print("----------------Errors Data----------------") print(error_parcel_comment) eo.set_value(row, 6, without_error_parcel_count) eo.set_value(row, 7, without_error_parcel_comment) eo.set_value(row, 8, error_parcel_comment) self.driver.get( LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK) time.sleep(4) break except NoSuchElementException: break try: parcel_id1 = self.driver.find_element_by_xpath( LocalElementLocator.LAST_PARCEL_ID).text except NoSuchElementException: self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK) whilevalue == 0 time.sleep(2)
def supplier_setup_check(self, v_supplier, v_retailer, v_document_type, current_row, service_name): v_document_type = str(v_document_type) self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) # lg.login("DC4 PreProd") # # # Switch to other window # self.v_driver.execute_script("window.open('about:blank', 'tab2');") # self.v_driver.switch_to.window("tab2") # time.sleep(2) # # lg.login("Launchpad") # time.sleep(5) # # self.v_driver.maximize_window() eo = ExcelOperations(self.v_task_type, self.v_data_sheet) self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) so.click_element_by_xpath(AppConstants.DC4_TAB) dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo) so.send_text_by_xpath(AppConstants.DC4_COMPANY_NAME_TEXT_FIELD, v_supplier) so.click_element_by_xpath(AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK) select_supplier = so.click_element_by_xpath( CommonLocators.Company_Select_Link) # Check the retationship click_relationship = self.v_driver.find_element_by_xpath( CommonLocators.Relationship_Tab).click() search_retailer_relationship = self.v_driver.find_element_by_xpath( CommonLocators.Trading_Partner_Name_text_Field).send_keys( v_retailer) self.v_driver.find_element_by_xpath( CommonLocators.click_search).click() # retailer_profile_name = self.v_driver.find_element_by_xpath(CommonLocators.Trading_Partner_Profile_Name).text # print(retailer_profile_name) supplier_EDI_Data = self.v_driver.find_element_by_xpath( CommonLocators.Supplier_EDI_Info).text retailer_EDI_Data = self.v_driver.find_element_by_xpath( CommonLocators.Retailer_EDI_Info).text # Supplier EDI Info supplier_EDI_Data_list_1 = supplier_EDI_Data.split('GRP_ID:') supplier_EDI_Data_list_2 = supplier_EDI_Data.split('Qual:') supplier_qaul_ID = supplier_EDI_Data_list_2[1].split('ID:')[0] supplier_qaul_ID = re.sub('\W+', '', supplier_qaul_ID) eo.set_value(current_row, 5, supplier_qaul_ID) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) supplier_ISA_ID = supplier_EDI_Data_list_1[0].split('ID:')[2] supplier_ISA_ID = re.sub('\W+', '', supplier_ISA_ID) eo.set_value(current_row, 6, supplier_ISA_ID) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) supplier_Grp_ID = supplier_EDI_Data_list_1[1] supplier_Grp_ID = re.sub('\W+', '', supplier_Grp_ID) # Retailer EDI Info retailer_EDI_Data_list_1 = retailer_EDI_Data.split('GRP_ID:') retailer_EDI_Data_list_2 = retailer_EDI_Data.split('Qual:') retailer_qaul_ID = retailer_EDI_Data_list_2[1].split('ID:')[0] retailer_qaul_ID = re.sub('\W+', '', retailer_qaul_ID) eo.set_value(current_row, 7, retailer_qaul_ID) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) retailer_ISA_ID = retailer_EDI_Data_list_1[0].split('ID:')[2] retailer_ISA_ID = re.sub('\W+', '', retailer_ISA_ID) eo.set_value(current_row, 8, retailer_ISA_ID) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) retailer_Grp_ID = retailer_EDI_Data_list_1[1] retailer_Grp_ID = re.sub('\W+', '', retailer_Grp_ID) v_trading_partner_name = self.v_driver.find_element_by_xpath( CommonLocators.Trading_Partner_Name).text print(v_trading_partner_name) if v_trading_partner_name == v_retailer: # Select the Supplier company profile and check for the FI setup select_supplier_profile = self.v_driver.find_element_by_xpath( CommonLocators.Supplier_Profile_Link).click() elif v_trading_partner_name == "No trading partners found.": print("No Retailer Found") return # Profile Page Display show_option_click = self.v_driver.find_element_by_xpath( CommonLocators.show_click).click() counter = 2 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' while (so.check_exists_by_xpath(path)): service = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[10]') doc_tpe = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[3]') if service == service_name: if doc_tpe == v_document_type: eo.set_value(current_row, 11, "FI Capability is present") supplier_version = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[7]') eo.set_value(current_row, 9, supplier_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) click_extension = so.click_element_by_xpath( '//*[@id="form1:table1:0:table2:' + str(counter) + ':extensionPopup"]') # Process_Test_Files_Utility.add_extensions(counter) break else: eo.set_value(current_row, 11, "FI is not present") self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) counter = counter + 1 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' time.sleep(15)
def retailer_setup_check(self, v_supplier, v_retailer, v_document_type, current_row): v_document_type_1 = str(v_document_type) v_document_type_2 = '875' self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) eo = ExcelOperations(self.v_task_type, self.v_data_sheet) self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) so.click_element_by_xpath(AppConstants.DC4_TAB) dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo) self.v_driver.find_element_by_xpath( AppConstants.DC4_COMPANY_NAME_TEXT_FIELD).send_keys(v_retailer) self.v_driver.find_element_by_xpath( AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK).click() select_retailer = self.v_driver.find_element_by_xpath( CommonLocators.Company_Select_Link).click() # Check the retationship click_relationship = so.click_element_by_xpath( CommonLocators.Relationship_Tab) search_retailer_relationship = so.send_text_by_xpath( CommonLocators.Trading_Partner_Name_text_Field, v_supplier) so.click_element_by_xpath(CommonLocators.click_search) # Select the Retailer company profile and check for the FI setup select_retailer_profile = so.click_element_by_xpath( CommonLocators.Supplier_Profile_Link) # Profile Page Display show_option_click = so.click_element_by_xpath( CommonLocators.show_click) counter = 2 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' while (so.check_exists_by_xpath(path)): service = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[10]') doc_tpe = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[3]') print(doc_tpe) if doc_tpe == v_document_type_1: if service != 'DoNotRoute': print("850 capability is available") retailer_version = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[8]') eo.set_value(current_row, 10, retailer_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) break elif service == 'DoNotRoute': print("850 capability is not available") elif doc_tpe == v_document_type_2: if service != 'DoNotRoute': print("875 capability is present") retailer_version = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[8]') eo.set_value(current_row, 10, retailer_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) break elif service == 'DoNotRoute': print("875 capability is present") counter = counter + 1 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' time.sleep(10)
def execute_main(self): v_start_time = time.time() self.lo.log_to_file("INFO", "Login in to DC4 Pre-Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) rf = ReportFileUtility(self.v_task_type) SeleniumOperations(self.v_task_type, self.v_driver, self.lo) output_sheet = self.v_input_wb.get_sheet_by_name('Output') input_sheet = self.v_input_wb.get_sheet_by_name('Input') input_sheet_ex = ExcelOperations(self.v_task_type, input_sheet) output_sheet_ex = ExcelOperations(self.v_task_type, output_sheet) self.v_driver.maximize_window() Max_row = input_sheet.max_row current_row = 2 #Max_row = output_sheet.max_row #current_row_output = 2 lg.login("DC4 PreProd") while (current_row <= Max_row): v_TPID = input_sheet.cell(row=current_row, column=1).value v_Doc_850 = input_sheet.cell(row=current_row, column=2).value if (v_Doc_850 == 'Y'): v_doc = '850' V_supplier_doc_version = '7.4' dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo) dc.company_search_by_TPID(v_TPID) self.lo.log_to_file("INFO", "Searching Supplier Data") V_Supplier_Profile_name = so.get_text_by_xpath( '//*[@id="table2"]/table/tbody/tr/td/table/tbody/tr[2]/td[2]') V_Supplier_name = so.get_text_by_xpath( '//*[@id="table2:0:commandLink4"]') print("Supplier Name = " + V_Supplier_name) output_sheet_ex.set_value(current_row, 1, V_Supplier_name) print("Supplier Profile = " + V_Supplier_Profile_name) so.click_element_by_xpath('//*[@id="table2:0:commandLink4"]') so.click_element_by_xpath( '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a' ) self.lo.log_to_file("INFO", "Searching Retailer Data") V_retailer_name, V_retailer_profile, V_supplier_row_index = self.search_retailer_profile( V_Supplier_Profile_name) #print(V_retailer_name, V_retailer_profile, V_supplier_row_index) if V_retailer_name == V_retailer_profile == V_supplier_row_index == False: print('No relationship found') self.lo.log_to_file( "INFO", "No relationship found, going to next row") output_sheet_ex.set_value(current_row, 4, 'Relationship not found') current_row = current_row + 1 else: print("Retailer Name = " + V_retailer_name) output_sheet_ex.set_value(current_row, 2, V_retailer_name) print("Retailer Profile = " + V_retailer_profile) self.lo.log_to_file("INFO", "Searching Retailer Map Versions") V_ret_document, V_ret_doc_status, V_ret_doc_service, V_ret_doc_version = self.search_retailer_map( v_doc, V_retailer_profile, V_Supplier_Profile_name, V_Supplier_name) V_supplier_map_version, V_supplier_profile_map_name, V_supplier_map_row_index = self.check_supplier_profile( V_Supplier_Profile_name, v_doc, V_supplier_row_index) print("Supplier Map version = " + V_supplier_map_version) print("Supplier Map Name" + V_supplier_profile_map_name) output_sheet_ex.set_value(current_row, 3, V_ret_document) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) self.lo.log_to_file("INFO", "Maps and version found") V_send_suuplier_map_index = int(V_supplier_map_row_index) V_send_suuplier_map_index = V_send_suuplier_map_index - 2 status = self.add_extensions(V_ret_doc_version, V_supplier_doc_version, V_send_suuplier_map_index) #print(status) if status == 'None': output_sheet_ex.set_value(current_row, 4, 'Success') else: output_sheet_ex.set_value(current_row, 4, 'Fail') current_row = current_row + 1 self.v_driver.close() v_end_time = time.time() rf.update_sheet(self.v_username, 2, math.floor(v_end_time - v_start_time), str(datetime.date.today()))
def execute_main(self): v_start_time = time.time() self.lo.log_to_file("INFO", "Login in to DC4 Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type,self.v_driver,self.lo) ehu = ErrorHospital_Utility(self.v_task_type,self.v_driver,self.lo) rf = ReportFileUtility(self.v_task_type) output_sheet = self.v_input_wb.get_sheet_by_name('Output') input_sheet = self.v_input_wb.get_sheet_by_name('Input') eo = ExcelOperations(self.v_task_type, input_sheet) output_sheet_eo = ExcelOperations(self.v_task_type, output_sheet) output_sheet_curr_row = 2 for index in range(2,input_sheet.max_row+1): list_duplicate_ticket_uid = [] today = datetime.datetime.now() DD = datetime.timedelta(days=14) earlier = today - DD earlier_str = earlier.strftime("%Y-%m-%d") earlier_str = earlier_str+' 00:00:00' lg.login("DC4 Prod") v_error_title = eo.get_value(index, 1) if v_error_title == LocalElementLocator.ADHOC_ERROR_TITLE: v_ticket_uid = eo.get_value(index, 2) if v_ticket_uid is None: v_ticket_uid = ' ' ehu.adhoc_error_search(v_ticket_uid,earlier_str,' ') if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) tuid_index = 2 while(ehu.get_ticket_uid(tuid_index)): temp_ticket_uid = ehu.get_ticket_uid(tuid_index) temp_receiver = ehu.get_receiver_name(tuid_index) temp_sender = ehu.get_sender_name(tuid_index) if temp_ticket_uid not in list_duplicate_ticket_uid: ehu.adhoc_error_search(temp_ticket_uid,earlier_str,' ') v_tpid, v_doctype = ehu.get_info_from_description(tuid_index-2) ehu.adhoc_error_search(' ', earlier_str,v_tpid) if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) temp_tuid_index = 2 while (ehu.get_ticket_uid(temp_tuid_index)): list_duplicate_ticket_uid.append(ehu.get_ticket_uid(temp_tuid_index)) temp_tuid_index = temp_tuid_index+1 output_sheet_eo.set_value(output_sheet_curr_row, 1, temp_ticket_uid) output_sheet_eo.set_value(output_sheet_curr_row, 2, temp_sender) output_sheet_eo.set_value(output_sheet_curr_row, 3, temp_receiver) output_sheet_eo.set_value(output_sheet_curr_row, 4, v_tpid) output_sheet_eo.set_value(output_sheet_curr_row, 5, v_doctype) output_sheet_curr_row = output_sheet_curr_row+1 self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) ehu.adhoc_error_search(v_ticket_uid, earlier_str, ' ') if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) tuid_index = tuid_index+1 #so.click_element(AppConstants.DC4_TAB, "BY_NAME") #dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo) #dc.company_search_by_name('Midlab Inc') #dc.company_search_by_ISA_ID('6166651648') #dc.company_search_by_TPID('620TSTWONDERTRE') self.v_driver.close() v_end_time = time.time() rf.update_sheet(self.v_username, 2, math.floor(v_end_time - v_start_time), str(datetime.date.today()))
def get_CM_parcels(self, input_sheet, row): self.lo.log_to_file( "INFO", "Executing TransactionTrackerOperations.get_CM_parcels()") whilevalue = 1 while (whilevalue): try: so = SeleniumOperations(self.v_task_type, self.driver, self.lo) eo = ExcelOperations(self.v_task_type, input_sheet) error_parcel_comment = '' without_error_parcel_comment = '' without_error_parcel_count = 0 error_parcel_count = 0 j = 1 while (1): i = 1 parcel_id = self.driver.find_element_by_xpath( LocalElementLocator.PARCEL_ID_1 + str(i) + LocalElementLocator.PARCEL_ID_2) while (parcel_id.is_enabled()): try: parcel_id1 = self.driver.find_element_by_xpath( LocalElementLocator.PARCEL_ID_1 + str(i) + LocalElementLocator.PARCEL_ID_2).text except NoSuchElementException: break status = so.get_text_by_xpath( LocalElementLocator.STATUS_1 + str(i) + LocalElementLocator.STATUS_2) document_id = so.get_text_by_xpath( LocalElementLocator.DOCUMENT_ID_1 + str(i) + LocalElementLocator.DOCUMENT_ID_2) parcel_date_time = so.get_text_by_xpath( LocalElementLocator.PARCEL_DATE_TIME_1 + str(i) + LocalElementLocator.PARCEL_DATE_TIME_2) if "CM" in document_id: if "Completed w/o Errors" in status: without_error_parcel_count = without_error_parcel_count + 1 without_error_parcel_comment = without_error_parcel_comment + str( without_error_parcel_count ) + ") Parcel ID: " + str( parcel_id1) + " (Document ID: " + str( document_id ) + ") with status: " + str( status ) + " [" + parcel_date_time + "]" + "\n" if "Completed w/Errors" in status: error_parcel_count = error_parcel_count + 1 error_parcel_comment = error_parcel_comment + str( error_parcel_count ) + ") Parcel ID: " + str( parcel_id1) + " (Document ID: " + str( document_id ) + ") with status: " + str( status ) + " [" + parcel_date_time + "]" + "\n" i = i + 1 j = j + 1 try: parcel_id = self.driver.find_element_by_xpath( LocalElementLocator.PARCEL_ID_1 + str(i) + LocalElementLocator.PARCEL_ID_2) except NoSuchElementException: self.lo.log_to_file( "INFO", "NoSuchElementException in TransactionTrackerOperations.get_CM_parcels()" ) next_button = self.driver.find_element_by_xpath( LocalElementLocator.NEXT_SEARCH_BTN) if (next_button.is_enabled()): next_button = self.driver.find_element_by_xpath( LocalElementLocator.NEXT_SEARCH_BTN) next_button.click() time.sleep(2) else: eo.set_value(row, 6, without_error_parcel_count) eo.set_value(row, 7, without_error_parcel_comment) eo.set_value(row, 8, error_parcel_comment) self.driver.get( LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK) break except NoSuchElementException: break try: parcel_id1 = self.driver.find_element_by_xpath( LocalElementLocator.LAST_PARCEL_ID).text except NoSuchElementException: self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK) whilevalue == 0 time.sleep(2)
def execute_main(self, v_error_title, v_ticket_uid, output_sheet, earlier_str): v_count = 0 selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) list_duplicate_ticket_uid = [] output_sheet_excel_operation_object = ExcelOperations( self.v_task_type, output_sheet) v_output_sheet_curr_row = 2 error_hospital_utility_object = ErrorHospital_Utility( self.v_task_type, self.v_driver, self.log_file_object, self.error_hospital_machine_learning_object) #Search for error tickets error_hospital_utility_object.document_rejected_error_search( v_ticket_uid, earlier_str, ' ', v_error_title, ' ') if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): selenium_operation_object.click_element_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) v_tuid_index = 2 while (error_hospital_utility_object.get_ticket_uid(v_tuid_index)): v_temp_ticket_uid = error_hospital_utility_object.get_ticket_uid( v_tuid_index) v_temp_receiver = error_hospital_utility_object.get_receiver_name( v_tuid_index) v_temp_sender = error_hospital_utility_object.get_sender_name( v_tuid_index) #Search for new unique ticket if v_temp_ticket_uid not in list_duplicate_ticket_uid: v_count = v_count + 1 v_status = ' ' error_hospital_utility_object.document_rejected_error_search( v_temp_ticket_uid, earlier_str, ' ', v_error_title, ' ') #Get TPID and doctype v_tpid, v_doctype = error_hospital_utility_object.get_info_from_description( v_tuid_index - 2) #Search for duplicate tickets error_hospital_utility_object.document_rejected_error_search( ' ', earlier_str, v_tpid, v_error_title, v_doctype) if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): selenium_operation_object.click_element_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) v_temp_tuid_index = 2 parcel_uid_list = [] #Append all duplicate tickets to list while (error_hospital_utility_object.get_ticket_uid( v_temp_tuid_index)): list_duplicate_ticket_uid.append( error_hospital_utility_object.get_ticket_uid( v_temp_tuid_index)) parcel_uid_list.append( error_hospital_utility_object.get_parcel_uid( v_temp_tuid_index)) doc_type_list = error_hospital_utility_object.get_unique_doc_types( v_doctype) v_temp_tuid_index = v_temp_tuid_index + 1 #Add info to output sheet output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 1, v_temp_ticket_uid) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 2, v_temp_sender) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 3, v_temp_receiver) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 4, v_tpid) doc_type_string = ','.join(doc_type_list) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 5, doc_type_string) parcel_uid_string = '\n'.join(parcel_uid_list) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 6, parcel_uid_string) #Validate TPID if len(v_tpid) == 15 and ' ' not in v_tpid: self.log_file_object.log_to_file( "INFO", "TPID: " + v_tpid + " is valid") v_status, flag = error_hospital_utility_object.add_trading_partnership( v_error_title, v_tpid, doc_type_list, v_temp_sender, v_temp_receiver, v_status) if flag == 1: first_parcel_list = [] first_parcel_list.append(parcel_uid_list[0]) error_hospital_utility_object.requeue( first_parcel_list) time.sleep(2) error_status = error_hospital_utility_object.error_status( parcel_uid_list[0], v_error_title) self.v_driver.switch_to.window( self.v_driver.window_handles[0]) time.sleep(2) if error_status == 1: if len(parcel_uid_list) > 1: first_parcel_list = parcel_uid_list[1:] error_hospital_utility_object.requeue( first_parcel_list) v_status = v_status + '\nSuccessfully passed all the parcels' output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Done') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='008000', end_color='008000', fill_type='solid') self.log_file_object.log_to_file( "INFO", "Successfully passed the failed parcels") else: output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Failed') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='FFFF0000', end_color='FFFF0000', fill_type='solid') self.log_file_object.log_to_file( "INFO", "Unsuccessfully passed the failed parcels") else: output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Push to Manual') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='FFFF0000', end_color='FFFF0000', fill_type='solid') output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 8, v_status) else: self.log_file_object.log_to_file( "INFO", "TPID: " + v_tpid + " is invalid") v_status = v_status + '\nInvalid Data, Report to implementation analyst' output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Done') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='008000', end_color='008000', fill_type='solid') output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 8, v_status) v_output_sheet_curr_row = v_output_sheet_curr_row + 1 self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) error_hospital_utility_object.document_rejected_error_search( v_ticket_uid, earlier_str, ' ', v_error_title, ' ') if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): selenium_operation_object.click_element_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) v_tuid_index = v_tuid_index + 1 return v_count
def retailer_v_check(self, v_supplier, v_retailer, v_document_type, current_row): v_document_type_1 = str(v_document_type) v_document_type_2 = '875' self.lo.log_to_file("INFO", "Login in to DC4 Prod") login = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) selenium_operations = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) excel_operations = ExcelOperations(self.v_task_type, self.v_data_sheet) self.lo.log_to_file("INFO", "Login in to DC4 Prod") login = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) selenium_operations = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) selenium_operations.click_element_by_xpath(AppConstants.DC4_TAB) dc4_utility = DC4_Utility(self.v_task_type, self.v_driver, self.lo) self.v_driver.find_element_by_xpath( AppConstants.DC4_COMPANY_NAME_TEXT_FIELD).send_keys(v_retailer) self.v_driver.find_element_by_xpath( AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK).click() select_retailer = self.v_driver.find_element_by_xpath( '//*[@id="table1:10:commandLink2"]').click() click_relationship = selenium_operations.click_element_by_xpath( CommonLocators.Relationship_Prod_Tab) search_retailer_relationship = selenium_operations.send_text_by_xpath( CommonLocators.Trading_Partner_Name_text_Field, v_supplier) selenium_operations.click_element_by_xpath(CommonLocators.click_search) # Select the Retailer company profile and check for the FI setup select_retailer_profile = selenium_operations.click_element_by_xpath( CommonLocators.Supplier_Profile_Link) # Profile Page Display show_option_click = selenium_operations.click_element_by_xpath( CommonLocators.show_click) counter = 2 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' while (selenium_operations.check_exists_by_xpath(path)): service = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[10]') print(service) doc_type = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[3]') counter = counter + 1 print(doc_type) if doc_type == v_document_type_1: if service != 'DoNotRoute' and 'WEBtoService': print("850 capability is available") retailer_version = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[8]') capability_name = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2:' + str(counter) + ':outputText14"]') print(retailer_version) print(capability_name) if retailer_version == " ": retailer_version = self.retailer_ver_check( doc_type, capability_name) excel_operations.set_value(current_row, 10, retailer_version) retailer_capability_version = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[6]') excel_operations.set_value( current_row, 11, retailer_capability_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) break else: excel_operations.set_value(current_row, 10, retailer_version) retailer_capability_version = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[6]') excel_operations.set_value( current_row, 11, retailer_capability_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) break elif service == 'DoNotRoute': print("850 capability is not available")
def execute_main(self): db_object = DatabaseUtility(self.v_task_type, self.lo) if db_object.connection(): self.lo.log_to_file('INFO', 'Successful Connection') else: self.lo.log_to_file('ERROR', 'DB Server is not active') return v_start_time = time.time() self.lo.log_to_file("INFO", "Login in to DC4 Prod") login_obj = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) selenium_operation_obj = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) report_file_obj = ReportFileUtility(self.v_task_type) input_sheet = self.v_input_wb.get_sheet_by_name('Input') input_sheet_row_count = input_sheet.max_row excel_operation_obj = ExcelOperations(self.v_task_type, input_sheet) Web_Fulfillment_Utility_obj = Web_Fulfillment_Utility( self.v_task_type, self.v_driver, self.v_input_wb, self.lo, self.v_username, db_object) login_obj.login("Salesforce") self.v_driver.execute_script( "window.open('http://dc4ui.p01.pro:7777/dc4custmanager/faces/home.jsp', 'new_window')" ) # self.v_driver.execute_script( # "window.open('https://atlassian.spscommerce.com/browse/FICS-163692', 'new_window')") self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) report_file_object = ReportFileUtility(self.v_task_type) time.sleep(2) login_obj.login("DC4 Prod") input_row = excel_operation_obj.get_value(2, 4) FICS_Number = excel_operation_obj.get_value(input_row, 1) while (FICS_Number != None): v_start_time = time.time() v_salesforce_id = FICS_Number self.v_driver.switch_to.window(self.v_driver.window_handles[0]) time.sleep(2) #self.v_driver.get('https://atlassian.spscommerce.com/browse/'+FICS_Number) #v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, v_salesforce_id = Web_Fulfillment_Utility_obj.get_info_from_JIRA() v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name = Web_Fulfillment_Utility_obj.get_info_from_salesforce( v_salesforce_id) print(v_salesforce_id + "\n" + v_supplier_name + "\n" + v_email_address + "\n" + v_phone_number + "\n" + v_retailer_name + "\n" + v_vendor_number + "\n" + v_retailer_web_company_uid + "\n" + v_account_number + "\n" + v_retailer_dc4_company_uid + "\n" + v_contact_name) print(v_billing_address) self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) time.sleep(2) try: #Web_Fulfillment_Utility_obj.get_data_for_library(v_salesforce_id, v_supplier_name, v_retailer_name, v_retailer_dc4_company_uid, FICS_Number) Web_Fulfillment_Utility_obj.run_setup_tool( v_salesforce_id, v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name) except: self.v_driver.save_screenshot(AppConstants.APP_RUNNER_PATH + v_salesforce_id + '.png') print(input_row) v_end_time = time.time() report_file_object.update_sheet( self.v_username, 1, math.floor(v_end_time - v_start_time), str(datetime.date.today())) input_row = input_row + 1 excel_operation_obj.set_value(2, 4, input_row) FICS_Number = excel_operation_obj.get_value(input_row, 1) time.sleep(2)
def execute_main(self): t1 = threading.Thread(target=self.thread1) t2 = threading.Thread(target=self.thread2) t1.start() t2.start() t1.join() t2.join() db_object = DatabaseUtility(self.v_task_type, self.lo) if db_object.connection(): self.lo.log_to_file('INFO', 'Successful Connection') else: self.lo.log_to_file('ERROR', 'DB Server is not active') return v_start_time = time.time() self.lo.log_to_file("INFO", "Login in to DC4 Prod") login_obj = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) selenium_operation_obj = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) report_file_obj = ReportFileUtility(self.v_task_type) input_sheet = self.v_input_wb.get_sheet_by_name('Input') input_sheet_row_count = input_sheet.max_row excel_operation_obj = ExcelOperations(self.v_task_type, input_sheet) Web_Fulfillment_Utility_obj = Web_Fulfillment_Utility( self.v_task_type, self.v_driver, self.v_input_wb, self.lo, self.v_username, db_object, self.v_driver_mv) # login_obj.login("Salesforce") self.v_driver.execute_script( "window.open('http://dc4ui.p01.pro:7777/dc4custmanager/faces/home.jsp', 'new_window')" ) # self.v_driver.execute_script( # "window.open('https://atlassian.spscommerce.com/browse/FICS-163692', 'new_window')") self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) report_file_object = ReportFileUtility(self.v_task_type) time.sleep(2) login_obj.login("DC4 Prod") input_row = input_sheet_row_count + 1 FICS_Number = excel_operation_obj.get_value(input_row, 1) flag = 1 count = 0 v_start_time = time.time() while (flag): v_start_time1 = time.time() v_salesforce_id = easygui.enterbox('Please enter salesforce ID') self.v_driver.switch_to.window(self.v_driver.window_handles[0]) time.sleep(2) #self.v_driver.get('https://atlassian.spscommerce.com/browse/'+FICS_Number) #v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, v_salesforce_id = Web_Fulfillment_Utility_obj.get_info_from_JIRA() v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, client_uid, retailer_uid = Web_Fulfillment_Utility_obj.get_info_from_salesforce( v_salesforce_id) print(v_salesforce_id + "\n" + v_supplier_name + "\n" + v_email_address + "\n" + v_phone_number + "\n" + v_retailer_name + "\n" + v_vendor_number + "\n" + v_retailer_web_company_uid + "\n" + v_account_number + "\n" + v_retailer_dc4_company_uid + "\n" + v_contact_name) print(v_billing_address) self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) time.sleep(2) #Web_Fulfillment_Utility_obj.get_data_for_library(v_salesforce_id, v_supplier_name, v_retailer_name, v_retailer_dc4_company_uid, FICS_Number) Web_Fulfillment_Utility_obj.run_setup_tool( v_salesforce_id, v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, client_uid, retailer_uid) print(input_row) count = count + 1 excel_operation_obj.set_value(input_row, 1, count) FICS_Number = excel_operation_obj.get_value(input_row, 1) v_end_time1 = time.time() excel_operation_obj.set_value( input_row, 2, math.floor(v_end_time1 - v_start_time1)) excel_operation_obj.set_value(input_row, 3, datetime.date.today()) print( '----------------------------------------------\n\nExecution Time: ' + str(math.floor(v_end_time1 - v_start_time1)) + ' count: ' + str(count) + '\n\n-------------------------') time.sleep(2) input_row = input_row + 1 self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) flag = easygui.ynbox('Do you want to run one more setup?') v_end_time = time.time() report_file_object.update_sheet(self.v_username, count, math.floor(v_end_time - v_start_time), str(datetime.date.today()))