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 File_Uploading(self): SeleniumOperation = SeleniumOperations(self.v_driver, self.lo) SeleniumOperation.click_element_by_xpath(ElementLocator.FTP_Refresh) self.v_driver.get(ElementLocator.FTP_File_link) SeleniumOperation.click_element_by_xpath(ElementLocator.FTP_Refresh) self.v_driver.get(ElementLocator.FTP_inbound_edi) time.sleep(5) first_parcel = ExcelOperations.get_value( ElementLocator.Edi_Parcel_file, 1, 1) second_parcel = ExcelOperations.get_value( ElementLocator.Edi_Parcel_file, 2, 1) third_parcel = ExcelOperations.get_value( ElementLocator.Edi_Parcel_file, 3, 1) SeleniumOperation.send_text_by_xpath( ElementLocator.FTP_add_file, f"C:\\Users\\Krishnabhashkar.Jha\\Downloads\\{first_parcel}.dat") time.sleep(10) SeleniumOperation.send_text_by_xpath( ElementLocator.FTP_add_file, f"C:\\Users\\Krishnabhashkar.Jha\\Downloads\\{second_parcel}.dat") time.sleep(10) SeleniumOperation.send_text_by_xpath( ElementLocator.FTP_add_file, f"C:\\Users\\Krishnabhashkar.Jha\\Downloads\\{third_parcel}.dat") time.sleep(10) # SeleniumOperation.click_element_by_xpath(ElementLocator.FTP_upload) for i in range(3): time.sleep(2) SeleniumOperation.click_element_by_xpath( ElementLocator.FTP_Refresh) break time.sleep(3) SeleniumOperation.click_element_by_xpath(ElementLocator.FTP_Logout)
def Capability_parameter_validator(self): self.log.log_to_file( self, "INFO", " Validating Capability Parameters in Supplier Side! ") time.sleep(4) self.seleniumOperation.click_element_by_xpath(Element.comms_plus) self.output_channel_list = [] self.output_channels = self.driver.find_elements_by_xpath( Element.output_channel) for self.output_channel in self.output_channels: self.output_channel_list.append(self.output_channel.text) # print(self.output_channel_list) if (self.output_channel_list.__getitem__(0) == self.ERP_sheet['filename_macro'].iloc[0] and self.output_channel_list.__getitem__(2).split( '/').__getitem__(6) == "out" and self.output_channel_list.__getitem__(3).split( '/').__getitem__(5) == "out"): print( "filename_macro, archive_directory, and directory is Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 4, 2, 'MATCHED') else: self.Warning( 'cancel', "filename_macro/ archive_directory/ directory is Not Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 4, 2, 'NOT MATCHED')
def execute_main(self): login_object = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.log_file_object) error_hospital_machine_learning_object = Error_Hospital_Machine_Learning(self.v_task_type, self.v_username) report_file_object = 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') excel_operation_object = ExcelOperations(self.v_task_type, input_sheet) #Login into DC4 Prod login_object.login("DC4 Prod") self.log_file_object.log_to_file("INFO", "Login in to DC4 Prod") self.v_driver.execute_script("window.open('https://commerce.spscommerce.com/transaction-tracker/prod/transactions/', 'new_window')") self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) time.sleep(2) #Login into Launchpad login_object.login("Launchpad") self.log_file_object.log_to_file("INFO", "Login in to Launchpad") self.v_driver.switch_to.window(self.v_driver.window_handles[0]) time.sleep(2) #Extract data from input sheet for index in range(2,input_sheet.max_row+1): today = datetime.datetime.now() DD = datetime.timedelta(days=6) earlier = today - DD earlier_str = earlier.strftime("%Y-%m-%d") earlier_str = earlier_str+' 00:00:00' v_error_title = excel_operation_object.get_value(index, 1) #Searching data as per error title if v_error_title == LocalElementLocator.ADHOC_ERROR_TITLE: self.log_file_object.log_to_file("INFO", "Seaching tickets for error title:- AdhocReporting: document rejected") v_start_time = time.time() v_ticket_uid = excel_operation_object.get_value(index, 2) if v_ticket_uid is None: v_ticket_uid = ' ' Error_Document_rejected_obj = Error_Document_rejected(self.v_task_type, self.v_driver, self.log_file_object, self.v_input_wb, error_hospital_machine_learning_object) v_count = Error_Document_rejected_obj.execute_main(v_error_title, v_ticket_uid, output_sheet, earlier_str) v_end_time = time.time() report_file_object.update_sheet(self.v_username, v_count, math.floor(v_end_time - v_start_time), str(datetime.date.today())) if v_error_title == LocalElementLocator.WEB_DOC_REJECTED_ERROR_TITLE: self.log_file_object.log_to_file("INFO", "Seaching tickets for error title:- WebForms-ToService: document rejected") v_start_time = time.time() v_ticket_uid = excel_operation_object.get_value(index, 2) if v_ticket_uid is None: v_ticket_uid = ' ' Error_Document_rejected_obj = Error_Document_rejected(self.v_task_type, self.v_driver, self.log_file_object, self.v_input_wb, error_hospital_machine_learning_object) v_count = Error_Document_rejected_obj.execute_main(v_error_title, v_ticket_uid, output_sheet, earlier_str) v_end_time = time.time() report_file_object.update_sheet(self.v_username, v_count, math.floor(v_end_time - v_start_time), str(datetime.date.today())) else: self.log_file_object.log_to_file("ERROR", "Invalid error title ErrorHospital.execute_main()") time.sleep(3) self.v_driver.close()
def GetIDs(self): TestData = open(self.file_paths[0]) test_data = TestData.readlines() self.delimeter = test_data[0][3] Retailer_Qual = str(test_data[0].split(self.delimeter)[5]) Retailer_ISA_ID = str(test_data[0].split(self.delimeter)[6]).strip() Retailer_ISA_ID = str(Retailer_Qual) + ':' + str(Retailer_ISA_ID) ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 7, Retailer_ISA_ID) Retailer_Group_ID = str(test_data[1].split(self.delimeter)[2]).strip() ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 8, Retailer_Group_ID) Supplier_Qual = str(test_data[0].split(self.delimeter)[7]) Supplier_ISA_ID = str(test_data[0].split(self.delimeter)[8]).strip() Supplier_ISA_ID = str(Supplier_Qual) + ':' + str(Supplier_ISA_ID) ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 5, Supplier_ISA_ID) Supplier_Group_ID = str(test_data[1].split(self.delimeter)[3]).strip() ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 6, Supplier_Group_ID) TPID = self.TPID print(TPID) print('Retailer ', Retailer_ISA_ID, Retailer_Group_ID) print('Supplier', Supplier_ISA_ID, Supplier_Group_ID) return self.file_paths
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 add_extensions(self, counter): # Get the versions of the supplier and retailer from Input sheet eo = ExcelOperations(self.v_task_type, self.v_data_sheet) supplier_map_version = self.v_data_sheet.cell(row=counter, column=9).value retailer_map_version = self.v_data_sheet.cell(row=counter, column=10).value so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) version_check = msgbox("Supplier_Version" + supplier_map_version + " " + "Retailer_Version" + retailer_map_version) # # print(self.v_driver.current_window_handle) # if so.check_exists_by_xpath(V_configure_extensions_xpath): # so.click_element_by_xpath(V_configure_extensions_xpath) # time.sleep(1) # self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) # time.sleep(1) # self.v_driver.switch_to.frame(0) # self.lo.log_to_file("INFO", "Checking the extensions") self.v_driver.switch_to.window(self.v_driver.window_handles[0])
def Execute_GenerateInputs(self): generatingInput = Generate_Inputs(self.driver, self.wait, self.erp, self.supplier_name, self.retailer_name, self.Start_Date, self.No_of_Parcels) generatingInput.Login() generatingInput.TTSearch() generatingInput.DownloadInput() generatingInput.DeleteDupliacteFiles() self.SDQ_present_Flag = generatingInput.EdiValidations() self.filepaths = generatingInput.GetIDs() print('SDQ present in file ?', self.SDQ_present_Flag) ExcelOperations.set_value_to_cell(Element.Output_File_Path, 5, 2, self.SDQ_present_Flag) print('In Main file', self.filepaths)
def login(self, v_tool): login_wb = openpyxl.load_workbook( AppConstants.LOGIN_ENVIRONMENT_LOCATOR_FILE_PATH) sheet_names = login_wb.get_sheet_names() input_credential_sheet = self.input_wb.get_sheet_by_name("Credentials") eo = ExcelOperations(self.task_type, input_credential_sheet) so = SeleniumOperations(self.task_type, self.driver, self.log_file_object) if v_tool in sheet_names: login_sheet = login_wb.get_sheet_by_name(v_tool) else: self.log_file_object.log_to_file( "ERROR", "Error in Login.login(). Sheet name not found") return False tool_row = eo.search_for_element_in_column(1, v_tool) username = input_credential_sheet.cell(row=tool_row, column=2).value password = input_credential_sheet.cell(row=tool_row, column=3).value username_locator = login_sheet.cell(row=2, column=2).value password_locator = login_sheet.cell(row=3, column=2).value button_locator = login_sheet.cell(row=4, column=2).value if v_tool == "DC4 Prod": Link = AppConstants.DC4_PROD_LINK elif v_tool == "DC4 PreProd": Link = AppConstants.DC4_PREPROD_LINK elif v_tool == "JIRA": Link = AppConstants.JIRA_LINK elif v_tool == "Launchpad": Link = AppConstants.LAUNCHPAD_LINK elif v_tool == "Salesforce": Link = AppConstants.SALESFORCE_LINK else: self.log_file_object.log_to_file( "ERROR", "Error in Login.login(). Invalid Link") return False self.driver.get(Link) if v_tool == "Launchpad": self.driver.switch_to.frame(0) if v_tool == "Salesforce": so.click_element_by_xpath(AppConstants.SAILPOINT_TAB) so.send_text_by_xpath(username_locator, username) so.send_text_by_xpath(password_locator, password) so.click_element_by_xpath(button_locator) else: so.send_text_by_name(username_locator, username) so.send_text_by_name(password_locator, password) so.click_element_by_xpath(button_locator)
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 Setup_capability_validator(self): self.log.log_to_file( self, "INFO", " Starting Setup capability validation in Supplier Side! ") self.ERP_sheet = self.ERP_sheet.loc[( self.ERP_sheet['ERP'] == self.ERP_name)] datatype_name = self.ERP_sheet['DataTypeName'].iloc[0] service_name = self.ERP_sheet['Services'].iloc[0] doctype_name = self.ERP_sheet['Document'].iloc[0] # ExcelOperations.set_value_to_cell(file.Output_File_Path,1,2,doctype_name) # status = "ACTIVE" self.df_datatypes = self.df_datatypes.loc[ (self.df_datatypes['Service'] == str(service_name)) & (self.df_datatypes['Doctype'] == str(doctype_name))] print(self.df_datatypes) if self.df_datatypes.empty: print("Capability service and Doctype is not Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 1, 2, 'NOT MATCHED') else: print("Capability service and Doctype is Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 1, 2, 'MATCHED') pass self.df_datatypes_test = self.df_datatypes.loc[( self.df_datatypes['DataTypes'] == str(datatype_name))] # ExcelOperations.set_value_to_cell(file.Output_File_Path, 3, 2, self.df_datatypes['DataTypes']) if self.df_datatypes_test.empty: print(self.df_datatypes_test) print("Capability datatype is not Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 3, 2, 'NOT MATCHED') time.sleep(5) data_type = self.df_datatypes['DataTypes'].iloc[0] self.CapID = self.df_datatypes['CapId'].iloc[0] self.Warning( "cancel", str(f" This Datatype {data_type} is not MATCHED with input Datatype you want to " f"continue with DOCUMENT type and SERVICE")) self.extreact_extension() self.seleniumOperation.click_element_by_xpath( f".//*[contains(text(),'{str(self.CapID)}')]") pass else: print(self.df_datatypes_test) print("Capability datatype is Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 3, 2, 'MATCHED') self.CapID = self.df_datatypes_test['CapId'].iloc[0] self.extreact_extension() self.seleniumOperation.click_element_by_xpath( f".//*[contains(text(),'{str(self.CapID)}')]") pass
def get_parcel(self, rows): row = int(rows) selenium_operations_object = SeleniumOperations(self.driver, self.log) file_broker = selenium_operations_object.get_text_by_xpath( ElementLocator.file_broker_xpath) print(file_broker) ExcelOperations.set_value_to_cell(ElementLocator.Edi_Parcel_file, row, 1, file_broker) selenium_operations_object.click_element_by_xpath( f'//*[@id="parcel-{str(file_broker)}"]/div/div/div[2]/div/a/div/div' ) time.sleep(3) selenium_operations_object.click_element_by_xpath( ElementLocator.Download_xpath) selenium_operations_object.click_element_by_xpath( ElementLocator.BackToTransaction) selenium_operations_object.click_element_by_xpath( ElementLocator.BackToSearch)
def process(self, path): #tto = TransactionTrackerOperations print("in task filter method") #rf = ReportFileUtility(self.v_task_type) # self.v_input_sheet = self.v_input_wb.get_sheet_names("InputData") print("input data sheet selected") row_count = self.v_input_sheet.max_row print(row_count) eo = ExcelOperations(self.v_task_type, self.v_input_sheet) supplier_name = self.v_input_sheet.cell(row=2, column=1).value retailer_name = self.v_input_sheet.cell(row=2, column=2).value doc_type = self.v_input_sheet.cell(row=2, column=3).value date = self.v_input_sheet.cell(row=2, column=4).value ptfu = Process_Test_Files_Utility(self.v_task_type, self.v_driver, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) time.sleep(3) self.v_driver.switch_to.frame(0) ptfu.search_by_names(supplier_name, retailer_name, doc_type, date) # ptfu.search_by_names("AURORA ORGANIC","Topco","850","09/20/2018") ptfu.get_five_parcels() path = 'D:\processtestfiles.txt' with open(path) as f: for line in f: parcel = line.replace('\n', '') print("Download Parcel ID : " + str(parcel)) #self.v_driver.switch_to.frame(0) ptfu.search_by_parcel_id(str(parcel)) #generated_parcel_id = ptfu.save_page_source_and_generate_parcel_id_from_dom() #xpath_for_click = ptfu.generate_xpath_for_TT(generated_parcel_id) so.click_element_by_xpath( "//aside[text()='Transformations']/following::a[@title='View'][1]/div/div" ) # time.sleep(1) # downloaded_parcel=so.get_text_by_xpath("//aside[text()='Transformations']/following::a[@title='View'][1]/div/div/following::span[2]") # downloaded_parcel_path="C:\\Users\\yogesh.pawar\\Downloads\\"+downloaded_parcel+".dat" # copy_to_path="D:\\ProcessTestFiles" element = WebDriverWait(self.v_driver, 20).until( EC.element_to_be_clickable(( By.XPATH, "html/body/div[1]/section/section/div/div/section/div/div[3]/div[1]/div/div[1]/div/div/div/a/i" ))) element.click() time.sleep(2) # shutil.copy(downloaded_parcel_path, copy_to_path) if 'str' in line: #time.sleep(4) break
def map_extension_validation(self): self.log.log_to_file(self, "INFO", " Map Extension Validation in Receiver Side ! ") self.Map_sheet = pandas.read_excel(Element.INPUT_FILE_PATH, sheet_name='850 maps') self.Map_sheet = self.Map_sheet.loc[(self.Map_sheet['Supplier'] == float('7.6')) & (self.Map_sheet['Retailer'] == float('7'))] # print(self.Map_sheet['Map'].iloc[0]) self.Map_sheet = (self.Map_sheet.set_index(self.Map_sheet.columns.drop('Map', 1).tolist()).Map.str. split(',',expand=True).stack().reset_index().rename(columns={0: 'Map'}).loc[:, self.Map_sheet.columns]) # print(Map_sheet) self.Map_sheet = self.Map_sheet['Map'] self.df_Map = pandas.DataFrame(columns=['Extensions']) self.df_Map['Extensions'] = self.Map_sheet print(self.df_Map) if self.df_Map.equals(self.extension): print("Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 10, 2, 'MATCHED') ExcelOperations.set_value_to_cell(file.Output_File_Path, 6, 2, 'PASS') setup_methods.Warning(self,'cancel','Map Extension is Matched') else: print("Not Matched.") ExcelOperations.set_value_to_cell(file.Output_File_Path, 10, 2, 'NOT MATCHED') ExcelOperations.set_value_to_cell(file.Output_File_Path, 6, 2, 'FAIL') setup_methods.Warning(self, 'cancel', 'Map Extension is Not Matched')
def Extensions_validation(self): self.log.log_to_file(self, "INFO", " Start Extension_validation in Receiver Side ! ") self.extension = pandas.read_excel(Element.Extention_File_Path, sheet_name="Sheet1") self.extension = self.extension[self.extension.Extensions.str.contains('MapExtension')] self.extension['Extensions'] = self.extension['Extensions'].str.split(' ').str[1] if self.extension['Extensions'].str.contains('split').any() == True: self.splitter = ExcelOperations.get_value(file.Output_File_Path,5,2) # print(self.splitter) if self.splitter == True: print("Splitter Map is present") self.log.log_to_file(self, "INFO", " Splitter Map is present in Receiver Side ! ") # ExcelOperations.set_value_to_cell(file.Output_File_Path, 5, 2, 'TRUE') # setup_methods.Warning(self, 'cancel', 'Splitter Map is present') else: if self.splitter == True: print("Splitter Map is not There") self.log.log_to_file(self, "INFO", " Splitter Map is NOT present in Receiver Side ! ") # ExcelOperations.set_value_to_cell(file.Output_File_Path, 5, 2, 'FALSE') setup_methods.Warning(self, 'cancel', 'SDQ Segment is there but Splitter Map is not There !') self.extension = self.extension[self.extension.Extensions.str.contains('conversion')] print(self.extension)
def __init__(self, driver, wait, erp, supplier_name, retailer_name, Start_Date): self.driver = driver self.driver.get(Element.TT_url) self.wait = wait self.erp = erp ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 4, self.erp) self.supplier_name = supplier_name ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 1, self.supplier_name) self.retailer_name = retailer_name ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 2, self.retailer_name) self.Start_Date = Start_Date
def execute_main(self): self.lo.log_to_file("INFO", "Login in to DC4 Prod") login_object = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) # report_file_object = ReportFileUtility(self.v_task_type) total_rows = self.v_data_sheet.max_row print(total_rows) login_object.login("DC4 Prod") self.v_driver.maximize_window() for row_count in range(2, total_rows + 1): v_start_time = time.time() excel_operations = ExcelOperations(self.v_task_type, self.v_data_sheet) v_supplier = self.v_data_sheet.cell(row=row_count, column=1).value v_retailer = self.v_data_sheet.cell(row=row_count, column=2).value v_erp = self.v_data_sheet.cell(row=row_count, column=15).value print(v_retailer) print(v_erp) service_name = ["FItoService", "FIfromService"] v_doc_type = self.v_data_sheet.cell(row=row_count, column=3).value print(v_doc_type) v_date = self.v_data_sheet.cell(row=row_count, column=4).value if v_doc_type == 850: print(v_doc_type) Setup_U_Ob = QB_Setup_Util(self.v_task_type, self.lo, self.v_username, self.v_input_wb, self.v_driver) retailer_flag = Setup_U_Ob.retailer_v_check( v_supplier, v_retailer, v_doc_type, row_count) supplier_flag = Setup_U_Ob.Supplier_Setup_Check( v_supplier, v_retailer, v_doc_type, v_erp, row_count)
def __init__(self, driver, wait, erp, supplier_name, retailer_name, Start_Date, No_of_Parcels): self.driver = driver self.wait = wait self.erp = erp ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 4, self.erp) self.supplier_name = supplier_name ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 1, self.supplier_name) self.retailer_name = retailer_name ExcelOperations.set_value_to_cell( ElementLocator_For_PurchaseOrder_SetUp.INPUT_FILE_PATH, 2, 2, self.retailer_name) self.Start_Date = Start_Date self.No_of_Parcels = No_of_Parcels self.root = tk.Tk() self.root.withdraw() self.root.attributes("-topmost", True)
def process(self, path): tto = TransactionTrackerOperations print("in task filter method") #rf = ReportFileUtility(self.v_task_type) # self.v_input_sheet = self.v_input_wb.get_sheet_names("InputData") print("input data sheet selected") row_count = self.v_data_sheet.max_row print(row_count) eo = ExcelOperations(self.v_task_type, self.v_data_sheet) supplier_name = self.v_data_sheet.cell(row=2, column=1).value retailer_name = self.v_data_sheet.cell(row=2, column=2).value doc_type = self.v_data_sheet.cell(row=2, column=3).value date = self.v_data_sheet.cell(row=2, column=4).value ptfu = Process_Test_Files_Utility(self.v_task_type, self.lo, self.v_driver, self.v_input_wb) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) time.sleep(3) self.v_driver.switch_to.frame(0) time.sleep(2) ptfu.search_by_names(supplier_name, retailer_name, doc_type, date) # ptfu.search_by_names("CAULIPOWER","Amazon.com","850","09/20/2018") ptfu.get_five_parcels() path = '../Applications/Workflows/ProcessTestFiles/AppResources/parcelIDsforSearch.txt' #path = 'D:\parcelIDsforSearch.txt' with open(path) as f: parcel_id_for_vali_and_autoit = '' for line in f: parcel = line.replace('\n', '') print("Download Parcel ID : " + str(parcel)) #self.v_driver.switch_to.frame(0) ptfu.search_by_parcel_id(str(parcel)) #generated_parcel_id = ptfu.save_page_source_and_generate_parcel_id_from_dom() #xpath_for_click = ptfu.generate_xpath_for_TT(generated_parcel_id) parcel_id_for_validation_and_autoit = so.get_text_by_xpath( "//aside[text()='Transformations']/following::a[@title='View']/div[1]/following::span[2]" ) print("downloaded parcel ID :" + str(parcel_id_for_validation_and_autoit)) so.click_element_by_xpath( "//aside[text()='Transformations']/following::a[@title='View'][1]/div/div" ) parcel_id_for_vali_and_autoit = parcel_id_for_vali_and_autoit + parcel_id_for_validation_and_autoit + "\n" print(parcel_id_for_validation_and_autoit) element = WebDriverWait(self.v_driver, 20).until( EC.element_to_be_clickable(( By.XPATH, "html/body/div[1]/section/section/div/div/section/div/div[3]/div[1]/div/div[1]/div/div/div/a/i" ))) element.click() time.sleep(2) # shutil.copy(downloaded_parcel_path, copy_to_path) if 'str' in line: #time.sleep(4) break file = open( "../Applications/Workflows/ProcessTestFiles/AppResources/parcel_id_for_validation_and_autoit.txt", "w+") file.write(parcel_id_for_vali_and_autoit)
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): 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 Get_parameters(self): self.log.log_to_file(self, "INFO", " Geting parameters in Supplier Side! ") time.sleep(3) self.parameters_list = [] self.parameters = self.driver.find_elements_by_xpath( Element.parameters) for self.parameter in self.parameters: self.parameters_list.append(self.parameter.text) self.df_parameter = pandas.DataFrame(columns=['parameters']) self.df_parameter['parameters'] = self.parameters_list # print(self.df_parameter) self.df_parameter = self.df_parameter.iloc[1:, :] self.df_parameter['parameters'] = self.df_parameter[ 'parameters'].str.split('\n').str[0] self.df_parameter.rename(columns={'parameters': 'NAME'}, inplace=True) indexes_to_be_removed = self.df_parameter.loc[self.df_parameter['NAME'] == "ID"].index[0] self.df_parameter = self.df_parameter.iloc[:indexes_to_be_removed - 1, :] self.df_parameter = pandas.DataFrame(self.df_parameter.NAME.str.split( ' ', 1).tolist(), columns=['NAME', 'VALUE']) print(self.df_parameter) print( "_____________________________________________________________________________" ) try: if numpy.isnan(self.ERP_sheet.WRAPDOCUMENT.iloc[0]): print('WRAPDOCUMENT not applicable') except: if self.ERP_sheet.WRAPDOCUMENT.iloc[0] == \ self.df_parameter.loc[self.df_parameter['NAME'] == 'WRAPDOCUMENT', 'VALUE'].iloc[0]: print('WRAPDOCUMENT value matched') else: self.Warning( 'cancel', 'Warning!! WRAPDOCUMENT value does not match, do you want to continue ?' ) try: if numpy.isnan(self.ERP_sheet.WRAPTRAILER.iloc[0]): print('WRAPTRAILER not applicable') except: if self.ERP_sheet.WRAPTRAILER.iloc[0] == \ self.df_parameter.loc[self.df_parameter['NAME'] == 'WRAPTRAILER', 'VALUE'].iloc[0]: print('WRAPTRAILER value matched') else: self.Warning( 'cancel', 'Warning!! WRAPTRAILER value does not match, do you want to continue ?' ) try: if numpy.isnan(self.ERP_sheet.WRAPHEADER.iloc[0]): print('WRAPHEADER not applicable') except: if self.ERP_sheet.WRAPHEADER.iloc[0] == \ self.df_parameter.loc[self.df_parameter['NAME'] == 'WRAPHEADER', 'VALUE'].iloc[0]: print('WRAPHEADER value matched') else: self.Warning( 'cancel', 'Warning!! WRAPHEADER value does not match, do you want to continue ?' ) print( "_____________________________________________________________________________" ) try: self.action_parameters_list = [] self.action_parameters = self.driver.find_elements_by_xpath( Element.action_parameters) for self.action_parameter in self.action_parameters: self.action_parameters_list.append(self.action_parameter.text) try: if numpy.isnan(self.ERP_sheet['PearlScriptAction'].iloc[0]): print("PearlScriptAction is not applicable") ExcelOperations.set_value_to_cell(file.Output_File_Path, 8, 2, 'NOT MATCHED') except: if self.action_parameters_list[0] == self.ERP_sheet[ 'PearlScriptAction'].iloc[0]: print("PearlScriptAction is Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 8, 2, 'MATCHED') else: self.Warning('cancel', "Warning!! PearlScriptAction is not Matched") try: if numpy.isnan(self.ERP_sheet['NamingScriptAction'].iloc[0]): print("NamingScriptAction is not applicable") ExcelOperations.set_value_to_cell(file.Output_File_Path, 9, 2, ' NOT MATCHED') except: if self.action_parameters_list[1] == self.ERP_sheet[ 'NamingScriptAction'].iloc[0]: print("NamingScriptAction is Matched") ExcelOperations.set_value_to_cell(file.Output_File_Path, 9, 2, 'MATCHED') else: self.Warning( 'cancel', "Warning!! NamingScriptAction is not Matched") except: self.Warning( 'cancel', "Warning!! PearlScriptAction and NamingScriptAction is not Present !! DO You want " "to Continue ?") pass
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): 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_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 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 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, v_erp, 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_supplier) 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_retailer) 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) print(v_erp) if doc_type == v_document_type_1: if service != 'DoNotRoute' and service != 'WEBtoService': print("850 capability is already available") print(v_document_type_1) else: print('add new capability') add_existing_capability = selenium_operations.click_element_by_xpath( '//*[@id="form1:table1:0:table2:addExistingCapability"]/img' ) time.sleep(2) self.v_driver.switch_to.window( self.v_driver.window_handles[-1]) time.sleep(3) self.v_driver.switch_to.frame(0) time.sleep(2) self.v_driver.find_element_by_xpath( '//*[@id="form1:showDetailHeader1"]/tbody/tr[2]/td[2]/table/tbody/tr[1]/td[1]' ).click() self.v_driver.find_element_by_xpath( '//*[@id="form1:inputText3"]').send_keys('FI%') time.sleep(3) if v_erp == 'QB': self.v_driver.find_element_by_xpath( '//*[@id="form1:inputText4"]' ).send_keys( 'SPS QuickBooks Adaptor | RSX 7.2 | 850 - Legacy') selenium_operations.click_element_by_xpath( '//*[@id="form1:commandButton2"]/img') print('850 QB exists') try: self.v_driver.find_element_by_xpath( '//*[@id="form1:table1:0:tableSelectMany1"]') capability_flag = 0 except: capability_flag = 1 elif v_erp == 'Dwyer': self.v_driver.find_element_by_xpath( '//*[@id="form1:inputText4"]').send_keys( 'Dwyer Adaptor V7 850 V2 XML') selenium_operations.click_element_by_xpath( '//*[@id="form1:commandButton2"]/img') print('850 QB exists') try: self.v_driver.find_element_by_xpath( '//*[@id="form1:table1:0:tableSelectMany1"]') capability_flag = 0 except: capability_flag = 1 else: self.v_driver.find_element_by_xpath( '//*[@id="form1:inputText4"]').send_keys( 'SPS Fishbowl Adaptor | RSX 7.2 | 850 - Legacy' ) selenium_operations.click_element_by_xpath( '//*[@id="form1:commandButton2"]/img') print('850 QB exists') try: self.v_driver.find_element_by_xpath( '//*[@id="form1:table1:0:tableSelectMany1"]') capability_flag = 0 except: capability_flag = 1 if capability_flag == 0: self.v_driver.find_element_by_xpath( '//*[@id="form1:table1:0:tableSelectMany1"]' ).click() Choose = selenium_operations.double_click_by_xpath( '//*[@id="form1:table1:commandButton1"]') time.sleep(10) else: self.v_driver.close() print('Add new capability') self.v_driver.switch_to.window( self.v_driver.window_handles[0]) time.sleep(2) selenium_operations.click_element_by_xpath( '//*[@id="form1:table1:0:table2:createCapability"]/img' ) time.sleep(5) self.v_driver.switch_to.window( self.v_driver.window_handles[-1]) time.sleep(3) self.v_driver.switch_to.frame(0) time.sleep(2) self.v_driver.find_element_by_xpath( '//*[@id="form1:findService"]').send_keys('1007') if v_erp == 'QB': self.v_driver.find_element_by_xpath( '//*[@id="form1:findDataType"]').send_keys( '106967') selenium_operations.click_element_by_xpath( '//*[@id="form1:commandButton1"]/img') elif v_erp == 'Dwwyer': self.v_driver.find_element_by_xpath( '//*[@id="form1:findDataType"]').send_keys( '91552') selenium_operations.click_element_by_xpath( '//*[@id="form1:commandButton1"]/img') else: self.v_driver.find_element_by_xpath( '//*[@id="form1:findDataType"]').send_keys( '109095') selenium_operations.click_element_by_xpath( '//*[@id="form1:commandButton1"]/img') self.v_driver.switch_to.window(self.v_driver.window_handles[0]) time.sleep(2) 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]') print(doc_type) capability_uid = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:table2:column24"]') print(capability_uid) profile_uid = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1:0:outputText1"]') print(profile_uid) if doc_type == v_document_type_1: if service != 'DoNotRoute' and service != 'WEBtoService': print("850 capability exist") selenium_operations.click_element_by_xpath( '//*[@id="form1:table1:0:table2:' + str(counter - 2) + ':tableSelectMany1"]') print("Capability selected") selenium_operations.click_element_by_xpath( '//*[@id="form1:table1:0:table2:disableCapability"]/img' ) time.sleep(10) break counter = counter + 1 path = 'Close'
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()))