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 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 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_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 search_by_names(self, supplier, retailer, doc_type, date): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) print("in search_by_names method") self.select_customer("Company", supplier) time.sleep(3) self.select_customer("Trading Partner", retailer) time.sleep(2) so.send_text_by_xpath( "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/div/div[1]/label/input", date) time.sleep(2) time.sleep(2) service = self.v_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[2]/div/div[1]/label/select" ) #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[2]/div/div[1]/label/select", "DC4Router") service.send_keys("DC4Router") 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[2]/div/div[3]/label/input", doc_type) search_btn = self.v_driver.find_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(3) clear_btn = self.v_driver.find_element_by_xpath( "html/body/div[1]/section/section/div/div/section/div/div[1]/div[2]/div[5]/div/a" )
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 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 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 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 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 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 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 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 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 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 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 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 add_new_capability(self): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) po_service_uid = "1007" return_documents_service_uid = "1006" #capabilities_sheet=so.call_excel_sheet('Capabilities') capabilities_sheet = self.v_input_wb.get_sheet_by_name('Capabilities') #Loop to Iterate through the Capabilities Excel Sheet #for row_counter in range (1,(capabilities_sheet.max_row)+1): for row_counter in range(1, 2): for col_counter in range(2, (capabilities_sheet.max_column) + 1): so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB) so.click_element_by_xpath( LocalElementLocator.DC4_PREPROD_ADD_CAPABILITY_BUTTON) sheet_value = capabilities_sheet.cell(row=row_counter, column=col_counter).value #Switch to Create Capability Child Window; so.switch_child_window_handle() so.switch_to_default_frame() time.sleep(2) #Click on the Search Service Torch; Switch to the Search Service Child Window so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SERVICE_TORCH) time.sleep(2) so.switch_child_window_handle() so.switch_to_default_frame() #If Condition to validate serviceUID input based on Inbound/Outbound Documents if str(sheet_value) == "850" or str( sheet_value) == "850 Outbound": so.send_text_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SERVICE_SERVICE_UID, po_service_uid) else: so.send_text_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SERVICE_SERVICE_UID, return_documents_service_uid) so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_SEARCH_SERVICES_SEARCH_BUTTON) so.get_text_by_xpath( LocalElementLocator. DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID) #print(so.get_text_by_xpath(LocalElementLocator.DC4_PREPROD_CREATE_CAPABILITY_SERVICE_SERVICE_UID)) #print(so.get_text_by_xpath(LocalElementLocator.DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID)) sheet_value_service_uid_validation = str( capabilities_sheet.cell(row=row_counter + 1, column=col_counter).value) print("Adding Capability") print( so.get_text_by_xpath( LocalElementLocator. DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID)) #Validating ServiceUID Input with the SearchResult & Clicking Choose if sheet_value_service_uid_validation == str( so.get_text_by_xpath( LocalElementLocator. DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID )): so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_SEARCH_SERVICES_CHOOSE_BUTTON) else: print("Service Validation Failed") return time.sleep(1) so.switch_child_window_handle() so.switch_to_default_frame() so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_CAPABILITY_TORCH) time.sleep(1) so.switch_child_window_handle() so.switch_to_default_frame() sheet_value_capability_name = str( capabilities_sheet.cell(row=row_counter + 2, column=col_counter).value) print(sheet_value_capability_name) so.send_text_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_DATATYPE_NAME, sheet_value_capability_name) so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_SEARCH_BUTTON ) datatype_name_result_table_count = len( so.list_elements_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_DATATYPE_NAME_RESULT_TABLE )) #print(datatype_name_result_table_count) if datatype_name_result_table_count > 2: self.v_driver.close() so.switch_child_window_handle() self.v_driver.close() return else: so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_SEARCHED_CAPABILITY_CHECKBOX ) so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_CHOOSE_BUTTON ) time.sleep(1) so.switch_child_window_handle() so.switch_to_default_frame() sheet_value_capability_notes = str( capabilities_sheet.cell(row=row_counter + 3, column=col_counter).value) so.send_text_by_xpath( LocalElementLocator.DC4_PREPROD_CREATE_CAPABILITY_NOTES, sheet_value_capability_notes) so.click_element_by_xpath( LocalElementLocator. DC4_PREPROD_CREATE_CAPABILITY_SUBMIT_BUTTON) so.switch_parent_window_handle() #so.switch_to_default_frame() print("Great! New Capabilities have been Added :) ")
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)
class DC4_Prod_Actions: # Check_Capability_Status def __init__(self, task_type, lo, username,v_Browser): self.v_input_wb = openpyxl.load_workbook(ElementLocators.INPUT_FILE_PATH) self.v_task_type = task_type self.v_input_sheet = self.v_input_wb.get_sheet_by_name("Input") self.v_input_sheet_maps = self.v_input_wb.get_sheet_by_name("Maps") self.v_input_sheet_Adaptor_Data_Type_ID = self.v_input_wb.get_sheet_by_name("Adaptor Data Type ID") self.log = lo self.v_username = username self.v_Browser=v_Browser self.so = SeleniumOperations(self.v_task_type, self.v_Browser, self.log) self.login_operations_object = Login(self.v_task_type, self.v_Browser, self.v_input_wb, self.log) self.so = SeleniumOperations(self.v_task_type, self.v_Browser, self.log) self.login_operations_object.login("Launchpad") self.login_operations_object.login("DC4 Prod") # time.sleep(5) # self.v_Browser.get("https://commerce.spscommerce.com/migrator/") # time.sleep(10) # self.Migrator("960468") # time.sleep(10000) # def Migrator(self, profile_uid): # # self.v_Browser.get("https://commerce.spscommerce.com/migrator/") # # time.sleep(10) # self.v_Browser.switch_to.frame(0) # time.sleep(5) # self.v_Browser.find_element_by_xpath(".//*[contains(text(),'Search by column')]//select").click() # time.sleep(2) # self.v_Browser.find_element_by_xpath(".//*[contains(text(),'profile_uid')]").click() # # time.sleep(3) # # driver.find_element_by_xpath(".//b").click() # time.sleep(4) # self.v_Browser.find_element_by_xpath( # "html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/a").click() # time.sleep(4) # self.v_Browser.find_element_by_xpath( # "html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/div/div/input").send_keys( # profile_uid) # # driver.find_element_by_xpath("html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/div/div/input").click() # time.sleep(3) # self.v_Browser.find_element_by_xpath( # "html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/div/div/input").clear() # self.v_Browser.find_element_by_xpath( # "html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/div/div/input").send_keys( # profile_uid) # time.sleep(3) # self.v_Browser.find_element_by_xpath(".//ul/li").click() # # self.v_Browser.switch_to.frame(0) # time.sleep(3) # self.v_Browser.find_element_by_xpath(".//*[contains(text(),'Export')]").click() # self.v_Browser.find_element_by_xpath(".//*[contains(text(),'Migrate')]").click() # # self.v_Browser.find_element_by_xpath(".//*[contains(@class,'medium button confirm')]").click() # print("clicked on migrator") def Migrator(self, relationship_uid): self.v_Browser.get("https://commerce.spscommerce.com/migrator/") time.sleep(10) self.v_Browser.switch_to.frame(0) self.so.click_element_by_xpath(".//*[contains(text(),'Table')]//select") self.so.click_element_by_xpath(".//*[contains(text(),'relationship')]") self.so.click_element_by_xpath("html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/a") self.so.send_text_by_xpath("html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/div/div/input",relationship_uid) time.sleep(8) self.so.send_text_by_xpath("html/body/div[1]/div/div/api-interaction/div/div[4]/label/chosen-select/div/div/div/input",relationship_uid) time.sleep(8) self.so.click_element_by_xpath(".//ul/li") self.so.click_element_by_xpath(".//*[contains(text(),'Export')]") time.sleep(15) self.so.click_element_by_xpath(".//*[contains(text(),'Migrate')]") time.sleep(15) print("clicked on migrator") def get_maps(self,doc_type,adaptor,retailer_version): for i in range(1,self.v_input_sheet_maps.max_row+1): doc_type_from_sheet = self.v_input_sheet_maps.cell(row=i, column=1).value if str(doc_type_from_sheet)==str(doc_type): supplier_version_from_sheet = self.v_input_sheet_maps.cell(row=i, column=2).value if adaptor=="Quickbooks" or adaptor=="Fishbowl": supplier_version="7.2" if adaptor=="Dwyer" or adaptor=="Peachtree": supplier_version="7" if str(supplier_version_from_sheet)==str(supplier_version): retailer_version_from_sheet = self.v_input_sheet_maps.cell(row=i, column=3).value if str(retailer_version_from_sheet)==str(retailer_version): maps=self.v_input_sheet_maps.cell(row=i, column=5).value arr_maps=maps.split(",") return arr_maps def get_capability_name(self,adaptor, doc): Quickbooks = {"810": ["SPS QuickBooks Adaptor | RSX 7.2 | 810 - Legacy", "106968"], "850": ["SPS QuickBooks Adaptor | RSX 7.2 | 850 - Legacy", "106967"], "875": ["SPS QuickBooks Adaptor | RSX 7.2 | 875 - Legacy", "110240"], "856": ["SPS Quickbooks Adapter RSX 7.2 | OzLink | 856", "135124"]} Fishbowl = {"810": ["SPS Fishbowl Adaptor | RSX 7.2 | 810 - Legacy", "109097"], "850": ["SPS Fishbowl Adaptor | RSX 7.2 | 850 - Legacy", "109095"], "875": ["SPS FISHBOWL ADAPTOR | RSX 7.2 | 875 - LEGACY", "112556"], "856": ["SPS Fishbowl Adaptor | RSX 7.2 | 856 - Legacy", "109096"]} Dwyer = {"810": ["Dwyer Adaptor V7 810 XML", "31788"], "850": ["Dwyer Adaptor V7 850 XML", "31768"], "875": ["Dwyer Adaptor V7 875 XML", "70230"]} Peachtree = {"810": ["Peachtree 810 XML", "73633"], "850": ["Peachtree 850 XML", "73632"], "875": ["Peachtree 875 XML", "78248"]} if adaptor == "Quickbooks": arr = Quickbooks.get(doc) return arr if adaptor == "Fishbowl": arr = Fishbowl.get(doc) return arr if adaptor == "Dwyer": arr = Dwyer.get(doc) return arr if adaptor == "Peachtree": arr = Peachtree.get(doc) return arr def Search_By_TPID(self,TPID): # self.so.click_element_by_xpath(ElementLocators.Browse_Customers) self.v_Browser.get(ElementLocators.DC4_Prod_link) self.so.click_element_by_xpath(ElementLocators.Customers_by_TPID) self.so.send_text_by_xpath(ElementLocators.TPID_input_box,TPID) self.so.click_element_by_xpath(ElementLocators.Search_button) Company_name=self.so.get_text_by_xpath(ElementLocators.Company_name) Profile_name=self.so.get_text_by_xpath(ElementLocators.Profile_name) return Company_name+"$"+Profile_name def Open_supplier(self,TPID): self.so.click_element_by_xpath(ElementLocators.First_company_name) self.so.click_element_by_xpath(ElementLocators.Relationships) self.so.click_element_by_xpath(ElementLocators.Relationships_Advanced) if self.so.check_exists_by_xpath(ElementLocators.Sender_as_Show_all): self.so.click_element_by_xpath(ElementLocators.Sender_as_Show_all) self.so.click_element_by_xpath(ElementLocators.Show_all_profile) self.so.click_element_by_xpath(ElementLocators.Receiver_as_Show_all) self.so.click_element_by_xpath(ElementLocators.Show_all_profile2) time.sleep(5) Retailer_name=self.so.get_text_by_xpath("//*[contains(text(),'"+str(TPID)+"') and contains(@id,'form1:table3:')]//preceding::span[5]") Relationship_UID_as_Sender=self.so.get_text_by_xpath("//*[contains(text(),'"+str(TPID)+"') and contains(@id,'form1:table3:')]//preceding::span[6]") Relationship_UID_as_Receiver=self.so.get_text_by_xpath("//*[contains(text(),'"+str(TPID)+"') and contains(@id,'form1:table4:')]//preceding::span[8]") self.so.click_element_by_xpath(ElementLocators.Relationship_Overview) self.so.send_text_by_xpath(ElementLocators.Search_TP_box,Retailer_name) self.so.click_element_by_xpath(ElementLocators.TP_Search_button) return Retailer_name+"$"+Relationship_UID_as_Sender+"$"+Relationship_UID_as_Receiver def Open_profile(self,Profile_name): Company_EDI_Summary=self.so.get_text_by_xpath(ElementLocators.Company_EDI_Summary) Trading_Partner_EDI_Summary=self.so.get_text_by_xpath(ElementLocators.Trading_Partner_EDI_Summary) self.so.click_element_by_xpath("//*[contains(text(),'"+str(Profile_name)+"')]") self.so.click_element_by_xpath(ElementLocators.Show) return Company_EDI_Summary+"$"+Trading_Partner_EDI_Summary def Add_New_Capability(self,Doc_Type,capability_ID): self.so.click_element_by_xpath(ElementLocators.createCapability) time.sleep(3) all_windows = self.v_Browser.window_handles num_of_windows = len(all_windows) print(num_of_windows) requested_window = all_windows[1] self.v_Browser.switch_to.window(requested_window) print(self.v_Browser.current_url) print("Total Window: " + str(num_of_windows)) self.v_Browser.switch_to.frame(0) if str(Doc_Type)=='850' or str(Doc_Type)=='875': service_UID='1007' if str(Doc_Type)=='810'or str(Doc_Type)=='855' or str(Doc_Type)== '856': service_UID='1006' self.so.send_text_by_xpath(ElementLocators.service,service_UID) self.so.send_text_by_xpath(ElementLocators.Data_Type,"["+capability_ID+"]") self.so.click_element_by_xpath(ElementLocators.submit_create_capability) self.v_Browser.switch_to.window(self.v_Browser.window_handles[0]) def add_existing_capability(self,capability_name,capability_ID,Doc_Type): self.so.click_element_by_xpath(ElementLocators.addExistingCapability) #switch window time.sleep(4) all_windows=self.v_Browser.window_handles num_of_windows=len(all_windows) requested_window=all_windows[1] self.v_Browser.switch_to.window(requested_window) print(self.v_Browser.current_url) print("Total Window: "+str(num_of_windows)) self.v_Browser.switch_to.frame(0) # seq = self.v_Browser.find_elements_by_tag_name('frame') # print("seq len") # print(len(seq)) # for index in range(len(seq)): # iframe = self.v_Browser.find_elements_by_tag_name('iframe')[index] # print(iframe) # i = 0 time.sleep(3) print("------------------") count=self.v_Browser.find_elements_by_xpath("//a[contains(text(),'Show')]") print(len(count)) print("------------------") # while True: status='' for i in range(len(count)): required_capability_name = self.so.get_text_by_xpath("//span[@id='form1:table1:" + str(i) + ":outputText6']") print(required_capability_name) if str(capability_name) == str(required_capability_name): print("capability matched...............") checkbox = "//input[@id='form1:table1:" + str(i) + ":tableSelectMany1']" capability_uid = "//span[@id='form1:table1:" + str(i) + ":outputText2']" self.so.click_element_by_xpath(checkbox) self.so.click_element_by_xpath(ElementLocators.cap_choose_btn) # self.v_Browser.close() self.v_Browser.switch_to.window(self.v_Browser.window_handles[0]) status='capability selected' break else: status='Capability not available' if status=="Capability not available": self.v_Browser.close() self.v_Browser.switch_to.window(self.v_Browser.window_handles[0]) self.Add_New_Capability(Doc_Type,capability_ID) return "filebroker_required" else: return "filebroker_not_required" print(status) # print("in while loop") # flag = self.so.check_exists_by_xpath(required_capability_name) # val=self.so.get_text_by_xpath(required_capability_name) # print(val) # if self.so.check_exists_by_xpath(required_capability_name): # print("in True loop") # name_from_UI = self.so.get_text_by_xpath(required_capability_name) # if name_from_UI == capability_name: # print("capability matched...............") # checkbox="//input[@id='form1:table1:"+str(i)+":tableSelectMany1']" # capability_uid="//span[@id='form1:table1:"+str(i)+":outputText2']" # self.so.click_element_by_xpath(checkbox) # # self.so.click_element_by_xpath(ElementLocators.choose_btn) # time.sleep(3) # # self.v_Browser.close() # print("about to close") # time.sleep(1190) # break # # if self.so.check_exists_by_xpath(required_capability_name)==False: # print("in false loop") # time.sleep(3) # self.v_Browser.close() # # requested_window = all_windows[0] # # self.v_Browser.switch_to.window(requested_window) # # self.so.click_element_by_xpath(ElementLocators.Relationships) # time.sleep(1900) # capability not available # click on # break # i += 1 # if flag==False: # break def Toggle_profile_capability(self,capability_name): self.so.click_element_by_xpath(ElementLocators.Profiles_Tab) time.sleep(3) i = 0 action = '' while True: Datatype_Name = "//span[@id='form1:table1:0:table2:" + str(i) + ":outputText14']" flag = self.so.check_exists_by_xpath(Datatype_Name) if flag == True: name_from_UI = self.so.get_text_by_xpath(Datatype_Name) if name_from_UI == capability_name: status = "//span[@id='form1:table1:0:table2:" + str(i) + ":outputText13']" checkbox = "//input[@id='form1:table1:0:table2:" + str(i) + ":tableSelectMany1'] " Extentions = "//a[@id='form1:table1:0:table2:" + str(i) + ":extensionPopup']" checkbox = "//input[@id='form1:table1:0:table2:" + str(i) + ":tableSelectMany1'] " Status = self.so.get_text_by_xpath(status) self.so.click_element_by_xpath(checkbox) self.so.click_element_by_xpath(ElementLocators.Toggle_profile_capability_status) self.so.click_element_by_xpath(ElementLocators.Profiles_Tab) # if Status == "Active": # action = "do_nothing" # break # if Status == "Disabled": # action = "do_nothing" # check exxtentions # self.so.click_element_by_xpath(checkbox) break if flag == False: # capability not available # click on # self.add_existing_capability(capability_name, capability_ID, Doc_Type) break i += 1 def filebroker(self,capability_name,doc_type,ftp_name): # def filebroker(self): # added_cap_UID="2820910" # doc_type="850" # ftp_name="Demo" self.so.click_element_by_xpath(ElementLocators.Capabilities) # self.so.send_text_by_xpath(ElementLocators.Capability_UID_textbox,added_cap_UID) self.so.send_text_by_xpath(ElementLocators.Datatype_Name_textbox,capability_name) self.so.click_element_by_xpath(ElementLocators.search_capability) self.so.click_element_by_xpath(ElementLocators.editFilebrokerSettingsButton) time.sleep(5) self.v_Browser.switch_to.window(self.v_Browser.window_handles[1]) self.v_Browser.switch_to.frame(0) self.so.click_element_by_xpath(ElementLocators.add_filebroker_btn) time.sleep(4) if doc_type=='850' or doc_type=='875': Archive_Directory_path="/u01/Arc/ftp/vendor/"+ftp_name+"/out" Directory_path="/u01/ftp/vendor/"+ftp_name+"/out" FilenameMacro="PO%p" time.sleep(2) select = Select(self.v_Browser.find_element_by_id('_idJsp4:_idJsp8')) select.select_by_visible_text('DC4 - Read or write files from/to DC4') time.sleep(2) select = Select(self.v_Browser.find_element_by_id('_idJsp4:_idJsp39')) select.select_by_visible_text('File - Read or write files from/to internal comms server') time.sleep(4) # # self.so.click_element_by_xpath(ElementLocators.Source_Channel) # self.so.click_element_by_xpath(ElementLocators.Source_Channel_text) # self.so.click_element_by_xpath("//*[contains(text(),'Destination Channel')]") # time.sleep(3) # self.so.click_element_by_xpath(ElementLocators.Destination_Channel) # time.sleep(3) # self.so.click_element_by_xpath(ElementLocators.Destination_Channel_text) # self.so.click_element_by_xpath("//*[contains(text(),'Destination Channel')]") # time.sleep(2) # self.so.send_text_by_xpath(ElementLocators.Source_Channel,"DC4") # self.so.click_element_by_xpath(ElementLocators.Destination_Channel) # self.so.send_text_by_xpath(ElementLocators.Destination_Channel,"File - Read or write files from/to internal comms server") self.so.click_element_by_xpath(ElementLocators.continue_btn) time.sleep(4) self.so.send_text_by_xpath(ElementLocators.ArchiveDirectory_fito,Archive_Directory_path) self.so.send_text_by_xpath(ElementLocators.Directory_fito,Directory_path) self.so.send_text_by_xpath(ElementLocators.FilenameMacro_fito,FilenameMacro) self.so.click_element_by_xpath(ElementLocators.Save_Changes_btn) time.sleep(3) self.v_Browser.switch_to.window(self.v_Browser.window_handles[0]) if doc_type=='810' or doc_type=='856': Archive_Directory_path="/u01/Arc/ftp/vendor/"+ftp_name+"/in" Directory_path="/u01/ftp/vendor/"+ftp_name+"/in" status="Active" if doc_type=='810': FileSpecification="IN*" if doc_type=='856': FileSpecification="ASN*" time.sleep(2) select = Select(self.v_Browser.find_element_by_id('_idJsp4:_idJsp8')) select.select_by_visible_text('File - Read or write files from/to internal comms server') time.sleep(2) select = Select(self.v_Browser.find_element_by_id('_idJsp4:_idJsp39')) select.select_by_visible_text('DC4 - Read or write files from/to DC4') time.sleep(2) select = Select(self.v_Browser.find_element_by_id('_idJsp4:_idJsp70')) select.select_by_visible_text('Active') time.sleep(2) self.so.click_element_by_xpath(ElementLocators.continue_btn) # self.so.click_element_by_xpath(ElementLocators.Source_Channel) # self.so.click_element_by_xpath((ElementLocators.Destination_Channel_text)) # self.so.click_element_by_xpath(ElementLocators.Destination_Channel) # self.so.click_element_by_xpath(ElementLocators.Source_Channel_text) # # self.so.send_text_by_xpath(ElementLocators.Source_Channel,"File - Read or write files from/to internal comms server") # self.so.send_text_by_xpath(ElementLocators.Destination_Channel,"DC4 - Read or write files from/to DC4") # self.so.click_element_by_xpath(ElementLocators.Status) # self.so.click_element_by_xpath(ElementLocators.Status_text) # self.so.send_text_by_xpath(ElementLocators.Status,status) time.sleep(3) self.so.send_text_by_xpath(ElementLocators.ArchiveDirectory_fifrom,Archive_Directory_path) self.so.send_text_by_xpath(ElementLocators.Directory_fifrom,Directory_path) self.so.send_text_by_xpath(ElementLocators.FileSpecification,FileSpecification) self.so.click_element_by_xpath(ElementLocators.Save_Changes_btn) time.sleep(3) self.v_Browser.switch_to.window(self.v_Browser.window_handles[0]) def Add_Extentions(self, capability_name,arr_maps,Doc_Type,ftp_name): total_extentions = len(arr_maps) time.sleep(5) self.so.click_element_by_xpath(ElementLocators.Profiles_Tab) time.sleep(3) i = 0 action = '' while True: Datatype_Name = "//span[@id='form1:table1:0:table2:" + str(i) + ":outputText14']" flag = self.so.check_exists_by_xpath(Datatype_Name) if flag == True: name_from_UI = self.so.get_text_by_xpath(Datatype_Name) if name_from_UI == capability_name: status = "//span[@id='form1:table1:0:table2:" + str(i) + ":outputText13']" checkbox = "//input[@id='form1:table1:0:table2:" + str(i) + ":tableSelectMany1']" Extentions = "//a[@id='form1:table1:0:table2:" + str(i) + ":extensionPopup']" checkbox = "//input[@id='form1:table1:0:table2:" + str(i) + ":tableSelectMany1']" Status = self.so.get_text_by_xpath(status) added_cap_UID=self.so.get_text_by_xpath("//span[@id='form1:table1:0:table2:" + str(i) + ":outputText24']") self.so.click_element_by_xpath(Extentions) time.sleep(4) self.v_Browser.switch_to.window(self.v_Browser.window_handles[1]) self.v_Browser.switch_to.frame(0) for i in range(total_extentions): self.so.click_element_by_xpath(ElementLocators.Add_Extention_btn) self.so.click_element_by_xpath(ElementLocators.map_1080) self.so.click_element_by_xpath(ElementLocators.map_1080_choose) for i in range(total_extentions): self.so.click_element_by_xpath("//a[@id='form1:table1dd"+str(i)+"']//img") for i in range(total_extentions): self.so.send_text_by_xpath("//input[@id='form1:table1:"+str(i)+":table2:0:outputText22']",arr_maps[i]) self.so.click_element_by_xpath(ElementLocators.Extention_Save_Changes) time.sleep(3) self.v_Browser.switch_to.window(self.v_Browser.window_handles[0]) ############################################################### self.filebroker(added_cap_UID, Doc_Type, ftp_name) # if Status == "Active": # action = "do_nothing" # break # if Status == "Disabled": # action = "do_nothing" # check exxtentions # self.so.click_element_by_xpath(checkbox) break if flag == False: # capability not available # click on # self.add_existing_capability(capability_name, capability_ID, Doc_Type) break i += 1 return added_cap_UID def Check_Capability_Status(self,capability_name,capability_ID,Doc_Type,arr_maps,ftp_name): time.sleep(4) i=0 action='' while True: Datatype_Name="//span[@id='form1:table1:0:table2:"+str(i)+":outputText14']" flag=self.so.check_exists_by_xpath(Datatype_Name) if flag==True: name_from_UI=self.so.get_text_by_xpath(Datatype_Name) if name_from_UI==capability_name: status="//span[@id='form1:table1:0:table2:"+str(i)+":outputText13']" checkbox="//input[@id='form1:table1:0:table2:"+str(i)+":tableSelectMany1'] " Extentions="//a[@id='form1:table1:0:table2:"+str(i)+":extensionPopup']" checkbox="//input[@id='form1:table1:0:table2:"+str(i)+":tableSelectMany1'] " Status=self.so.get_text_by_xpath(status) print(name_from_UI) print(Status) if Status=="Active": action="do_nothing" break if Status=="Disabled": action = "do_nothing" #check exxtentions # self.so.click_element_by_xpath(checkbox) break if flag==False: #capability not available #click on filebroker_required_or_not=self.add_existing_capability(capability_name,capability_ID,Doc_Type) self.Toggle_profile_capability(capability_name) self.Add_Extentions(capability_name,arr_maps,Doc_Type,ftp_name) if filebroker_required_or_not=="filebroker_required": self.filebroker(capability_name, Doc_Type, ftp_name) break i += 1
def check_extensions(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", "Check for the map extensions") 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) 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() select_supplier_profile = so.click_element_by_xpath( CommonLocators.Supplier_Profile_Link) # 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]' flag = 0 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 and doc_tpe == v_document_type: V_configure_extensions_xpath = '//*[@id="form1:table1:0:table2:' + str( counter - 2) + ':extensionPopup"]' so.click_element_by_xpath(V_configure_extensions_xpath) 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) extension_counter = 2 click_show_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( extension_counter) + ']/td[1]/div/a[2]' extension_counter1 = 0 map_extension_list = list() while (so.check_exists_by_xpath(click_show_path)): so.click_element_by_xpath( '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(extension_counter) + ']/td[1]/div/a[2]') time.sleep(1) map_text = self.v_driver.find_element_by_name( 'form1:table1:' + str(extension_counter1) + ':table2:0:outputText22') map_values = map_text.get_attribute('value') map_extension_list.append(map_values) print(map_extension_list) extension_counter = extension_counter + 2 extension_counter1 = extension_counter1 + 1 click_show_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( extension_counter) + ']/td[1]/div/a[2]' map_extension_list_str = ('\n').join(map_extension_list) supplier_map_version = self.v_data_sheet.cell(row=current_row, column=9).value retailer_map_version = self.v_data_sheet.cell(row=current_row, column=10).value msg_1 = "Please press Yes if the maps are correct. Select No if the maps are incorrect \n\n " + "\n" + "Supplier Version:" + supplier_map_version + "\n" + "Retailer Version:" + retailer_map_version + "\n\n" + map_extension_list_str if msg_1 is not None: title = "Please Confirm" if boolbox(msg_1, title): # show a Continue/Cancel dialog pass # user chose Yes else: # user chose No flag = 1 break else: pass counter = counter + 1 # map_extension_list.clear() path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' close_extension_tab = so.click_element_by_xpath( CommonLocators.extensions_cancel_button) self.v_driver.switch_to.window(self.v_driver.window_handles[0]) return flag
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 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 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 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 search_retailer_map(self, document, retailer_profile_name, supplier_profile_name, supplier_name): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) input_text = '//*[@id="form1:inputText1"]' so.send_text_by_xpath(input_text, supplier_name) so.click_element_by_xpath('//*[@id="form1:commandButton1"]') profile_flag = 0 row_index = 2 while (profile_flag == 0): V_retailer_relationship_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( row_index) + ']/td[6]' if so.check_exists_by_xpath(V_retailer_relationship_profile_path): V_relationship_retailer_profile_name = so.get_text_by_xpath( V_retailer_relationship_profile_path) self.lo.log_to_file("INFO", "Relationship found at retailer side") if V_relationship_retailer_profile_name == supplier_profile_name: V_relationship_retailer_profile_path = '// *[ @ id = "form1:table1:' + str( row_index - 2) + ':commandLink3"]' #so.click_element_by_xpath(V_relationship_retailer_profile_path) if so.check_exists_by_xpath( V_relationship_retailer_profile_path): so.click_element_by_xpath( V_relationship_retailer_profile_path) self.lo.log_to_file("INFO", "In retailer profile") V_retailer_profile_show_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[2]/td[2]/div/a[2]' if so.check_exists_by_xpath( V_retailer_profile_show_path): so.click_element_by_xpath( '//*[@id="form1:table1"]/table[2]/tbody/tr[2]/td[2]/div/a[2]' ) map_flag = 0 map_row_index = 2 while (map_flag == 0): V_retailer_doc_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index) + ']/td[3]' if so.check_exists_by_xpath( V_retailer_doc_path): V_retailer_document = so.get_text_by_xpath( V_retailer_doc_path) if V_retailer_document == document: self.lo.log_to_file( "INFO", V_retailer_document) print("Retailer Document = " + V_retailer_document) self.lo.log_to_file( "INFO", "Doc Found") V_retailer_doc_status_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index) + ']/td[9]' if so.check_exists_by_xpath( V_retailer_doc_status_path): V_reatiler_doc_status = so.get_text_by_xpath( V_retailer_doc_status_path) if V_reatiler_doc_status == 'Active': self.lo.log_to_file( "INFO", "Status is Active") print( "Retailer Dcoument Status = " + V_reatiler_doc_status) V_retailer_doc_service_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index) + ']/td[10]' if so.check_exists_by_xpath( V_retailer_doc_service_path ): V_reatiler_doc_service = so.get_text_by_xpath( V_retailer_doc_service_path ) if V_reatiler_doc_service == 'CommerceEDIfromService' or V_reatiler_doc_service == 'CommerceEDItoService' or V_reatiler_doc_service == 'B2BfromService' or V_reatiler_doc_service == 'B2BtoService': self.lo.log_to_file( "INFO", "Services are correct" ) print( "Retailer doc service = " + V_reatiler_doc_service ) if (document == '850'): V_retailer_doc_version_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index ) + ']/td[8]' if so.check_exists_by_xpath( V_retailer_doc_version_path ): V_retailer_doc_version = so.get_text_by_xpath( V_retailer_doc_version_path ) self.lo.log_to_file( "INFO", "Retailer version found" ) print( "Retailer map version for 850 = " + V_retailer_doc_version ) so.click_element_by_xpath( '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a' ) input_text = '//*[@id="form1:inputText1"]' so.send_text_by_xpath( input_text, supplier_name ) so.click_element_by_xpath( '//*[@id="form1:commandButton1"]' ) supp_row_index = row_index - 2 V_relationship_supplier_name_path = '//*[@id="form1:table1:' + str( supp_row_index ) + ':commandLink2"]' so.click_element_by_xpath( V_relationship_supplier_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' ) return V_retailer_document, V_reatiler_doc_status, V_reatiler_doc_service, V_retailer_doc_version else: self.lo.log_to_file( "INFO", "Versions not present" ) return False else: V_retailer_doc_version_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index ) + ']/td[7]' if so.check_exists_by_xpath( V_retailer_doc_version_path ): V_retailer_doc_version = so.get_text_by_xpath( V_retailer_doc_version_path ) self.lo.log_to_file( "INFO", "Retailer version found" ) print( "Retailer map version for" + document + " = " + V_retailer_doc_version ) supp_row_index = row_index - 2 V_relationship_supplier_name_path = '//*[@id="form1:table1:' + str( supp_row_index ) + ':commandLink2"]' so.click_element_by_xpath( V_relationship_supplier_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' ) return V_retailer_document, V_reatiler_doc_status, V_reatiler_doc_service, V_retailer_doc_version else: self.lo.log_to_file( "INFO", "Versions not present" ) return False map_flag = 1 else: map_row_index = map_row_index + 1 else: self.lo.log_to_file( "INFO", "No services present in retailer profile" ) return False else: map_row_index = map_row_index + 1 else: return False else: map_row_index = map_row_index + 1 else: self.lo.log_to_file( "INFO", "No documents present in retailer profile" ) map_flag = 1 return False else: return False else: return False profile_flag = 1 else: row_index = row_index + 1 else: return false
def add_capbility(self, v_doc, profie_name, row_index): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) v_add_capability_path = '//*[@id="form1:table1:0:table2:addExistingCapability"]' print(self.v_driver.current_window_handle) if so.check_exists_by_xpath(v_add_capability_path): so.click_element_by_xpath(v_add_capability_path) 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) time.sleep(1) self.lo.log_to_file("INFO", "Adding capability") v_search_existing_path = '//*[@id="form1:showDetailHeader1__xc_"]' if so.check_exists_by_xpath(v_search_existing_path): so.click_element_by_xpath(v_search_existing_path) so.send_text_by_xpath('//*[@id="form1:inputText3"]', 'FItoService') so.send_text_by_xpath('//*[@id="form1:inputText5"]', '850') self.show_all('//*[@id="form1:showOneChoice2"]', '0') self.lo.log_to_file("INFO", "Data sent") so.click_element_by_xpath('//*[@id="form1:commandButton2"]') self.lo.log_to_file("INFO", "Clicked on search") capability_row_index = 0 capability_flag = 0 capability_2013 = 'Standard NetSuite Sales Order RSX Order v7.4 Governance (LEGACY SIP)' capability_2015 = 'Standard NetSuite Sales Order RSX Order v7.4 Governance (LEGACY SIP) | v3' capability_2017_1 = 'Standard NetSuite Sales Order RSX Order v7.7 Governance_v1' capability_2017 = 'Standard NetSuite Sales Order RSX Order v7.4 (2017)' while (capability_flag == 0): self.lo.log_to_file("INFO", "Inside while") v_choose_capbability_path = '// *[ @ id = "form1:table1:' + str( capability_row_index) + ':outputText6"]' if so.check_exists_by_xpath(v_choose_capbability_path): self.lo.log_to_file("INFO", "Inside If1") v_capability_name = so.get_text_by_xpath( v_choose_capbability_path) print(v_capability_name) if (v_capability_name == capability_2013 or v_capability_name == capability_2015 or v_capability_name == capability_2017 or v_capability_name == capability_2017_1): self.lo.log_to_file("INFO", "Inside If2") so.click_element_by_xpath( '//*[@id="form1:table1:' + str(capability_row_index) + ':tableSelectMany1"]') self.lo.log_to_file("INFO", "Tick checkbox") so.click_element_by_xpath( '//*[@id="form1:table1:commandButton1"]') self.lo.log_to_file("INFO", "Click choose") capability_flag = 1 capability_row_index = capability_row_index + 1 self.lo.log_to_file("INFO", "Row++") doc_flag = 0 map_row_index = 2 while (doc_flag == 0): v_supplier_profile_doc_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index) + ']/td[3]' if so.check_exists_by_xpath( v_supplier_profile_doc_path): v_supplier_profile_doc = so.get_text_by_xpath( v_supplier_profile_doc_path) if v_supplier_profile_doc == v_doc: v_supplier_doc_status_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index) + ']/td[9]' if so.check_exists_by_xpath( v_supplier_doc_status_path): v_supplier_doc_status = so.get_text_by_xpath( v_supplier_doc_status_path) if v_supplier_doc_status == 'Active': v_supplier_doc_service_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index) + ']/td[10]' if so.check_exists_by_xpath( v_supplier_doc_service_path ): v_supplier_doc_service = so.get_text_by_xpath( v_supplier_doc_service_path ) if v_supplier_doc_service == 'FItoService': self.lo.log_to_file( "INFO", "Doc found, status is active, service is correct" ) v_supplier_profile_map_version = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index ) + ']/td[6]' if so.check_exists_by_xpath( v_supplier_profile_map_version ): v_supplier_profile_map_version_display = so.get_text_by_xpath( v_supplier_profile_map_version ) v_supplier_profile_map_name = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( map_row_index ) + ']/td[4]' if so.check_exists_by_xpath( v_supplier_profile_map_name ): v_supplier_profile_map_name_display = so.get_text_by_xpath( v_supplier_profile_map_name ) else: return False else: return False return map_row_index doc_flag = 1 else: map_row_index = map_row_index + 1 print( 'Service not FItoService' ) else: self.lo.log_to_file( "INFO", "No services present in supplier profile" ) return False else: map_row_index = map_row_index + 1 else: return False else: map_row_index = map_row_index + 1 else: self.lo.log_to_file("INFO", "Inside else2") capability_row_index = capability_row_index + 1 return False else: return False