def process(self, path): self.lo.log_to_file("INFO", "Executing TT_File_Download.process()") 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.get_five_parcels() path = CommonLocators.PROCESS_PATH #After Getting parcels, search with parcelID with open(path) as f: for line in f: parcel = line.replace('\n', '') ptfu.search_by_parcel_id(str(parcel)) so.click_element_by_xpath(CommonLocators.TRANSAFORMATION) element = WebDriverWait(self.v_driver, 20).until( EC.element_to_be_clickable( (By.XPATH, CommonLocators.TRANSAFORMATION1))) element.click() time.sleep(2) if 'str' in line: break
def search_by_parcel_id(self, parcel_id): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) print("in search_by_parcel_id method") self.v_driver.get( "https://commerce.spscommerce.com/transaction-tracker/prod/transactions/" ) time.sleep(4) self.v_driver.switch_to.frame(0) # parcel_id_textbox = self.driver.find_element_by_xpath( # "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/label/div/div[2]/input") so.send_text_by_xpath( "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/label/div/div[2]/input", parcel_id) # parcel_id_textbox.send_keys(parcel_id) time.sleep(4) # search_btn = self.driver.find_element_by_xpath( # "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[5]/div/button") so.click_element_by_xpath( "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[5]/div/button" ) # search_btn.click() time.sleep(4) first_parcel_id = self.v_driver.find_element_by_xpath( ".//*[@id='parentTablesContainer']/div[1]/table/tbody/tr/td[2]/span/a " ) so.click_element_by_xpath( ".//*[@id='parentTablesContainer']/div[1]/table/tbody/tr/td[2]/span/a" ) #first_parcel_id.click() time.sleep(3)
def add_existing_capability(self): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) capabilities_sheet = so.call_excel_sheet('Capabilities') for row_counter in range(5, 6): for col_counter in range(2, (capabilities_sheet.max_column) + 1): so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_ADD_EXISTING_CAPABILITY_BUTTON) time.sleep(2) so.switch_child_window_handle() so.switch_to_default_frame() so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_PLUS_SEARCH_BUTTON) capability_uid = capabilities_sheet.cell( row=row_counter, column=col_counter).value so.send_text_by_xpath( LocalElementLocator.DC4_PREPROD_CAPABILITY_UID, capability_uid) so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_FEC_SEARCH_BUTTON) so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_SEARCHED_CAPABILITY_UID_CHECKBOX) so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_FEC_CHOOSE_BUTTON) so.switch_parent_window_handle()
def requeue(self, parcel_list): selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) selenium_operation_object.click_element_by_xpath( LocalElementLocator.REQUEUE_PARCEL_TAB_XPATH) flag = 0 for v_index in range(0, len(parcel_list)): i = (v_index + 1) % 5 if i == 0: i = 5 parcel_path = '//*[@id="form1:inputText' + str(i) + '"]' flag = 0 if selenium_operation_object.check_exists_by_xpath(parcel_path): selenium_operation_object.send_text_by_xpath( parcel_path, parcel_list[v_index]) if i == 5: selenium_operation_object.click_element_by_id( LocalElementLocator.REQUEUE_PARCEL_BUTTON_ID) flag = 1 if flag == 0: selenium_operation_object.click_element_by_id( LocalElementLocator.REQUEUE_PARCEL_BUTTON_ID) selenium_operation_object.click_element_by_id( LocalElementLocator.ERROR_HOSPITAL_TAB_ID1)
def search_process_for_process_test_file(self, supplier, retailer, doc_type, date, mode): self.log.log_to_file( self, "INFO", "Executing method 'search_process' from TransactionTrackerOperations" ) self.driver.switch_to.frame(0) selenium_operations_object = SeleniumOperations(self.driver, self.log) if mode == "preprod": selenium_operations_object.click_element_by_xpath( ElementLocator.preprod_click) selenium_operations_object.click_element_by_xpath( ElementLocator.preprod) pass elif mode == "prod": pass time.sleep(2) self.select_customer("Company", supplier) time.sleep(2) self.select_customer("Trading Partner", retailer) selenium_operations_object.send_text_by_xpath( ElementLocator.START_DATE, date) selenium_operations_object.send_text_by_xpath( ElementLocator.DOCUMENT_TYPE, doc_type) selenium_operations_object.click_element_by_xpath( ElementLocator.Status_button) selenium_operations_object.click_element_by_xpath( ElementLocator.Accepted_click) selenium_operations_object.click_element_by_xpath( ElementLocator.SEARCH_BTN) time.sleep(5)
def select_customer(self, v_customer_type, v_customer_name): self.log.log_to_file("INFO", "Executing TransactionTrackerOperations.select_customer()") selenium_operations_object = SeleniumOperations(self.v_task_type, self.driver, self.log) time.sleep(2) if v_customer_type == "Company": selenium_operations_object.send_text_by_xpath(LocalElementLocator.COMPANY_SEARCH_INPUTBOX, v_customer_name) if v_customer_type == "Trading Partner": selenium_operations_object.send_text_by_xpath(LocalElementLocator.TRADING_SEARCH_INPUTBOX, v_customer_name) time.sleep(2) count = self.driver.find_elements_by_xpath(LocalElementLocator.DROP_DOWN_LIST) for i in range(len(count)): if v_customer_type == "Company": v_customer_from_TT = selenium_operations_object .get_text_by_xpath(LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_1 + str( i) + LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_2) if v_customer_type == "Trading Partner": v_customer_from_TT = selenium_operations_object .get_text_by_xpath( LocalElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_1 + str( i) + LocalElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_2) if v_customer_name.lower() == v_customer_from_TT.lower(): if v_customer_type == "Company": selenium_operations_object.click_element_by_xpath(LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_1 + str( i) + LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_2) if v_customer_type == "Trading Partner": selenium_operations_object.click_element_by_xpath(LocalElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_1 + str( i) + LocalElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_2) break time.sleep(2)
def add_extention(doc_type, supplier_version, retailer_version): so = SeleniumOperations(self.v_task_type, self.v_Browser, self.log) value = get_maps(doc_type, supplier_version, retailer_version) total_maps = value[0] all_maps = value[1] maps = all_maps.split(",") so.click_element_by_xpath(".//*[@id='form1:table1:commandButton1']/img" ) #click on add extention btn so.click_element_by_xpath( ".//.[contains(text(),'1080')]//preceding::*[contains(@type,'radio')][1]" ) #1080 map extention so.click_element_by_xpath( ".//*[@id='form1:table1:commandButton2_adfr_adfr']/img" ) #choose button for i in range(int(total_maps)): so.click_element_by_xpath(".//*[@id='form1:table1dd" + str(i) + "']/img") #start from 0 and execute 3 time for k in range(int(total_maps)): so.send_text_by_xpath(".//*[@id='form1:table1:" + str(k) + ":table2:0:outputText22']", maps[k]) #start from 0 and execute 3 time so.click_element_by_xpath( ".//*[@id='form1:commandButton2_adfr']/img") #save button
def search_trading_partner_name_in_relationships(self, retailer_name): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) so.send_text_by_xpath( LocalElementLocator.DC4_PREPROD_TRADING_PARTNER_NAME_TEXTFIELD, retailer_name) so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_SEARCH_BUTTON)
def error_status(self, parcel_uid, error_title): self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) time.sleep(3) link = 'https://commerce.spscommerce.com/transaction-tracker/prod/transactions/' + parcel_uid + '/' self.v_driver.get(link) time.sleep(15) self.v_driver.switch_to.frame(0) time.sleep(2) selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) time.sleep(2) if error_title == LocalElementLocator.ADHOC_ERROR_TITLE: path = '//*[@id="parcel-' + parcel_uid + '"]/div[2]/div/div/div[2]/form/div/button[2]' if not selenium_operation_object.check_exists_by_xpath(path): time.sleep(2) self.v_driver.get(link) time.sleep(10) self.v_driver.switch_to.frame(0) time.sleep(2) if not selenium_operation_object.check_exists_by_xpath(path): return 0 selenium_operation_object.click_element_by_xpath(path) i = 1 while (1): path1 = '/html/body/app-reporting/div/div/div/div/div[2]/div/section/div[2]/div[2]/div[' + str( i) + ']' temp = selenium_operation_object.get_text_by_xpath(path1) time.sleep(1) if parcel_uid in temp: ans = self.v_driver.find_element_by_xpath( '/html/body/app-reporting/div/div/div/div/div[2]/div/section/div[2]/div[2]/div[' + str(i + 1) + ']').text id = ans.split('AdhocReporting ')[1] id = id.split('\n')[0] break i = i + 1 selenium_operation_object.click_element_by_xpath( '//*[@id="parcel-' + id + '"]/div/div/div[1]/a/span/i[2]') status = selenium_operation_object.get_text_by_xpath( '//*[@id="parcel-' + id + '"]/div/ng-include/div/div/div[1]/div/div[2]/dl/div[2]/dd') if status == 'Accepted': return 1 else: return 0 else: return 1
def Login_Launchpad(self,driver): so = SeleniumOperations(self.v_task_type, driver, self.log) driver.get(ElementLocators.TRANSACTION_TRACKER_PROD_LINK) time.sleep(7) driver.switch_to.frame(0) # driver.find_element_by_xpath(ElementLocators.tt_username).send_keys(ElementLocators.tt_uname) # time.sleep(5) so.send_text_by_xpath(ElementLocators.tt_username, ElementLocators.tt_uname) so.send_text_by_xpath(ElementLocators.tt_password, ElementLocators.tt_pw) so.click_element_by_xpath(ElementLocators.tt_login_btn) time.sleep(2)
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 click_on_profile_name_via_relationships(self): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) searched_profiles_relationships = so.list_elements_by_xpath( LocalElementLocator.DC4_PREPROD_SEARCH_TABLE_CONTENT_TR) count_searched_profiles_relationships = len( searched_profiles_relationships) print(count_searched_profiles_relationships) if count_searched_profiles_relationships != 2: return else: so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_RELATIONSHIPS_PROFILE_NAME)
def select_customer(self, customer_type, customer_name): #self.driver.switch_to.frame(0) self.lo.log_to_file( "INFO", "Executing method 'select_customer' from TransactionTrackerOperations" ) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) print("Search for: " + str(customer_name)) time.sleep(2) # driver.switch_to.frame(0) if customer_type == "Company": # self.driver.switch_to.frame(0) so.send_text_by_xpath( "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[1]/div[2]/div/div[1]/div/div[1]/label/chosen-company/div/ul/li/input", customer_name) if customer_type == "Trading Partner": # self.driver.switch_to.frame(0) # TP_name = self.driver.find_element_by_xpath( # "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[1]/div[2]/div/div[1]/div/div[4]/label/chosen-trading-partner/div/ul/li/input") # time.sleep(2) print("================================" + customer_name) so.send_text_by_xpath( "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[1]/div[2]/div/div[1]/div/div[4]/label/chosen-trading-partner/div/ul/li/input", customer_name) # driver.find_element_by_xpath("html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[1]/div[2]/div/div[1]/div/div[4]/label/chosen-trading-partner/div/ul").click() #TP_name.send_keys(customer_name) time.sleep(3) count = self.v_driver.find_elements_by_xpath( ".//*[contains(@id,'ui-select-choices-row-')]") for i in range(len(count)): if customer_type == "Company": customer_from_TT = self.v_driver.find_element_by_xpath( ".//*[@id='ui-select-choices-row-0-" + str(i) + "']").text if customer_type == "Trading Partner": customer_from_TT = self.v_driver.find_element_by_xpath( ".//*[@id='ui-select-choices-row-1-" + str(i) + "']").text if customer_name == customer_from_TT: if customer_type == "Company": so.click_element_by_xpath( ".//*[@id='ui-select-choices-row-0-" + str(i) + "']") #self.driver.find_element_by_xpath(".//*[@id='ui-select-choices-row-0-" + str(i) + "']").click() if customer_type == "Trading Partner": so.click_element_by_xpath( ".//*[@id='ui-select-choices-row-1-" + str(i) + "']") #self.driver.find_element_by_xpath(".//*[@id='ui-select-choices-row-1-" + str(i) + "']").click() print("Found matching customer name at position: " + str(i + 1)) time.sleep(2)
def return_capability_uid(self): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) #capabilities_sheet = so.call_excel_sheet('Capabilities') capabilities_sheet = self.v_input_wb.get_sheet_by_name('Capabilities') for row_counter in range(5, 6): for col_counter in range(2, (capabilities_sheet.max_column) + 1): so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB) sheet_value_capability_notes = str( capabilities_sheet.cell(row=row_counter - 1, column=col_counter).value) so.send_text_by_xpath( LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB_NOTES, sheet_value_capability_notes) so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB_SEARCH) #print(len(so.list_elements_by_xpath(LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_TABLE))) if len( so.list_elements_by_xpath( LocalElementLocator. DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_TABLE) ) == 2: notes_content = str( so.get_text_by_xpath( LocalElementLocator. DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_NOTES)) if sheet_value_capability_notes == notes_content: print("New Capability UID Created:") print( so.get_text_by_xpath( LocalElementLocator. DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_CAPABILITY_UID )) capability_uid = str( so.get_text_by_xpath( LocalElementLocator. DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_CAPABILITY_UID )) capabilities_sheet.cell( row=row_counter, column=col_counter).value = capability_uid #self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) else: print( "Mess is done, Clean It :/ The Note that caused Issue" ) print(sheet_value_capability_notes) else: print("No Result Found for:") print(sheet_value_capability_notes) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
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 adding_map_extension(self, rsx_conversion_map, v_position): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) V_add_extensions_xpath = '//*[@id="form1:table1"]/table[1]/tbody/tr/td/table/tbody/tr/td[1]' time.sleep(1) if so.check_exists_by_xpath(V_add_extensions_xpath): so.click_element_by_xpath(V_add_extensions_xpath) V_map_extension_xpath = '//*[@id="form1:table1"]/table/tbody/tr[2]/td/table/tbody/tr[8]/td[1]' so.click_element_by_xpath(V_map_extension_xpath) self.lo.log_to_file("INFO", "Map Extension added") so.click_element_by_xpath('//*[@id="form1:table1:commandButton2"]') show_map_extension_xpath = '//*[@id="form1:table1dd' + str( v_position) + '"]' if so.check_exists_by_xpath(show_map_extension_xpath): so.click_element_by_xpath(show_map_extension_xpath) V_map_extension_input_xpath = '//*[@id="form1:table1:' + str( v_position) + ':table2:0:outputText22"]' if so.check_exists_by_xpath(V_map_extension_input_xpath): so.send_text_by_xpath(V_map_extension_input_xpath, rsx_conversion_map) self.lo.log_to_file("INFO", "Conversion Map added") return True else: self.lo.log_to_file("INFO", "Incorrect path for inout text") return False else: self.lo.log_to_file("INFO", "Incorrect path for show map extension") return False else: self.lo.log_to_file("INFO", "Incorrect path for add extensions xpath") return False
def get_info_from_description(self, index): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) path = '//*[@id="form1:table1:' + str(index) + ':commandLink1"]' so.click_element_by_xpath(path) doctype = so.get_text_by_xpath( LocalElementLocator.EH_DOCTYPE_INFO_XPATH) doctype = doctype.split(' ')[0] TPID = so.get_text_by_xpath( LocalElementLocator.EH_DESCRIPTION_INFO_XPATH) if 'Document:' in TPID: TPID = TPID.split('Document:')[1] TPID = TPID.split('\n')[0] #TPID = re.sub('\W+', '', TPID) else: TPID = 'Invalid TPID' return TPID, doctype
def upload_file(self,driver,parcel): self.lo.log_to_file("INFO", "Executing File_upload_autoit.upload_file()") so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) time.sleep(3) so.click_element_by_xpath(AppConstants.FTP_ADD_FILES_BTN) time.sleep(2) #Hardcoded path required for AutoIT tool path="C:" + "\\" + "Users" + "\\" + getpass.getuser() + "\\" + "Downloads" + "\\" +parcel + ".dat" os.system(AppConstants.AUTOIT_FTP_UPLOAD_SCRIPT + path) time.sleep(5) driver.switch_to.frame(2) so.click_element_by_xpath(C.FTP_UPLOAD_FILES_BTN) time.sleep(2) i=1 for i in range (2): driver.refresh() time.sleep(10)
def search_by_parcel_id_and_download(self, parcel_id): self.create_file_save_path("supplier", "retailer") print("search_by_parcel_id_and_download method") self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK + parcel_id) so = SeleniumOperations(self.v_task_type, self.driver, self.lo) time.sleep(1) self.driver.switch_to.frame(0) time.sleep(1) PARCEL_FIRST_STAGE_ID = so.get_text_by_xpath( LocalElementLocator.PARCEL_FIRST_STAGE_ID) self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK + parcel_id + "/parcel/" + PARCEL_FIRST_STAGE_ID) time.sleep(2) self.driver.switch_to.frame(0) so.click_element_by_xpath(LocalElementLocator.DOWNLOAD_LOGO_BUTTON) time.sleep(3)
def search_retailer_profile(self, profie_name): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) self.show_all('//*[@id="form1:table1-nb__xc_c"]', 'all') profile_flag = 0 row_index = 2 while (profile_flag == 0): V_relationship_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( row_index) + ']/td[4]' if so.check_exists_by_xpath(V_relationship_profile_path): V_relationship_profile_name = so.get_text_by_xpath( V_relationship_profile_path) if V_relationship_profile_name == profie_name: ret_row_index = row_index - 2 V_relationship_retailer_name_path = '//*[@id="form1:table1:' + str( ret_row_index) + ':commandLink2"]' V_relationship_retailer_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( row_index) + ']/td[6]' if so.check_exists_by_xpath( V_relationship_retailer_name_path): V_relationship_retailer_name = so.get_text_by_xpath( V_relationship_retailer_name_path) ret_row_index = row_index - 2 so.click_element_by_xpath( V_relationship_retailer_name_path) 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", "Retailer company Found") else: return False if so.check_exists_by_xpath( V_relationship_retailer_profile_path): V_relationship_retailer_profile_name = so.get_text_by_xpath( V_relationship_retailer_profile_path) self.lo.log_to_file("INFO", "Retailer profile found") else: return False profile_flag = 1 return V_relationship_retailer_name, V_relationship_retailer_profile_name, row_index else: row_index = row_index + 1 else: self.lo.log_to_file("INFO", "Retailer profile not found") return False, False, False
def login_to_sailpoint(self): print("login_to_sailpoint") so = SeleniumOperations(self.v_task_type, self.v_Browser, self.log) self.v_Browser.get(ElementLocators.SALESFORCE_URL) so.click_element_by_xpath(".//*[@id='idp_section_buttons']/button[2]") # so.click_element_by_xpath(".//*[@id='cancel_idp_hint']")#Log In with a Different Account link # so.click_element_by_xpath(".//*[contains(text(),'SailPoint')]") # so.click_element_by_xpath(ElementLocators.SAILPOINT_BTN) # self.v_Browser.get("https://iam.spscommerce.com/login/login?spEntityID=https%3A%2F%2Fspscommerce.my.salesforce.com&goto=https%3A%2F%2Fiam-sso.spscommerce.com%2Fsso%2FSSORedirect%2FmetaAlias%2Fspscommerce%2Fidp%3FReqID%3D_2CAAAAXCfPa15ME8wMGcwMDAwMDA0Qzk4AAAA3kV67IWmbs12h6m088CMAf07tJcrGOLzEuC6k0Aq2epzV0oaRieDf2U4LBX0Ve0lPuXoZm0y4nxzD4vTrqr7X4mue0_5qLojuNHUxFCj61_mB3PZQj97LDNHpjxkZunTSBRH90cSn5xydi1kFAyU8PVF4s8BKuzm6j8kJzse7O_CephJERN1e6PoPj0VKwaWkFnvGnr-YNZyL64Uy3nUyttHGaMkHw4OYrepEuTK31x1D7qp0MwTmiK2l4_ZqOdVBw%26index%3Dnull%26acsURL%3Dhttps%253A%252F%252Fspscommerce.my.salesforce.com%253Fso%253D00D300000000bzv%26spEntityID%3Dhttps%253A%252F%252Fspscommerce.my.salesforce.com%26binding%3Durn%253Aoasis%253Anames%253Atc%253ASAML%253A2.0%253Abindings%253AHTTP-POST") # time.sleep(2) # self.v_Browser.get("https://iam.spscommerce.com/login/login?spEntityID=https%3A%2F%2Fspscommerce.my.salesforce.com&goto=https%3A%2F%2Fiam-sso.spscommerce.com%2Fsso%2FSSORedirect%2FmetaAlias%2Fspscommerce%2Fidp%3FReqID%3D_2CAAAAXCfPa15ME8wMGcwMDAwMDA0Qzk4AAAA3kV67IWmbs12h6m088CMAf07tJcrGOLzEuC6k0Aq2epzV0oaRieDf2U4LBX0Ve0lPuXoZm0y4nxzD4vTrqr7X4mue0_5qLojuNHUxFCj61_mB3PZQj97LDNHpjxkZunTSBRH90cSn5xydi1kFAyU8PVF4s8BKuzm6j8kJzse7O_CephJERN1e6PoPj0VKwaWkFnvGnr-YNZyL64Uy3nUyttHGaMkHw4OYrepEuTK31x1D7qp0MwTmiK2l4_ZqOdVBw%26index%3Dnull%26acsURL%3Dhttps%253A%252F%252Fspscommerce.my.salesforce.com%253Fso%253D00D300000000bzv%26spEntityID%3Dhttps%253A%252F%252Fspscommerce.my.salesforce.com%26binding%3Durn%253Aoasis%253Anames%253Atc%253ASAML%253A2.0%253Abindings%253AHTTP-POST") # self.v_Browser.get("https://iam.spscommerce.com/login/login?spEntityID=https%3A%2F%2Fspscommerce.my.salesforce.com&goto=https%3A%2F%2Fiam-sso.spscommerce.com%2Fsso%2FSSORedirect%2FmetaAlias%2Fspscommerce%2Fidp%3FReqID%3D_2CAAAAXCfPa15ME8wMGcwMDAwMDA0Qzk4AAAA3kV67IWmbs12h6m088CMAf07tJcrGOLzEuC6k0Aq2epzV0oaRieDf2U4LBX0Ve0lPuXoZm0y4nxzD4vTrqr7X4mue0_5qLojuNHUxFCj61_mB3PZQj97LDNHpjxkZunTSBRH90cSn5xydi1kFAyU8PVF4s8BKuzm6j8kJzse7O_CephJERN1e6PoPj0VKwaWkFnvGnr-YNZyL64Uy3nUyttHGaMkHw4OYrepEuTK31x1D7qp0MwTmiK2l4_ZqOdVBw%26index%3Dnull%26acsURL%3Dhttps%253A%252F%252Fspscommerce.my.salesforce.com%253Fso%253D00D300000000bzv%26spEntityID%3Dhttps%253A%252F%252Fspscommerce.my.salesforce.com%26binding%3Durn%253Aoasis%253Anames%253Atc%253ASAML%253A2.0%253Abindings%253AHTTP-POST") so.send_text_by_xpath(ElementLocators.SAILPOINT_USERNAME_TEXTBOX, ElementLocators.SAILPOINT_CREDENTIAL_USENAME) so.send_text_by_xpath(ElementLocators.SAILPOINT_PASSWORD_TEXTBOX, ElementLocators.SAILPOINT_CREDENTIAL_PASSWORD) so.click_element_by_xpath(ElementLocators.SAILPOINT_LOGIN_BTN)
def search_process_for_process_test_file(self, supplier, retailer, doc_type, date): print( "=====================================Task Number: ===================================" ) print( "============================================================================================" ) self.lo.log_to_file( "INFO", "Executing method 'search_process' from TransactionTrackerOperations" ) self.driver.switch_to.frame(0) so = SeleniumOperations(self.v_task_type, self.driver, self.lo) time.sleep(2) self.select_customer("Company", supplier) time.sleep(1) self.select_customer("Trading Partner", retailer) so.send_text_by_xpath(LocalElementLocator.START_DATE, date) so.click_element_by_xpath(LocalElementLocator.SERVICE) so.click_element_by_xpath(LocalElementLocator.DC4ROUTER) so.send_text_by_xpath(LocalElementLocator.DOCUMENT_TYPE, doc_type) so.click_element_by_xpath(LocalElementLocator.SEARCH_BTN) time.sleep(3)
def retailer_ver_check(self, doc_type, retailer_capability_name): self.lo.log_to_file("INFO", "Login in to DC4 Pre_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( CommonLocators.DC4_ADMIN_TAB) selenium_operations.send_text_by_xpath( CommonLocators.DATATYPE_NAME_TEXTFIELD, retailer_capability_name) selenium_operations.click_element_by_xpath( CommonLocators.DATATYPE_SEARCH_BUTTON) retailer_FEDS_capability_name = selenium_operations.get_text_by_xpath( CommonLocators.FEDS_CAPABILITY) selenium_operations.send_text_by_xpath( CommonLocators.DATATYPE_NAME_TEXTFIELD, retailer_FEDS_capability_name) table_rows = self.v_driver.find_elements_by_xpath( '//*[@id="form1:table1"]/table[2]/tbody/tr[1]/th[1]') total_rows = len(table_rows) - 1 print(total_rows) for counter in range(0, total_rows): retailer_version_value = selenium_operations.get_text_by_xpath( '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(counter) + ']/td[7]') if retailer_version_value == " ": pass else: return retailer_version_value
def login(self, v_tool): if v_tool == "DC4 Prod": Link = AppConstants.DC4_PROD_LINK elif v_tool == "DC4 PreProd": Link = AppConstants.DC4_PREPROD_LINK elif v_tool == "Launchpad": Link = AppConstants.LAUNCHPAD_LINK elif v_tool == "FTP Pre-prod": Link = AppConstants.FTP_PREPROD_LINK else: self.lo.log_to_file("ERROR", "Error in Login.login(). Invalid Link") return False self.v_driver.get(Link) SeleniumOperation = SeleniumOperations(self.v_driver, self.lo) if v_tool == "Launchpad": print("IN login method for Launchpad") time.sleep(7) self.v_driver.switch_to.frame(0) SeleniumOperation.send_text_by_xpath( ElementLocator.Login_Email_Xpath, ElementLocator.Launchpad_username) SeleniumOperation.send_text_by_xpath( ElementLocator.Login_Password_Xpath, ElementLocator.Launchpad_password) SeleniumOperation.click_element_by_xpath( ElementLocator.Login_Button) elif v_tool == "FTP Pre-prod": print("IN login method for FTP") self.v_driver.get(ElementLocator.FTP_PREPROD_LINK) SeleniumOperation.send_text_by_xpath( ElementLocator.FTP_USERNAME_Xpath, ElementLocator.FTP_pre_prod_username) SeleniumOperation.send_text_by_xpath( ElementLocator.FTP_PASSWORD_Xpath, ElementLocator.FTP_pre_prod_password) SeleniumOperation.click_element_by_xpath( ElementLocator.FTP_LOGIN_BUTTON_Xpath)
def get_info_from_description(self, v_index): selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) v_path = '//*[@id="form1:table1:' + str(50 + v_index) + ':commandLink1"]' if selenium_operation_object.check_exists_by_xpath(v_path) == True: v_path = v_path else: v_path = '//*[@id="form1:table1:' + str( v_index) + ':commandLink1"]' selenium_operation_object.click_element_by_xpath(v_path) v_doctype = selenium_operation_object.get_text_by_xpath( LocalElementLocator.EH_DOCTYPE_INFO_XPATH) v_doctype = v_doctype.split(' ')[0] v_TPID = selenium_operation_object.get_text_by_xpath( LocalElementLocator.EH_DESCRIPTION_INFO_XPATH) if 'Document:' in v_TPID: v_TPID = v_TPID.split('Document: ')[1] v_TPID = v_TPID.split('\n')[0] else: v_TPID = 'Invalid v_TPID' return v_TPID, v_doctype
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 Download_processFile(self): selenium_operations_object = SeleniumOperations(self.driver, self.log) # tt_first_parcel = selenium_operations_object.get_text_by_xpath(ElementLocator.parcel_1_click) # tt_second_parcel = selenium_operations_object.get_text_by_xpath(ElementLocator.parcel_2_click) # tt_third_parcel = selenium_operations_object.get_text_by_xpath(ElementLocator.parcel_3_click) selenium_operations_object.click_element_by_xpath( ElementLocator.parcel_1_click) self.get_parcel("1") # selenium_operations_object.send_text_by_xpath(ElementLocator.search_parcel,tt_second_parcel) selenium_operations_object.click_element_by_xpath( ElementLocator.parcel_2_click) self.get_parcel("2") selenium_operations_object.click_element_by_xpath( ElementLocator.parcel_3_click) self.get_parcel("3")
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.lo) if v_tool in sheet_names: login_sheet = login_wb.get_sheet_by_name(v_tool) else: self.lo.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.lo.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 search_process_for_CMPDM(self,supplier,retailer,doc_type,date, input_sheet,row): print("Task no: "+str(row)) print("--------------") try: self.log.log_to_file("INFO", "Executing TransactionTrackerOperations.search_process_for_CMPDM() for: "+str(supplier)+"|"+str(retailer)+"|"+str(doc_type)) self.driver.switch_to.frame(0) selenium_operations_object = SeleniumOperations(self.v_task_type, self.driver, self.log) self.select_customer("Company",supplier) self.select_customer("Trading Partner",retailer) selenium_operations_object.send_text_by_xpath(LocalElementLocator.START_DATE,date) selenium_operations_object.click_element_by_xpath(LocalElementLocator.SERVICE) selenium_operations_object.click_element_by_xpath(LocalElementLocator.DC4ROUTER) selenium_operations_object.send_text_by_xpath(LocalElementLocator.DOCUMENT_TYPE,doc_type) selenium_operations_object.click_element_by_xpath(LocalElementLocator.SEARCH_BTN) time.sleep(3) self.get_CM_parcels(input_sheet, row) except NoSuchElementException: self.log.log_to_file("ERROR", "Fail in TransactionTrackerOperations.search_process_for_CMPDM() for: " + str( supplier) + "|" + str(retailer) + "|" + str(doc_type))
def company_search_by_name(self, company_name): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) so.click_element_by_name(AppConstants.DC4_TAB) so.send_text_by_xpath(AppConstants.DC4_COMPANY_NAME_TEXT_FIELD, company_name) so.click_element_by_xpath(AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK)