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 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 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 validate_existing_trading_partnership(self, error_title, doc_type_list): selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) supplier_web_id = '' retailer_web_id = '' for v_index in range(0, len(doc_type_list)): temp_doc = doc_type_list[v_index] i = 2 while (1): form_path = '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( i) + ']/td[9]' status_path = '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( i) + ']/td[12]' if selenium_operation_object.check_exists_by_xpath(form_path): if temp_doc == selenium_operation_object.get_text_by_xpath( form_path): if temp_doc == '810' or temp_doc == '846' or temp_doc == '855' or temp_doc == '856' or temp_doc == '940': supplier_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[5]') retailer_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[7]') else: supplier_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[7]') retailer_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[5]') if selenium_operation_object.get_text_by_xpath( status_path) == 'true': del doc_type_list[v_index] break #Find supplier and retailer web company uid if temp_doc == '810' or temp_doc == '846' or temp_doc == '855' or temp_doc == '856' or temp_doc == '940': supplier_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[5]') retailer_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[7]') else: supplier_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[7]') retailer_web_id = selenium_operation_object.get_text_by_xpath( '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(i) + ']/td[5]') else: break i = i + 1 return doc_type_list, supplier_web_id, retailer_web_id
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 get_receiver_name(self, index): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) #receiver_path = '//*[@id="form1:table1:' + str(index) + ':outputText17"]' receiver_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( index) + ']/td[7]' if so.check_exists_by_xpath(receiver_path): return so.get_text_by_xpath(receiver_path) else: return False
def get_receiver_name(self, v_index): selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) v_receiver_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( v_index) + ']/td[7]' if selenium_operation_object.check_exists_by_xpath(v_receiver_path): return selenium_operation_object.get_text_by_xpath(v_receiver_path) else: return False
def get_ticket_uid(self, index): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) #ticket_uid_path = '//*[@id="form1:table1:'+str(index)+':commandLink1"]' ticket_uid_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( index) + ']/td[3]' if so.check_exists_by_xpath(ticket_uid_path): return so.get_text_by_xpath(ticket_uid_path) else: return False
def get_unique_doc_types(self, v_doc_type): list_doc_type = [] list_doc_type.append(v_doc_type) selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) v_index = 2 while (1): v_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str( v_index) + ']/td[8]/text()[1]' if selenium_operation_object.check_exists_by_xpath(v_path): if v_doc_type != selenium_operation_object.get_text_by_xpath( v_path): list_doc_type.append( selenium_operation_object.get_text_by_xpath(v_path)) else: break v_index = v_index + 1 return list_doc_type
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
class Salesforce: 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.log = lo self.v_username = username self.v_Browser = v_Browser self.so = SeleniumOperations(self.v_task_type, self.v_Browser, self.log) 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 open_FS_Team_Queue(self): print("open_FS_Team_Queue") time.sleep(5) self.v_Browser.get("https://spscommerce.my.salesforce.com/") time.sleep(5) self.v_Browser.get("https://spscommerce.my.salesforce.com/") self.v_Browser.get(ElementLocators.QUEUE_URL) time.sleep(7) if self.so.check_exists_by_xpath( ElementLocators.CROSS_SWITCH_BOX) == True: self.so.click_element_by_xpath(ElementLocators.CROSS_SWITCH_BOX) self.v_Browser.get(ElementLocators.QUEUE_URL) time.sleep(2) self.so.click_element_by_xpath(ElementLocators.QUEUE_LIST) self.so.click_element_by_xpath(ElementLocators.FS_TEAM_QUEUE) if self.so.check_exists_by_xpath(ElementLocators.GO_BTN) == True: self.so.click_element_by_xpath(ElementLocators.GO_BTN) def get_all_ticket_info(self): print("get_all_ticket_info") all_tickets = self.v_Browser.find_elements_by_xpath( ElementLocators.ALL_CASES) Case_number_and_salesforce_id_array = [] for ii in all_tickets: # get salceforce ID try: Salesforce_ID = ii.get_attribute("id").split("_")[0] Case_number = ii.text Case_number_and_salesforce_id_array.append(Case_number + "_" + Salesforce_ID) # self.open_case_in_new_tab(Salesforce_ID) except: print("error occured in getting Salesforce_ID") return Case_number_and_salesforce_id_array def return_caseno_and_salesforceno(self, i, Case_number_and_salesforce_id_array): Case_number = Case_number_and_salesforce_id_array[i].split("_")[0] salesforce_id = Case_number_and_salesforce_id_array[i].split("_")[1] return Case_number, salesforce_id def open_cases_and_get_info(self, Case_number_and_salesforce_id_array): print("open_cases_and_get_info") # j=0 # print(Case_number_and_salesforce_id_array) for i in range(len(Case_number_and_salesforce_id_array)): print("i value") print(i) data = self.return_caseno_and_salesforceno( i, Case_number_and_salesforce_id_array) # print(Case_number_and_salesforce_id_array) Case_number = data[0] salesforce_id = data[1] print("==========================================") print(Case_number) print(salesforce_id) print("==========================================") # time.sleep(5) print(Case_number_and_salesforce_id_array) # salesforce_id_array_task=Case_number_and_salesforce_id_array[i] # print(i) # print(salesforce_id) self.v_Browser.get("https://spscommerce.my.salesforce.com/" + str(salesforce_id)) time.sleep(1) subject = self.v_Browser.find_element_by_xpath( ".//*[contains(@id,'Subject')]").get_attribute( "value").lower() # subject=self.so.get_text_by_xpath(".//*[contains(@id,'Subject')]").lower() # print(subject) # if "document processing error" in subject: # findings="Document Processing Error" # elif "document error" in subject: # findings = "Document Processing Error for document error" # elif "processing error" in subject: # findings = "Document Processing Error for processing error" # else: # findings="Unknown Error" mail_count = len( self.v_Browser.find_elements_by_xpath( ".//*[contains(@class,'feeditemaux cxfeeditemaux EmailMessageAuxBody')]" )) all_mails = self.v_Browser.find_elements_by_xpath( ".//*[contains(@class,'feeditemaux cxfeeditemaux EmailMessageAuxBody')]" ) # Case_number_and_salesforce_id_array = [] mail1 = " " mail2 = " " mail3 = " " mail4 = " " mail5 = " " mail6 = " " mail7 = " " mail8 = " " mail9 = " " mail10 = " " mail11 = " " mail12 = " " mail13 = " " mail14 = " " mail15 = " " mail16 = " " mail17 = " " mail18 = " " mail19 = " " mail20 = " " mail21 = " " mail22 = " " mail23 = " " mail24 = " " mail25 = " " k = 0 for ii in all_mails: k = k + 1 mail_text = ii.text if k == 1: mail1 = mail_text elif k == 2: mail2 = mail_text elif k == 3: mail3 = mail_text elif k == 4: mail4 = mail_text elif k == 5: mail5 = mail_text elif k == 6: mail6 = mail_text elif k == 7: mail7 = mail_text elif k == 8: mail8 = mail_text elif k == 9: mail9 = mail_text elif k == 10: mail10 = mail_text elif k == 11: mail11 = mail_text elif k == 12: mail12 = mail_text elif k == 13: mail13 = mail_text elif k == 14: mail14 = mail_text elif k == 15: mail15 = mail_text elif k == 16: mail16 = mail_text elif k == 17: mail17 = mail_text elif k == 18: mail18 = mail_text elif k == 19: mail19 = mail_text elif k == 20: mail20 = mail_text elif k == 21: mail21 = mail_text elif k == 22: mail22 = mail_text elif k == 23: mail23 = mail_text elif k == 24: mail24 = mail_text elif k == 25: mail25 = mail_text self.save_findings_in_excel(i, Case_number, salesforce_id, "findings", subject, mail1, mail2, mail3, mail4, mail5) def save_findings_in_excel(self, i, Case_number, salesforce_id, findings, subject, mail1=None, mail2=None, mail3=None, mail4=None, mail5=None, mail6=None, mail7=None, mail8=None, mail9=None, mail10=None, mail11=None, mail12=None, mail13=None, mail14=None, mail15=None, mail16=None, mail17=None, mail18=None, mail19=None, mail20=None, mail21=None, mail22=None, mail23=None, mail24=None, mail25=None): row_value = i + 2 self.v_input_sheet.cell(row=row_value, column=1).value = Case_number self.v_input_sheet.cell(row=row_value, column=2).value = salesforce_id self.v_input_sheet.cell(row=row_value, column=3).value = findings self.v_input_sheet.cell(row=row_value, column=4).value = subject self.v_input_sheet.cell(row=row_value, column=5).value = mail1 self.v_input_sheet.cell(row=row_value, column=6).value = mail2 self.v_input_sheet.cell(row=row_value, column=7).value = mail3 self.v_input_sheet.cell(row=row_value, column=8).value = mail4 self.v_input_sheet.cell(row=row_value, column=9).value = mail5 self.v_input_sheet.cell(row=row_value, column=10).value = mail6 self.v_input_sheet.cell(row=row_value, column=9).value = mail7 self.v_input_sheet.cell(row=row_value, column=9).value = mail8 self.v_input_sheet.cell(row=row_value, column=9).value = mail9 self.v_input_sheet.cell(row=row_value, column=9).value = mail10 self.v_input_sheet.cell(row=row_value, column=9).value = mail11 self.v_input_sheet.cell(row=row_value, column=9).value = mail12 self.v_input_sheet.cell(row=row_value, column=9).value = mail13 self.v_input_sheet.cell(row=row_value, column=9).value = mail14 self.v_input_sheet.cell(row=row_value, column=9).value = mail15 self.v_input_sheet.cell(row=row_value, column=9).value = mail16 self.v_input_sheet.cell(row=row_value, column=9).value = mail17 self.v_input_sheet.cell(row=row_value, column=9).value = mail18 self.v_input_sheet.cell(row=row_value, column=9).value = mail19 self.v_input_sheet.cell(row=row_value, column=9).value = mail20 self.v_input_sheet.cell(row=row_value, column=9).value = mail21 self.v_input_sheet.cell(row=row_value, column=9).value = mail22 self.v_input_sheet.cell(row=row_value, column=9).value = mail23 self.v_input_sheet.cell(row=row_value, column=9).value = mail24 self.v_input_sheet.cell(row=row_value, column=9).value = mail25 self.v_input_wb.save(ElementLocators.INPUT_FILE_PATH)
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
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 execute_main(self): v_start_time = time.time() self.lo.log_to_file("INFO", "Login in to DC4 Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type,self.v_driver,self.lo) ehu = ErrorHospital_Utility(self.v_task_type,self.v_driver,self.lo) rf = ReportFileUtility(self.v_task_type) output_sheet = self.v_input_wb.get_sheet_by_name('Output') input_sheet = self.v_input_wb.get_sheet_by_name('Input') eo = ExcelOperations(self.v_task_type, input_sheet) output_sheet_eo = ExcelOperations(self.v_task_type, output_sheet) output_sheet_curr_row = 2 for index in range(2,input_sheet.max_row+1): list_duplicate_ticket_uid = [] today = datetime.datetime.now() DD = datetime.timedelta(days=14) earlier = today - DD earlier_str = earlier.strftime("%Y-%m-%d") earlier_str = earlier_str+' 00:00:00' lg.login("DC4 Prod") v_error_title = eo.get_value(index, 1) if v_error_title == LocalElementLocator.ADHOC_ERROR_TITLE: v_ticket_uid = eo.get_value(index, 2) if v_ticket_uid is None: v_ticket_uid = ' ' ehu.adhoc_error_search(v_ticket_uid,earlier_str,' ') if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) tuid_index = 2 while(ehu.get_ticket_uid(tuid_index)): temp_ticket_uid = ehu.get_ticket_uid(tuid_index) temp_receiver = ehu.get_receiver_name(tuid_index) temp_sender = ehu.get_sender_name(tuid_index) if temp_ticket_uid not in list_duplicate_ticket_uid: ehu.adhoc_error_search(temp_ticket_uid,earlier_str,' ') v_tpid, v_doctype = ehu.get_info_from_description(tuid_index-2) ehu.adhoc_error_search(' ', earlier_str,v_tpid) if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) temp_tuid_index = 2 while (ehu.get_ticket_uid(temp_tuid_index)): list_duplicate_ticket_uid.append(ehu.get_ticket_uid(temp_tuid_index)) temp_tuid_index = temp_tuid_index+1 output_sheet_eo.set_value(output_sheet_curr_row, 1, temp_ticket_uid) output_sheet_eo.set_value(output_sheet_curr_row, 2, temp_sender) output_sheet_eo.set_value(output_sheet_curr_row, 3, temp_receiver) output_sheet_eo.set_value(output_sheet_curr_row, 4, v_tpid) output_sheet_eo.set_value(output_sheet_curr_row, 5, v_doctype) output_sheet_curr_row = output_sheet_curr_row+1 self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) ehu.adhoc_error_search(v_ticket_uid, earlier_str, ' ') if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) tuid_index = tuid_index+1 #so.click_element(AppConstants.DC4_TAB, "BY_NAME") #dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo) #dc.company_search_by_name('Midlab Inc') #dc.company_search_by_ISA_ID('6166651648') #dc.company_search_by_TPID('620TSTWONDERTRE') self.v_driver.close() v_end_time = time.time() rf.update_sheet(self.v_username, 2, math.floor(v_end_time - v_start_time), str(datetime.date.today()))
def 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 check_supplier_profile(self, profie_name, v_doc, row_index): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) self.show_all('//*[@id="form1:table1-nb__xc_c"]', 'all') 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_supplier_profile_path = '//*[@id="form1:table1:' + str( row_index - 2) + ':commandLink3"]' so.click_element_by_xpath(v_supplier_profile_path) self.lo.log_to_file("INFO", "In supplier profile") so.click_element_by_xpath( '//*[@id="form1:table1"]/table[2]/tbody/tr[2]/td[2]/div/a[2]') #print('Click on show') doc_flag = 0 map_row_index = 2 #print(doc_flag) while (doc_flag == 0): #print('Entry in while') 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 v_supplier_profile_map_version_display, v_supplier_profile_map_name_display, 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", "No docs added") doc_flag = 1 V_new_map_row_index = self.add_capbility( v_doc, profie_name, row_index) return v_supplier_profile_map_version_display, v_supplier_profile_map_name_display, V_new_map_row_index profile_flag = 1 else: print('Relationship not found') return False
def add_extensions(self, retailer_map_version, supplier_map_version, supplier_map_row_index): so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) V_configure_extensions_xpath = '//*[@id="form1:table1:0:table2:' + str( supplier_map_row_index) + ':extensionPopup"]' #print(self.v_driver.current_window_handle) if so.check_exists_by_xpath(V_configure_extensions_xpath): so.click_element_by_xpath(V_configure_extensions_xpath) time.sleep(1) self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) time.sleep(1) self.v_driver.switch_to.frame(0) self.lo.log_to_file("INFO", "Adding extension") if (retailer_map_version != supplier_map_version): self.lo.log_to_file("INFO", "Adding Map extension") v_position = -1 while (retailer_map_version != supplier_map_version): if retailer_map_version == '7.0': v_position = v_position + 1 self.adding_map_extension(LocalElementLocator.PO02, str(v_position)) retailer_map_version = '7.2' print('Map Extensions added from 7.0 to 7.2') self.lo.log_to_file( "INFO", "Map Extensions added from 7.0 to 7.2") elif retailer_map_version == '7.2': v_position = v_position + 1 self.adding_map_extension(LocalElementLocator.PO24, str(v_position)) retailer_map_version = '7.4' print('Map Extensions added from 7.2 to 7.4') self.lo.log_to_file( "INFO", "Map Extensions added from 7.2 to 7.4") elif retailer_map_version == '7.5': v_position = v_position + 1 self.adding_map_extension(LocalElementLocator.PO54, str(v_position)) retailer_map_version = '7.4' print('Map Extensions added from 7.5 to 7.4') self.lo.log_to_file( "INFO", "Map Extensions added from 7.5 to 7.4") elif retailer_map_version == '7.6': v_position = v_position + 1 self.adding_map_extension(LocalElementLocator.PO65, str(v_position)) retailer_map_version = '7.5' print('Map Extensions added from 7.6 to 7.5') self.lo.log_to_file( "INFO", "Map Extensions added from 7.6 to 7.5") elif retailer_map_version == '7.7': v_position = v_position + 1 self.adding_map_extension(LocalElementLocator.PO76, str(v_position)) retailer_map_version = '7.6' print('Map Extensions added from 7.7 to 7.6') self.lo.log_to_file( "INFO", "Map Extensions added from 7.7 to 7.6") if (retailer_map_version == supplier_map_version): so.click_element_by_xpath('//*[@id="form1:commandButton2"]') self.lo.log_to_file("INFO", "Saving Extension") time.sleep(1) else: self.lo.log_to_file("INFO", "Incorrect path for configure extensions") return False self.v_driver.switch_to.window(self.v_driver.window_handles[0])
def add_trading_partnership(self, v_error_tiltle, v_TPID, doc_type_list, sender, receiver, v_status): selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) v_present = 0 supplier_web_id = '' retailer_web_id = '' selenium_operation_object.click_element_by_id( LocalElementLocator.DC4_WEBFORM_TAB_ID) selenium_operation_object.click_element_by_xpath( LocalElementLocator.DC4_SEARCH_TRADING_PARTNERSHIP_LINK_XPATH) selenium_operation_object.send_text_by_id( LocalElementLocator.DC4_EVISION_KEY_ID, v_TPID) selenium_operation_object.click_element_by_id( LocalElementLocator.DC4_TRADING_PARTNERSHIP_SEARCH_BUTTON_ID) #Check for existing trading partnership if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.DC4_FIRST_TRADING_PARTNERSHIP_XPATH): v_present = 1 doc_type_list, supplier_web_id, retailer_web_id = self.validate_existing_trading_partnership( v_error_tiltle, doc_type_list) if len(doc_type_list) == 0: v_status = v_status + 'Trading Partnership is already v_present' selenium_operation_object.click_element_by_id( LocalElementLocator.ERROR_HOSPITAL_TAB_ID2) flag = 1 return v_status, flag if LocalElementLocator.ADHOC_ERROR_TITLE == v_error_tiltle: #Determine supplier and retailer sender, receiver = self.check_supplier_retailer( sender, receiver, doc_type_list[0]) #If Valid Trading Partnership is not present if len(doc_type_list) != 0: if supplier_web_id == '': if v_present == 1: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_CREATE_TRADING_PARTNERSHIP_BUTTON1) else: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_CREATE_TRADING_PARTNERSHIP_BUTTON2) selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SENDER_TORCH) v_status, flag = self.add_web_company(sender, v_status) if flag == 0 or flag == 2: selenium_operation_object.click_element_by_xpath( LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH) return v_status, flag selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TORCH) v_status, flag = self.add_web_company(receiver, v_status) if flag == 0 or flag == 2: selenium_operation_object.click_element_by_xpath( LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH) return v_status, flag if flag == 1: supp_web_id = self.v_driver.find_element_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID ).get_attribute('value') ret_web_id = self.v_driver.find_element_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID ).get_attribute('value') self.error_hospital_machine_learning_object.add_to_library( sender, supp_web_id) self.error_hospital_machine_learning_object.add_to_library( receiver, ret_web_id) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_EVISION_KEY_ID, v_TPID) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_FORM_NUMBER_ID, (', ').join(doc_type_list)) if LocalElementLocator.ADHOC_ERROR_TITLE == v_error_tiltle: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ZERO) else: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ONE) selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_CREATE_BUTTON) selenium_operation_object.click_element_by_xpath( LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH) v_status = v_status + '\nAdded web trading partnership' return v_status, 1 else: selenium_operation_object.click_element_by_xpath( LocalElementLocator.DC4_CREATE_TRADING_PARTNERSHIP_BUTTON1) if v_error_tiltle == LocalElementLocator.ADHOC_ERROR_TITLE: selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID, retailer_web_id) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID, supplier_web_id) else: if doc_type_list[0] == '810' or doc_type_list[ 0] == '846' or doc_type_list[ 0] == '855' or doc_type_list[ 0] == '856' or doc_type_list[0] == '940': selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID, supplier_web_id) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID, retailer_web_id) else: selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID, retailer_web_id) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID, supplier_web_id) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_EVISION_KEY_ID, v_TPID) selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_FORM_NUMBER_ID, (', ').join(doc_type_list)) if LocalElementLocator.ADHOC_ERROR_TITLE == v_error_tiltle: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ZERO) else: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ONE) selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_CREATE_BUTTON) selenium_operation_object.click_element_by_xpath( LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH) v_status = v_status + '\nAdded web trading partnership' return v_status, 1
def add_web_company(self, sender, v_status): flag = 0 selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) time.sleep(2) default_handle = self.v_driver.current_window_handle self.v_driver.switch_to.window(self.v_driver.window_handles[-1]) time.sleep(2) self.v_driver.switch_to.frame(0) time.sleep(2) #Check in library for web company uid web_uid = self.error_hospital_machine_learning_object.get_supplier_info( sender) if web_uid != False: selenium_operation_object.send_text_by_id( LocalElementLocator.DC4_ADD_TRADING_PARTNERSHIP_COMPANYUID_ID, web_uid) selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON) time.sleep(3) if selenium_operation_object.check_exists_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY): selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON) flag = 1 v_status = v_status + '\nFound web company from previous results' self.v_driver.switch_to.window(self.v_driver.window_handles[0]) time.sleep(2) return v_status, flag selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_ID, sender) selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON) time.sleep(2) if selenium_operation_object.check_exists_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY): i = 2 web_id = ' ' path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str( i) + ']/td[2]' while (1): if selenium_operation_object.check_exists_by_xpath(path): temp_web_id = selenium_operation_object.get_text_by_xpath( path) if temp_web_id != web_id and flag == 0: web_id = temp_web_id flag = 1 elif temp_web_id != web_id: flag = 2 break else: break i = i + 1 path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str( i) + ']/td[2]' if flag == 2: v_status = v_status + '\nMultiple web companies' else: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON) else: sender = '%' + sender.replace(' ', '%') + '%' selenium_operation_object.send_text_by_id( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_ID, sender) selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON) time.sleep(2) if selenium_operation_object.check_exists_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY): i = 2 web_id = ' ' path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str( i) + ']/td[2]' while (1): if selenium_operation_object.check_exists_by_xpath(path): temp_web_id = selenium_operation_object.get_text_by_xpath( path) if temp_web_id != web_id and flag == 0: web_id = temp_web_id flag = 1 elif temp_web_id != web_id: flag = 2 break else: break i = i + 1 path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str( i) + ']/td[2]' if flag == 2: v_status = v_status + '\nMultiple web companies' else: selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON) else: v_status = v_status + "No web company found" if flag == 0 or flag == 2: if easygui.ynbox( "Deadpool is unable to find web company. Do you want to add it manually?\n\nNote:- Add correct web comapany manually then select 'Yes' else 'No'" ): flag = 1 selenium_operation_object.click_element_by_xpath( LocalElementLocator. DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON) else: handles = list(self.v_driver.window_handles) handles.remove(default_handle) self.v_driver.close() time.sleep(2) self.v_driver.switch_to.window(default_handle) if flag == 1: self.v_driver.switch_to.window(self.v_driver.window_handles[0]) time.sleep(2) return v_status, flag
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_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 retailer_setup_check(self, v_supplier, v_retailer, v_document_type, current_row): v_document_type_1 = str(v_document_type) v_document_type_2 = '875' self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) eo = ExcelOperations(self.v_task_type, self.v_data_sheet) self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod") lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo) so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo) so.click_element_by_xpath(AppConstants.DC4_TAB) dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo) self.v_driver.find_element_by_xpath( AppConstants.DC4_COMPANY_NAME_TEXT_FIELD).send_keys(v_retailer) self.v_driver.find_element_by_xpath( AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK).click() select_retailer = self.v_driver.find_element_by_xpath( CommonLocators.Company_Select_Link).click() # Check the retationship click_relationship = so.click_element_by_xpath( CommonLocators.Relationship_Tab) search_retailer_relationship = so.send_text_by_xpath( CommonLocators.Trading_Partner_Name_text_Field, v_supplier) so.click_element_by_xpath(CommonLocators.click_search) # Select the Retailer company profile and check for the FI setup select_retailer_profile = so.click_element_by_xpath( CommonLocators.Supplier_Profile_Link) # Profile Page Display show_option_click = so.click_element_by_xpath( CommonLocators.show_click) counter = 2 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' while (so.check_exists_by_xpath(path)): service = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[10]') doc_tpe = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[3]') print(doc_tpe) if doc_tpe == v_document_type_1: if service != 'DoNotRoute': print("850 capability is available") retailer_version = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[8]') eo.set_value(current_row, 10, retailer_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) break elif service == 'DoNotRoute': print("850 capability is not available") elif doc_tpe == v_document_type_2: if service != 'DoNotRoute': print("875 capability is present") retailer_version = so.get_text_by_xpath( '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(counter) + ']/td[8]') eo.set_value(current_row, 10, retailer_version) self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) break elif service == 'DoNotRoute': print("875 capability is present") counter = counter + 1 path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str( counter) + ']/td[10]' time.sleep(10)
def execute_main(self, v_error_title, v_ticket_uid, output_sheet, earlier_str): v_count = 0 selenium_operation_object = SeleniumOperations(self.v_task_type, self.v_driver, self.log_file_object) list_duplicate_ticket_uid = [] output_sheet_excel_operation_object = ExcelOperations( self.v_task_type, output_sheet) v_output_sheet_curr_row = 2 error_hospital_utility_object = ErrorHospital_Utility( self.v_task_type, self.v_driver, self.log_file_object, self.error_hospital_machine_learning_object) #Search for error tickets error_hospital_utility_object.document_rejected_error_search( v_ticket_uid, earlier_str, ' ', v_error_title, ' ') if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): selenium_operation_object.click_element_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) v_tuid_index = 2 while (error_hospital_utility_object.get_ticket_uid(v_tuid_index)): v_temp_ticket_uid = error_hospital_utility_object.get_ticket_uid( v_tuid_index) v_temp_receiver = error_hospital_utility_object.get_receiver_name( v_tuid_index) v_temp_sender = error_hospital_utility_object.get_sender_name( v_tuid_index) #Search for new unique ticket if v_temp_ticket_uid not in list_duplicate_ticket_uid: v_count = v_count + 1 v_status = ' ' error_hospital_utility_object.document_rejected_error_search( v_temp_ticket_uid, earlier_str, ' ', v_error_title, ' ') #Get TPID and doctype v_tpid, v_doctype = error_hospital_utility_object.get_info_from_description( v_tuid_index - 2) #Search for duplicate tickets error_hospital_utility_object.document_rejected_error_search( ' ', earlier_str, v_tpid, v_error_title, v_doctype) if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): selenium_operation_object.click_element_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) v_temp_tuid_index = 2 parcel_uid_list = [] #Append all duplicate tickets to list while (error_hospital_utility_object.get_ticket_uid( v_temp_tuid_index)): list_duplicate_ticket_uid.append( error_hospital_utility_object.get_ticket_uid( v_temp_tuid_index)) parcel_uid_list.append( error_hospital_utility_object.get_parcel_uid( v_temp_tuid_index)) doc_type_list = error_hospital_utility_object.get_unique_doc_types( v_doctype) v_temp_tuid_index = v_temp_tuid_index + 1 #Add info to output sheet output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 1, v_temp_ticket_uid) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 2, v_temp_sender) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 3, v_temp_receiver) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 4, v_tpid) doc_type_string = ','.join(doc_type_list) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 5, doc_type_string) parcel_uid_string = '\n'.join(parcel_uid_list) output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 6, parcel_uid_string) #Validate TPID if len(v_tpid) == 15 and ' ' not in v_tpid: self.log_file_object.log_to_file( "INFO", "TPID: " + v_tpid + " is valid") v_status, flag = error_hospital_utility_object.add_trading_partnership( v_error_title, v_tpid, doc_type_list, v_temp_sender, v_temp_receiver, v_status) if flag == 1: first_parcel_list = [] first_parcel_list.append(parcel_uid_list[0]) error_hospital_utility_object.requeue( first_parcel_list) time.sleep(2) error_status = error_hospital_utility_object.error_status( parcel_uid_list[0], v_error_title) self.v_driver.switch_to.window( self.v_driver.window_handles[0]) time.sleep(2) if error_status == 1: if len(parcel_uid_list) > 1: first_parcel_list = parcel_uid_list[1:] error_hospital_utility_object.requeue( first_parcel_list) v_status = v_status + '\nSuccessfully passed all the parcels' output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Done') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='008000', end_color='008000', fill_type='solid') self.log_file_object.log_to_file( "INFO", "Successfully passed the failed parcels") else: output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Failed') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='FFFF0000', end_color='FFFF0000', fill_type='solid') self.log_file_object.log_to_file( "INFO", "Unsuccessfully passed the failed parcels") else: output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Push to Manual') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='FFFF0000', end_color='FFFF0000', fill_type='solid') output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 8, v_status) else: self.log_file_object.log_to_file( "INFO", "TPID: " + v_tpid + " is invalid") v_status = v_status + '\nInvalid Data, Report to implementation analyst' output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 7, 'Done') output_sheet.cell(row=v_output_sheet_curr_row, column=7).fill = PatternFill( start_color='008000', end_color='008000', fill_type='solid') output_sheet_excel_operation_object.set_value( v_output_sheet_curr_row, 8, v_status) v_output_sheet_curr_row = v_output_sheet_curr_row + 1 self.v_input_wb.save(AppConstants.INPUT_FILE_PATH) error_hospital_utility_object.document_rejected_error_search( v_ticket_uid, earlier_str, ' ', v_error_title, ' ') if selenium_operation_object.check_exists_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH): selenium_operation_object.click_element_by_xpath( LocalElementLocator.EH_SHOW_ALL_TAB_XPATH) v_tuid_index = v_tuid_index + 1 return v_count
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