Пример #1
0
    def execute_main(self):
            v_start_time = time.time()
            self.lo.log_to_file("INFO", "Login in to DC4 Pre-Prod")
            lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
            so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
            input_sheet = self.v_input_wb.get_sheet_by_name('Input')

            #HardCoded Location
            current_row = 2
            Company_Name = input_sheet.cell(row=current_row, column=1).value
            Retailer_Name=input_sheet.cell(row=current_row,column=2).value
            Capability_UID=input_sheet.cell(row=current_row,column=5).value

            #Login to DC4 Pre-Production
            lg.login("DC4 PreProd")

            #Entering & Searching DC4 Company
            dc4_common_dc4_utility_object = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
            dc4_common_dc4_utility_object.company_search_by_name(Company_Name)

            #Clicking on Searched Company Name, Relationships Tab
            dc4_local_dc4_utility_local_object=DC4_Utility_Local(self.v_task_type, self.v_driver, self.lo, self.v_input_wb)
            dc4_local_dc4_utility_local_object.click_on_searched_company_name()
            dc4_local_dc4_utility_local_object.add_new_capability()
            dc4_local_dc4_utility_local_object.return_capability_uid()
            dc4_local_dc4_utility_local_object.click_on_preprod_relationships_tab()
            dc4_local_dc4_utility_local_object.search_trading_partner_name_in_relationships(Retailer_Name)
            dc4_local_dc4_utility_local_object.click_on_profile_name_via_relationships()
            dc4_local_dc4_utility_local_object.click_on_show_link_of_searched_profile()
            dc4_local_dc4_utility_local_object.add_existing_capability()

            time.sleep(10)
Пример #2
0
 def execute_main(self):
     self.lo.log_to_file("INFO",
                         "Executing Process_Test_Files.execute_main()")
     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)
     self.v_data_sheet = self.v_input_wb.get_sheet_by_name(
         'PROCESS_TEST_FILES_INPUT')
     total_rows = self.v_data_sheet.max_row
     lg.login("Launchpad")
     self.v_driver.maximize_window()
     self.v_driver.execute_script("window.open('about:blank', 'tab2');")
     self.v_driver.switch_to.window("tab2")
     lg.login("DC4 PreProd")
     self.v_driver.execute_script("window.open('about:blank', 'tab3');")
     self.v_driver.switch_to.window("tab3")
     lg.login("FTP Pre-prod")
     for row_count in range(2, total_rows + 1):
         v_supplier = self.v_data_sheet.cell(row=row_count, column=1).value
         v_retailer = self.v_data_sheet.cell(row=row_count, column=2).value
         v_doc_type = self.v_data_sheet.cell(row=row_count, column=3).value
         v_date = self.v_data_sheet.cell(row=row_count, column=4).value
         if v_doc_type == CommonLocators.PO_File:
             ptf_850 = Process_Test_file_850(self.v_task_type, self.lo,
                                             self.v_username,
                                             self.v_input_wb, self.v_driver)
             ptf_850.execute_main(v_supplier, v_retailer, v_doc_type,
                                  row_count, v_date)
         else:
             self.lo.log_to_file(
                 "ERROR",
                 "Document is not found in Process_Test_Files.execute_main()"
             )
Пример #3
0
 def execute_main(self):
     self.lo.log_to_file(
         "INFO", "Executing ProductionDataMonitoring.execute_main()")
     self.v_driver = webdriver.Chrome(AppConstants.BROWSER_DRIVER)
     self.v_driver.maximize_window()
     lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
     lg.login("Launchpad")
     self.lo.log_to_file("INFO", "Login in to Launchpad")
     time.sleep(5)
     self.v_driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK)
     self.TaskFilter(self.v_input_wb, 'InProgress')
     self.lo.log_to_file(
         "INFO", "completed ProductionDataMonitoring.execute_main()")
     self.v_driver.close()
Пример #4
0
    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")
    def execute_main(self):
        # 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)
        self.v_data_sheet = self.v_input_wb.get_sheet_by_name('PROCESS_TEST_FILES_INPUT')

        total_rows = self.v_data_sheet.max_row
        self.v_driver.maximize_window()
        lg.login("Launchpad")
        time.sleep(3)
        self.v_driver.get("https://commerce.spscommerce.com/transaction-tracker/prod/transactions/")
        time.sleep(5)
        tto=TransactionTrackerOperations(self.v_task_type, self.v_driver, self.lo)

        # tto.search_process_for_process_test_file("Spring Silver Foods Inc","C&S Wholesale","850","10/02/2018")
        tto.search_by_parcel_id_and_download("10944250370")
 def execute_main(self):
     # self.v_driver = webdriver.Chrome(AppConstants.BROWSER_DRIVER)
     # self.v_driver.maximize_window()
     self.lo.log_to_file("INFO", "Login in to Launchpad")
     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)
     time.sleep(5)
     print("Browser opened,login,open TT")
     self.process(self.v_input_wb)
     print("Task filter completed")
 def execute_main(self):
     self.log.log_to_file(
         "INFO", "Executing CMProductionDataMonitoring.execute_main()")
     self.v_driver = webdriver.Chrome(AppConstants.BROWSER_DRIVER)
     self.v_driver.maximize_window()
     TransactionTrackerOperations_page_object = TransactionTrackerOperations(
         self.v_task_type, self.v_driver, self.log, self.v_input_sheet,
         self.v_input_wb, self.v_username, self.v_driver)
     self.log.log_to_file("INFO", "Login in to Launchpad")
     login_operations_object = Login(self.v_task_type, self.v_driver,
                                     self.v_input_wb, self.log)
     login_operations_object.login("Launchpad")
     time.sleep(5)
     self.v_driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK)
     TransactionTrackerOperations_page_object.TaskFilter_for_CM_PDM(
         self.v_input_wb, 'InProgress')
     self.log.log_to_file(
         "INFO", "completed CMProductionDataMonitoring.execute_main()")
     self.v_driver.close()
Пример #8
0
    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)
        rf = ReportFileUtility(self.v_task_type)

        lg.login("DC4 Prod")

        #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 execute_main(self):

        print('in main method of PDM')

        self.v_driver = webdriver.Chrome(AppConstants.BROWSER_DRIVER)
        self.v_driver.maximize_window()

        self.lo.log_to_file("INFO", "Login in to Launchpad")
        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)
        print("asdasdsad")
        lg.login("Launchpad")
        time.sleep(5)
        self.v_driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK)
        time.sleep(5)
        if so.check_clickable_by_xpath(
                "html/body/app-reporting/div/div/nav-bar/div/nav"):
            print("Element clickable")
        else:
            print("Not clickable")
    def execute_main(self):


        login_object = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.log_file_object)
        error_hospital_machine_learning_object = Error_Hospital_Machine_Learning(self.v_task_type, self.v_username)
        report_file_object = ReportFileUtility(self.v_task_type)
        output_sheet = self.v_input_wb.get_sheet_by_name('Output')
        input_sheet = self.v_input_wb.get_sheet_by_name('Input')
        excel_operation_object = ExcelOperations(self.v_task_type, input_sheet)
        #Login into DC4 Prod
        login_object.login("DC4 Prod")
        self.log_file_object.log_to_file("INFO", "Login in to DC4 Prod")
        self.v_driver.execute_script("window.open('https://commerce.spscommerce.com/transaction-tracker/prod/transactions/', 'new_window')")
        self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
        time.sleep(2)
        #Login into Launchpad
        login_object.login("Launchpad")
        self.log_file_object.log_to_file("INFO", "Login in to Launchpad")
        self.v_driver.switch_to.window(self.v_driver.window_handles[0])
        time.sleep(2)
        #Extract data from input sheet
        for index in range(2,input_sheet.max_row+1):
            today = datetime.datetime.now()
            DD = datetime.timedelta(days=6)
            earlier = today - DD
            earlier_str = earlier.strftime("%Y-%m-%d")
            earlier_str = earlier_str+' 00:00:00'

            v_error_title = excel_operation_object.get_value(index, 1)
            #Searching data as per error title
            if v_error_title == LocalElementLocator.ADHOC_ERROR_TITLE:
                self.log_file_object.log_to_file("INFO", "Seaching tickets for error title:- AdhocReporting: document rejected")
                v_start_time = time.time()
                v_ticket_uid = excel_operation_object.get_value(index, 2)
                if v_ticket_uid is None:
                    v_ticket_uid = ' '
                Error_Document_rejected_obj = Error_Document_rejected(self.v_task_type, self.v_driver, self.log_file_object,
                                                                      self.v_input_wb, error_hospital_machine_learning_object)
                v_count = Error_Document_rejected_obj.execute_main(v_error_title, v_ticket_uid, output_sheet, earlier_str)
                v_end_time = time.time()
                report_file_object.update_sheet(self.v_username, v_count, math.floor(v_end_time - v_start_time), str(datetime.date.today()))
            if v_error_title == LocalElementLocator.WEB_DOC_REJECTED_ERROR_TITLE:
                self.log_file_object.log_to_file("INFO",
                                                 "Seaching tickets for error title:- WebForms-ToService: document rejected")
                v_start_time = time.time()
                v_ticket_uid = excel_operation_object.get_value(index, 2)
                if v_ticket_uid is None:
                    v_ticket_uid = ' '
                Error_Document_rejected_obj = Error_Document_rejected(self.v_task_type, self.v_driver, self.log_file_object, self.v_input_wb, error_hospital_machine_learning_object)
                v_count = Error_Document_rejected_obj.execute_main(v_error_title, v_ticket_uid, output_sheet, earlier_str)
                v_end_time = time.time()
                report_file_object.update_sheet(self.v_username, v_count, math.floor(v_end_time - v_start_time),
                                str(datetime.date.today()))
            else:
                self.log_file_object.log_to_file("ERROR",
                                                 "Invalid error title ErrorHospital.execute_main()")
        time.sleep(3)
        self.v_driver.close()
Пример #11
0
    def execute_main(self):
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login_object = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                             self.lo)
        selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                       self.v_driver, self.lo)
        # report_file_object = ReportFileUtility(self.v_task_type)

        total_rows = self.v_data_sheet.max_row
        print(total_rows)
        login_object.login("DC4 Prod")
        self.v_driver.maximize_window()

        for row_count in range(2, total_rows + 1):
            v_start_time = time.time()
            excel_operations = ExcelOperations(self.v_task_type,
                                               self.v_data_sheet)
            v_supplier = self.v_data_sheet.cell(row=row_count, column=1).value
            v_retailer = self.v_data_sheet.cell(row=row_count, column=2).value
            v_erp = self.v_data_sheet.cell(row=row_count, column=15).value
            print(v_retailer)
            print(v_erp)
            service_name = ["FItoService", "FIfromService"]

            v_doc_type = self.v_data_sheet.cell(row=row_count, column=3).value
            print(v_doc_type)
            v_date = self.v_data_sheet.cell(row=row_count, column=4).value

            if v_doc_type == 850:
                print(v_doc_type)
                Setup_U_Ob = QB_Setup_Util(self.v_task_type, self.lo,
                                           self.v_username, self.v_input_wb,
                                           self.v_driver)
                retailer_flag = Setup_U_Ob.retailer_v_check(
                    v_supplier, v_retailer, v_doc_type, row_count)
                supplier_flag = Setup_U_Ob.Supplier_Setup_Check(
                    v_supplier, v_retailer, v_doc_type, v_erp, row_count)
    def retailer_ver_check(self, doc_type, retailer_capability_name):

        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        login = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                      self.lo)
        selenium_operations = SeleniumOperations(self.v_task_type,
                                                 self.v_driver, self.lo)

        selenium_operations.click_element_by_xpath(
            CommonLocators.DC4_ADMIN_TAB)

        selenium_operations.send_text_by_xpath(
            CommonLocators.DATATYPE_NAME_TEXTFIELD, retailer_capability_name)

        selenium_operations.click_element_by_xpath(
            CommonLocators.DATATYPE_SEARCH_BUTTON)

        retailer_FEDS_capability_name = selenium_operations.get_text_by_xpath(
            CommonLocators.FEDS_CAPABILITY)

        selenium_operations.send_text_by_xpath(
            CommonLocators.DATATYPE_NAME_TEXTFIELD,
            retailer_FEDS_capability_name)

        table_rows = self.v_driver.find_elements_by_xpath(
            '//*[@id="form1:table1"]/table[2]/tbody/tr[1]/th[1]')

        total_rows = len(table_rows) - 1

        print(total_rows)

        for counter in range(0, total_rows):

            retailer_version_value = selenium_operations.get_text_by_xpath(
                '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(counter) +
                ']/td[7]')
            if retailer_version_value == " ":
                pass
            else:
                return retailer_version_value
    def supplier_setup_check(self, v_supplier, v_retailer, v_document_type,
                             current_row, service_name):

        v_document_type = str(v_document_type)
        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)

        # lg.login("DC4 PreProd")
        #
        # # Switch to other window
        # self.v_driver.execute_script("window.open('about:blank', 'tab2');")
        # self.v_driver.switch_to.window("tab2")
        # time.sleep(2)
        #
        # lg.login("Launchpad")
        # time.sleep(5)
        #
        # self.v_driver.maximize_window()

        eo = ExcelOperations(self.v_task_type, self.v_data_sheet)

        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)

        so.click_element_by_xpath(AppConstants.DC4_TAB)

        dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
        so.send_text_by_xpath(AppConstants.DC4_COMPANY_NAME_TEXT_FIELD,
                              v_supplier)
        so.click_element_by_xpath(AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK)
        select_supplier = so.click_element_by_xpath(
            CommonLocators.Company_Select_Link)

        # Check the retationship
        click_relationship = self.v_driver.find_element_by_xpath(
            CommonLocators.Relationship_Tab).click()
        search_retailer_relationship = self.v_driver.find_element_by_xpath(
            CommonLocators.Trading_Partner_Name_text_Field).send_keys(
                v_retailer)

        self.v_driver.find_element_by_xpath(
            CommonLocators.click_search).click()

        # retailer_profile_name = self.v_driver.find_element_by_xpath(CommonLocators.Trading_Partner_Profile_Name).text
        # print(retailer_profile_name)

        supplier_EDI_Data = self.v_driver.find_element_by_xpath(
            CommonLocators.Supplier_EDI_Info).text
        retailer_EDI_Data = self.v_driver.find_element_by_xpath(
            CommonLocators.Retailer_EDI_Info).text

        # Supplier EDI Info
        supplier_EDI_Data_list_1 = supplier_EDI_Data.split('GRP_ID:')
        supplier_EDI_Data_list_2 = supplier_EDI_Data.split('Qual:')

        supplier_qaul_ID = supplier_EDI_Data_list_2[1].split('ID:')[0]
        supplier_qaul_ID = re.sub('\W+', '', supplier_qaul_ID)
        eo.set_value(current_row, 5, supplier_qaul_ID)
        self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)

        supplier_ISA_ID = supplier_EDI_Data_list_1[0].split('ID:')[2]
        supplier_ISA_ID = re.sub('\W+', '', supplier_ISA_ID)
        eo.set_value(current_row, 6, supplier_ISA_ID)
        self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)

        supplier_Grp_ID = supplier_EDI_Data_list_1[1]
        supplier_Grp_ID = re.sub('\W+', '', supplier_Grp_ID)

        # Retailer EDI Info
        retailer_EDI_Data_list_1 = retailer_EDI_Data.split('GRP_ID:')
        retailer_EDI_Data_list_2 = retailer_EDI_Data.split('Qual:')

        retailer_qaul_ID = retailer_EDI_Data_list_2[1].split('ID:')[0]
        retailer_qaul_ID = re.sub('\W+', '', retailer_qaul_ID)
        eo.set_value(current_row, 7, retailer_qaul_ID)
        self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)

        retailer_ISA_ID = retailer_EDI_Data_list_1[0].split('ID:')[2]
        retailer_ISA_ID = re.sub('\W+', '', retailer_ISA_ID)
        eo.set_value(current_row, 8, retailer_ISA_ID)
        self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)

        retailer_Grp_ID = retailer_EDI_Data_list_1[1]
        retailer_Grp_ID = re.sub('\W+', '', retailer_Grp_ID)

        v_trading_partner_name = self.v_driver.find_element_by_xpath(
            CommonLocators.Trading_Partner_Name).text
        print(v_trading_partner_name)

        if v_trading_partner_name == v_retailer:

            # Select the Supplier company profile and check for the FI setup
            select_supplier_profile = self.v_driver.find_element_by_xpath(
                CommonLocators.Supplier_Profile_Link).click()

        elif v_trading_partner_name == "No trading partners found.":

            print("No Retailer Found")
            return

        # Profile Page Display
        show_option_click = self.v_driver.find_element_by_xpath(
            CommonLocators.show_click).click()

        counter = 2
        path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
            counter) + ']/td[10]'
        while (so.check_exists_by_xpath(path)):

            service = so.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[10]')
            doc_tpe = so.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[3]')

            if service == service_name:
                if doc_tpe == v_document_type:

                    eo.set_value(current_row, 11, "FI Capability is present")

                    supplier_version = so.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                        + str(counter) + ']/td[7]')
                    eo.set_value(current_row, 9, supplier_version)
                    self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)

                    click_extension = so.click_element_by_xpath(
                        '//*[@id="form1:table1:0:table2:' + str(counter) +
                        ':extensionPopup"]')

                    # Process_Test_Files_Utility.add_extensions(counter)
                    break
                else:
                    eo.set_value(current_row, 11, "FI is not present")

            self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
            counter = counter + 1
            path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                counter) + ']/td[10]'

        time.sleep(15)
    def retailer_setup_check(self, v_supplier, v_retailer, v_document_type,
                             current_row):
        v_document_type_1 = str(v_document_type)
        v_document_type_2 = '875'
        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)

        eo = ExcelOperations(self.v_task_type, self.v_data_sheet)

        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)

        so.click_element_by_xpath(AppConstants.DC4_TAB)

        dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
        self.v_driver.find_element_by_xpath(
            AppConstants.DC4_COMPANY_NAME_TEXT_FIELD).send_keys(v_retailer)
        self.v_driver.find_element_by_xpath(
            AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK).click()
        select_retailer = self.v_driver.find_element_by_xpath(
            CommonLocators.Company_Select_Link).click()

        # Check the retationship
        click_relationship = so.click_element_by_xpath(
            CommonLocators.Relationship_Tab)
        search_retailer_relationship = so.send_text_by_xpath(
            CommonLocators.Trading_Partner_Name_text_Field, v_supplier)
        so.click_element_by_xpath(CommonLocators.click_search)

        # Select the Retailer company profile and check for the FI setup
        select_retailer_profile = so.click_element_by_xpath(
            CommonLocators.Supplier_Profile_Link)

        # Profile Page Display
        show_option_click = so.click_element_by_xpath(
            CommonLocators.show_click)

        counter = 2
        path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
            counter) + ']/td[10]'
        while (so.check_exists_by_xpath(path)):

            service = so.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[10]')
            doc_tpe = so.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[3]')
            print(doc_tpe)

            if doc_tpe == v_document_type_1:
                if service != 'DoNotRoute':
                    print("850 capability is available")

                    retailer_version = so.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                        + str(counter) + ']/td[8]')
                    eo.set_value(current_row, 10, retailer_version)
                    self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                    break

                elif service == 'DoNotRoute':
                    print("850 capability is not available")

            elif doc_tpe == v_document_type_2:
                if service != 'DoNotRoute':
                    print("875 capability is present")

                    retailer_version = so.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                        + str(counter) + ']/td[8]')
                    eo.set_value(current_row, 10, retailer_version)
                    self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                    break

                elif service == 'DoNotRoute':
                    print("875 capability is present")

            counter = counter + 1
            path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                counter) + ']/td[10]'

        time.sleep(10)
    def execute_main(self):

        t1 = threading.Thread(target=self.thread1)

        t2 = threading.Thread(target=self.thread2)
        t1.start()
        t2.start()

        t1.join()
        t2.join()

        db_object = DatabaseUtility(self.v_task_type, self.lo)
        if db_object.connection():
            self.lo.log_to_file('INFO', 'Successful Connection')
        else:
            self.lo.log_to_file('ERROR', 'DB Server is not active')
            return
        v_start_time = time.time()
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login_obj = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                          self.lo)
        selenium_operation_obj = SeleniumOperations(self.v_task_type,
                                                    self.v_driver, self.lo)
        report_file_obj = ReportFileUtility(self.v_task_type)
        input_sheet = self.v_input_wb.get_sheet_by_name('Input')
        input_sheet_row_count = input_sheet.max_row
        excel_operation_obj = ExcelOperations(self.v_task_type, input_sheet)
        Web_Fulfillment_Utility_obj = Web_Fulfillment_Utility(
            self.v_task_type, self.v_driver, self.v_input_wb, self.lo,
            self.v_username, db_object, self.v_driver_mv)
        # login_obj.login("Salesforce")
        self.v_driver.execute_script(
            "window.open('http://dc4ui.p01.pro:7777/dc4custmanager/faces/home.jsp', 'new_window')"
        )

        # self.v_driver.execute_script(
        #     "window.open('https://atlassian.spscommerce.com/browse/FICS-163692', 'new_window')")
        self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
        report_file_object = ReportFileUtility(self.v_task_type)
        time.sleep(2)
        login_obj.login("DC4 Prod")

        input_row = input_sheet_row_count + 1
        FICS_Number = excel_operation_obj.get_value(input_row, 1)
        flag = 1
        count = 0
        v_start_time = time.time()
        while (flag):
            v_start_time1 = time.time()
            v_salesforce_id = easygui.enterbox('Please enter salesforce ID')
            self.v_driver.switch_to.window(self.v_driver.window_handles[0])
            time.sleep(2)
            #self.v_driver.get('https://atlassian.spscommerce.com/browse/'+FICS_Number)
            #v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, v_salesforce_id = Web_Fulfillment_Utility_obj.get_info_from_JIRA()
            v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, client_uid, retailer_uid = Web_Fulfillment_Utility_obj.get_info_from_salesforce(
                v_salesforce_id)
            print(v_salesforce_id + "\n" + v_supplier_name + "\n" +
                  v_email_address + "\n" + v_phone_number + "\n" +
                  v_retailer_name + "\n" + v_vendor_number + "\n" +
                  v_retailer_web_company_uid + "\n" + v_account_number + "\n" +
                  v_retailer_dc4_company_uid + "\n" + v_contact_name)
            print(v_billing_address)

            self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
            time.sleep(2)
            #Web_Fulfillment_Utility_obj.get_data_for_library(v_salesforce_id, v_supplier_name, v_retailer_name, v_retailer_dc4_company_uid, FICS_Number)
            Web_Fulfillment_Utility_obj.run_setup_tool(
                v_salesforce_id, v_supplier_name, v_email_address,
                v_phone_number, v_retailer_name, v_billing_address,
                v_vendor_number, v_retailer_web_company_uid, v_account_number,
                v_retailer_dc4_company_uid, v_contact_name, client_uid,
                retailer_uid)
            print(input_row)
            count = count + 1
            excel_operation_obj.set_value(input_row, 1, count)

            FICS_Number = excel_operation_obj.get_value(input_row, 1)
            v_end_time1 = time.time()
            excel_operation_obj.set_value(
                input_row, 2, math.floor(v_end_time1 - v_start_time1))
            excel_operation_obj.set_value(input_row, 3, datetime.date.today())
            print(
                '----------------------------------------------\n\nExecution Time: '
                + str(math.floor(v_end_time1 - v_start_time1)) + '   count: ' +
                str(count) + '\n\n-------------------------')
            time.sleep(2)
            input_row = input_row + 1

            self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
            flag = easygui.ynbox('Do you want to run one more setup?')
        v_end_time = time.time()
        report_file_object.update_sheet(self.v_username, count,
                                        math.floor(v_end_time - v_start_time),
                                        str(datetime.date.today()))
    def execute_main(self):
        v_start_time = time.time()
        self.lo.log_to_file("INFO", "Login in to DC4 Pre-Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        rf = ReportFileUtility(self.v_task_type)
        SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        output_sheet = self.v_input_wb.get_sheet_by_name('Output')
        input_sheet = self.v_input_wb.get_sheet_by_name('Input')
        input_sheet_ex = ExcelOperations(self.v_task_type, input_sheet)
        output_sheet_ex = ExcelOperations(self.v_task_type, output_sheet)
        self.v_driver.maximize_window()
        Max_row = input_sheet.max_row
        current_row = 2
        #Max_row = output_sheet.max_row
        #current_row_output = 2

        lg.login("DC4 PreProd")

        while (current_row <= Max_row):
            v_TPID = input_sheet.cell(row=current_row, column=1).value
            v_Doc_850 = input_sheet.cell(row=current_row, column=2).value
            if (v_Doc_850 == 'Y'):
                v_doc = '850'
                V_supplier_doc_version = '7.4'
            dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
            dc.company_search_by_TPID(v_TPID)
            self.lo.log_to_file("INFO", "Searching Supplier Data")
            V_Supplier_Profile_name = so.get_text_by_xpath(
                '//*[@id="table2"]/table/tbody/tr/td/table/tbody/tr[2]/td[2]')
            V_Supplier_name = so.get_text_by_xpath(
                '//*[@id="table2:0:commandLink4"]')
            print("Supplier Name = " + V_Supplier_name)
            output_sheet_ex.set_value(current_row, 1, V_Supplier_name)
            print("Supplier Profile = " + V_Supplier_Profile_name)
            so.click_element_by_xpath('//*[@id="table2:0:commandLink4"]')
            so.click_element_by_xpath(
                '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a'
            )
            self.lo.log_to_file("INFO", "Searching Retailer Data")
            V_retailer_name, V_retailer_profile, V_supplier_row_index = self.search_retailer_profile(
                V_Supplier_Profile_name)
            #print(V_retailer_name, V_retailer_profile, V_supplier_row_index)
            if V_retailer_name == V_retailer_profile == V_supplier_row_index == False:
                print('No relationship found')
                self.lo.log_to_file(
                    "INFO", "No relationship found, going to next row")
                output_sheet_ex.set_value(current_row, 4,
                                          'Relationship not found')
                current_row = current_row + 1
            else:
                print("Retailer Name = " + V_retailer_name)
                output_sheet_ex.set_value(current_row, 2, V_retailer_name)
                print("Retailer Profile = " + V_retailer_profile)
                self.lo.log_to_file("INFO", "Searching Retailer Map Versions")
                V_ret_document, V_ret_doc_status, V_ret_doc_service, V_ret_doc_version = self.search_retailer_map(
                    v_doc, V_retailer_profile, V_Supplier_Profile_name,
                    V_Supplier_name)
                V_supplier_map_version, V_supplier_profile_map_name, V_supplier_map_row_index = self.check_supplier_profile(
                    V_Supplier_Profile_name, v_doc, V_supplier_row_index)
                print("Supplier Map version = " + V_supplier_map_version)
                print("Supplier Map Name" + V_supplier_profile_map_name)
                output_sheet_ex.set_value(current_row, 3, V_ret_document)
                self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                self.lo.log_to_file("INFO", "Maps and version found")
                V_send_suuplier_map_index = int(V_supplier_map_row_index)
                V_send_suuplier_map_index = V_send_suuplier_map_index - 2
                status = self.add_extensions(V_ret_doc_version,
                                             V_supplier_doc_version,
                                             V_send_suuplier_map_index)
                #print(status)
                if status == 'None':
                    output_sheet_ex.set_value(current_row, 4, 'Success')
                else:
                    output_sheet_ex.set_value(current_row, 4, 'Fail')
                current_row = current_row + 1

        self.v_driver.close()
        v_end_time = time.time()
        rf.update_sheet(self.v_username, 2,
                        math.floor(v_end_time - v_start_time),
                        str(datetime.date.today()))
Пример #17
0
    def check_extensions(self, v_supplier, v_retailer, v_document_type,
                         current_row, service_name):

        v_document_type = str(v_document_type)
        self.lo.log_to_file("INFO", "Check for the map extensions")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        eo = ExcelOperations(self.v_task_type, self.v_data_sheet)
        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        so.click_element_by_xpath(AppConstants.DC4_TAB)
        dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
        so.send_text_by_xpath(AppConstants.DC4_COMPANY_NAME_TEXT_FIELD,
                              v_supplier)
        so.click_element_by_xpath(AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK)
        select_supplier = so.click_element_by_xpath(
            CommonLocators.Company_Select_Link)

        # Check the retationship
        click_relationship = self.v_driver.find_element_by_xpath(
            CommonLocators.Relationship_Tab).click()
        search_retailer_relationship = self.v_driver.find_element_by_xpath(
            CommonLocators.Trading_Partner_Name_text_Field).send_keys(
                v_retailer)
        self.v_driver.find_element_by_xpath(
            CommonLocators.click_search).click()
        select_supplier_profile = so.click_element_by_xpath(
            CommonLocators.Supplier_Profile_Link)

        # Profile Page Display
        show_option_click = self.v_driver.find_element_by_xpath(
            CommonLocators.show_click).click()

        counter = 2
        path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
            counter) + ']/td[10]'
        flag = 0
        while (so.check_exists_by_xpath(path)):

            service = so.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[10]')
            doc_tpe = so.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[3]')

            if service == service_name and doc_tpe == v_document_type:

                V_configure_extensions_xpath = '//*[@id="form1:table1:0:table2:' + str(
                    counter - 2) + ':extensionPopup"]'
                so.click_element_by_xpath(V_configure_extensions_xpath)

                self.v_driver.switch_to.window(
                    self.v_driver.window_handles[-1])
                time.sleep(3)
                self.v_driver.switch_to.frame(0)
                time.sleep(2)

                extension_counter = 2
                click_show_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
                    extension_counter) + ']/td[1]/div/a[2]'
                extension_counter1 = 0
                map_extension_list = list()
                while (so.check_exists_by_xpath(click_show_path)):
                    so.click_element_by_xpath(
                        '//*[@id="form1:table1"]/table[2]/tbody/tr[' +
                        str(extension_counter) + ']/td[1]/div/a[2]')
                    time.sleep(1)
                    map_text = self.v_driver.find_element_by_name(
                        'form1:table1:' + str(extension_counter1) +
                        ':table2:0:outputText22')
                    map_values = map_text.get_attribute('value')

                    map_extension_list.append(map_values)
                    print(map_extension_list)
                    extension_counter = extension_counter + 2
                    extension_counter1 = extension_counter1 + 1
                    click_show_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
                        extension_counter) + ']/td[1]/div/a[2]'

                map_extension_list_str = ('\n').join(map_extension_list)

                supplier_map_version = self.v_data_sheet.cell(row=current_row,
                                                              column=9).value
                retailer_map_version = self.v_data_sheet.cell(row=current_row,
                                                              column=10).value

                msg_1 = "Please press Yes if the maps are correct. Select No if the maps are incorrect \n\n " + "\n" + "Supplier Version:" + supplier_map_version + "\n" + "Retailer Version:" + retailer_map_version + "\n\n" + map_extension_list_str

                if msg_1 is not None:
                    title = "Please Confirm"
                    if boolbox(msg_1, title):  # show a Continue/Cancel dialog
                        pass  # user chose Yes
                    else:  # user chose No
                        flag = 1
                        break
                else:
                    pass

            counter = counter + 1
            # map_extension_list.clear()
            path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                counter) + ']/td[10]'

        close_extension_tab = so.click_element_by_xpath(
            CommonLocators.extensions_cancel_button)

        self.v_driver.switch_to.window(self.v_driver.window_handles[0])
        return flag
 def thread2(self):
     login_obj = Login(self.v_task_type, self.v_driver_mv, self.v_input_wb,
                       self.lo)
     login_obj.login('Launchpad')
     time.sleep(5)
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 execute_main(self):
        db_object = DatabaseUtility(self.v_task_type, self.lo)
        if db_object.connection():
            self.lo.log_to_file('INFO', 'Successful Connection')
        else:
            self.lo.log_to_file('ERROR', 'DB Server is not active')
            return
        v_start_time = time.time()
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login_obj = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                          self.lo)
        selenium_operation_obj = SeleniumOperations(self.v_task_type,
                                                    self.v_driver, self.lo)
        report_file_obj = ReportFileUtility(self.v_task_type)
        input_sheet = self.v_input_wb.get_sheet_by_name('Input')
        input_sheet_row_count = input_sheet.max_row
        excel_operation_obj = ExcelOperations(self.v_task_type, input_sheet)
        Web_Fulfillment_Utility_obj = Web_Fulfillment_Utility(
            self.v_task_type, self.v_driver, self.v_input_wb, self.lo,
            self.v_username, db_object)
        login_obj.login("Salesforce")
        self.v_driver.execute_script(
            "window.open('http://dc4ui.p01.pro:7777/dc4custmanager/faces/home.jsp', 'new_window')"
        )

        # self.v_driver.execute_script(
        #     "window.open('https://atlassian.spscommerce.com/browse/FICS-163692', 'new_window')")
        self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
        report_file_object = ReportFileUtility(self.v_task_type)
        time.sleep(2)
        login_obj.login("DC4 Prod")

        input_row = excel_operation_obj.get_value(2, 4)
        FICS_Number = excel_operation_obj.get_value(input_row, 1)

        while (FICS_Number != None):
            v_start_time = time.time()
            v_salesforce_id = FICS_Number
            self.v_driver.switch_to.window(self.v_driver.window_handles[0])
            time.sleep(2)
            #self.v_driver.get('https://atlassian.spscommerce.com/browse/'+FICS_Number)
            #v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name, v_salesforce_id = Web_Fulfillment_Utility_obj.get_info_from_JIRA()
            v_supplier_name, v_email_address, v_phone_number, v_retailer_name, v_billing_address, v_vendor_number, v_retailer_web_company_uid, v_account_number, v_retailer_dc4_company_uid, v_contact_name = Web_Fulfillment_Utility_obj.get_info_from_salesforce(
                v_salesforce_id)
            print(v_salesforce_id + "\n" + v_supplier_name + "\n" +
                  v_email_address + "\n" + v_phone_number + "\n" +
                  v_retailer_name + "\n" + v_vendor_number + "\n" +
                  v_retailer_web_company_uid + "\n" + v_account_number + "\n" +
                  v_retailer_dc4_company_uid + "\n" + v_contact_name)
            print(v_billing_address)

            self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
            time.sleep(2)
            try:
                #Web_Fulfillment_Utility_obj.get_data_for_library(v_salesforce_id, v_supplier_name, v_retailer_name, v_retailer_dc4_company_uid, FICS_Number)
                Web_Fulfillment_Utility_obj.run_setup_tool(
                    v_salesforce_id, v_supplier_name, v_email_address,
                    v_phone_number, v_retailer_name, v_billing_address,
                    v_vendor_number, v_retailer_web_company_uid,
                    v_account_number, v_retailer_dc4_company_uid,
                    v_contact_name)
            except:
                self.v_driver.save_screenshot(AppConstants.APP_RUNNER_PATH +
                                              v_salesforce_id + '.png')

            print(input_row)
            v_end_time = time.time()
            report_file_object.update_sheet(
                self.v_username, 1, math.floor(v_end_time - v_start_time),
                str(datetime.date.today()))
            input_row = input_row + 1
            excel_operation_obj.set_value(2, 4, input_row)
            FICS_Number = excel_operation_obj.get_value(input_row, 1)
            time.sleep(2)
    def 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 Supplier_Setup_Check(self, v_supplier, v_retailer, v_document_type,
                             v_erp, current_row):
        v_document_type_1 = str(v_document_type)
        v_document_type_2 = '875'
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                      self.lo)
        selenium_operations = SeleniumOperations(self.v_task_type,
                                                 self.v_driver, self.lo)

        excel_operations = ExcelOperations(self.v_task_type, self.v_data_sheet)

        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                      self.lo)
        selenium_operations = SeleniumOperations(self.v_task_type,
                                                 self.v_driver, self.lo)

        selenium_operations.click_element_by_xpath(AppConstants.DC4_TAB)

        dc4_utility = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
        self.v_driver.find_element_by_xpath(
            AppConstants.DC4_COMPANY_NAME_TEXT_FIELD).send_keys(v_supplier)
        self.v_driver.find_element_by_xpath(
            AppConstants.DC4_COMPANY_NAME_SEARCH_CLICK).click()
        select_retailer = self.v_driver.find_element_by_xpath(
            '//*[@id="table1:10:commandLink2"]').click()

        click_relationship = selenium_operations.click_element_by_xpath(
            CommonLocators.Relationship_Prod_Tab)
        search_retailer_relationship = selenium_operations.send_text_by_xpath(
            CommonLocators.Trading_Partner_Name_text_Field, v_retailer)
        selenium_operations.click_element_by_xpath(CommonLocators.click_search)

        # Select the Retailer company profile and check for the FI setup
        select_retailer_profile = selenium_operations.click_element_by_xpath(
            CommonLocators.Supplier_Profile_Link)

        # Profile Page Display
        show_option_click = selenium_operations.click_element_by_xpath(
            CommonLocators.show_click)

        counter = 2
        path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
            counter) + ']/td[10]'
        while (selenium_operations.check_exists_by_xpath(path)):

            service = selenium_operations.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[10]')
            print(service)
            doc_type = selenium_operations.get_text_by_xpath(
                '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                + str(counter) + ']/td[3]')
            counter = counter + 1
            print(doc_type)
            print(v_erp)

            if doc_type == v_document_type_1:
                if service != 'DoNotRoute' and service != 'WEBtoService':
                    print("850 capability is already available")
                    print(v_document_type_1)

                else:
                    print('add new capability')
                    add_existing_capability = selenium_operations.click_element_by_xpath(
                        '//*[@id="form1:table1:0:table2:addExistingCapability"]/img'
                    )
                    time.sleep(2)

                    self.v_driver.switch_to.window(
                        self.v_driver.window_handles[-1])
                    time.sleep(3)
                    self.v_driver.switch_to.frame(0)
                    time.sleep(2)

                    self.v_driver.find_element_by_xpath(
                        '//*[@id="form1:showDetailHeader1"]/tbody/tr[2]/td[2]/table/tbody/tr[1]/td[1]'
                    ).click()
                    self.v_driver.find_element_by_xpath(
                        '//*[@id="form1:inputText3"]').send_keys('FI%')

                    time.sleep(3)

                    if v_erp == 'QB':
                        self.v_driver.find_element_by_xpath(
                            '//*[@id="form1:inputText4"]'
                        ).send_keys(
                            'SPS QuickBooks Adaptor | RSX 7.2 | 850 - Legacy')
                        selenium_operations.click_element_by_xpath(
                            '//*[@id="form1:commandButton2"]/img')
                        print('850 QB exists')
                        try:
                            self.v_driver.find_element_by_xpath(
                                '//*[@id="form1:table1:0:tableSelectMany1"]')
                            capability_flag = 0
                        except:
                            capability_flag = 1

                    elif v_erp == 'Dwyer':
                        self.v_driver.find_element_by_xpath(
                            '//*[@id="form1:inputText4"]').send_keys(
                                'Dwyer Adaptor V7 850 V2 XML')
                        selenium_operations.click_element_by_xpath(
                            '//*[@id="form1:commandButton2"]/img')
                        print('850 QB exists')
                        try:
                            self.v_driver.find_element_by_xpath(
                                '//*[@id="form1:table1:0:tableSelectMany1"]')
                            capability_flag = 0
                        except:
                            capability_flag = 1
                    else:
                        self.v_driver.find_element_by_xpath(
                            '//*[@id="form1:inputText4"]').send_keys(
                                'SPS Fishbowl Adaptor | RSX 7.2 | 850 - Legacy'
                            )
                        selenium_operations.click_element_by_xpath(
                            '//*[@id="form1:commandButton2"]/img')
                        print('850 QB exists')
                        try:
                            self.v_driver.find_element_by_xpath(
                                '//*[@id="form1:table1:0:tableSelectMany1"]')
                            capability_flag = 0
                        except:
                            capability_flag = 1

                    if capability_flag == 0:
                        self.v_driver.find_element_by_xpath(
                            '//*[@id="form1:table1:0:tableSelectMany1"]'
                        ).click()
                        Choose = selenium_operations.double_click_by_xpath(
                            '//*[@id="form1:table1:commandButton1"]')
                        time.sleep(10)

                    else:
                        self.v_driver.close()
                        print('Add new capability')

                        self.v_driver.switch_to.window(
                            self.v_driver.window_handles[0])
                        time.sleep(2)
                        selenium_operations.click_element_by_xpath(
                            '//*[@id="form1:table1:0:table2:createCapability"]/img'
                        )
                        time.sleep(5)

                        self.v_driver.switch_to.window(
                            self.v_driver.window_handles[-1])
                        time.sleep(3)
                        self.v_driver.switch_to.frame(0)
                        time.sleep(2)

                        self.v_driver.find_element_by_xpath(
                            '//*[@id="form1:findService"]').send_keys('1007')

                        if v_erp == 'QB':
                            self.v_driver.find_element_by_xpath(
                                '//*[@id="form1:findDataType"]').send_keys(
                                    '106967')
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:commandButton1"]/img')

                        elif v_erp == 'Dwwyer':
                            self.v_driver.find_element_by_xpath(
                                '//*[@id="form1:findDataType"]').send_keys(
                                    '91552')
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:commandButton1"]/img')

                        else:
                            self.v_driver.find_element_by_xpath(
                                '//*[@id="form1:findDataType"]').send_keys(
                                    '109095')
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:commandButton1"]/img')
                self.v_driver.switch_to.window(self.v_driver.window_handles[0])
                time.sleep(2)
                counter = 2
                path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                    counter) + ']/td[10]'
                while (selenium_operations.check_exists_by_xpath(path)):
                    service = selenium_operations.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                        + str(counter) + ']/td[10]')
                    print(service)
                    doc_type = selenium_operations.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                        + str(counter) + ']/td[3]')
                    print(doc_type)
                    capability_uid = selenium_operations.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2:column24"]')
                    print(capability_uid)
                    profile_uid = selenium_operations.get_text_by_xpath(
                        '//*[@id="form1:table1:0:outputText1"]')
                    print(profile_uid)

                    if doc_type == v_document_type_1:
                        if service != 'DoNotRoute' and service != 'WEBtoService':
                            print("850 capability exist")
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:table1:0:table2:' +
                                str(counter - 2) + ':tableSelectMany1"]')
                            print("Capability selected")
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:table1:0:table2:disableCapability"]/img'
                            )
                            time.sleep(10)
                            break
                    counter = counter + 1
                path = 'Close'
    def execute_main(self):
        v_start_time = time.time()
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type,self.v_driver,self.lo)
        ehu =  ErrorHospital_Utility(self.v_task_type,self.v_driver,self.lo)
        rf = ReportFileUtility(self.v_task_type)
        output_sheet = self.v_input_wb.get_sheet_by_name('Output')
        input_sheet = self.v_input_wb.get_sheet_by_name('Input')
        eo = ExcelOperations(self.v_task_type, input_sheet)
        output_sheet_eo = ExcelOperations(self.v_task_type, output_sheet)
        output_sheet_curr_row = 2
        for index in range(2,input_sheet.max_row+1):
            list_duplicate_ticket_uid = []
            today = datetime.datetime.now()
            DD = datetime.timedelta(days=14)
            earlier = today - DD
            earlier_str = earlier.strftime("%Y-%m-%d")
            earlier_str = earlier_str+' 00:00:00'
            lg.login("DC4 Prod")
            v_error_title = eo.get_value(index, 1)
            if v_error_title == LocalElementLocator.ADHOC_ERROR_TITLE:
                v_ticket_uid = eo.get_value(index, 2)
                if v_ticket_uid is None:
                    v_ticket_uid = ' '
                ehu.adhoc_error_search(v_ticket_uid,earlier_str,' ')
            if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH):
                so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH)
            tuid_index = 2
            while(ehu.get_ticket_uid(tuid_index)):
                temp_ticket_uid = ehu.get_ticket_uid(tuid_index)
                temp_receiver = ehu.get_receiver_name(tuid_index)
                temp_sender = ehu.get_sender_name(tuid_index)
                if temp_ticket_uid not in list_duplicate_ticket_uid:
                    ehu.adhoc_error_search(temp_ticket_uid,earlier_str,' ')
                    v_tpid, v_doctype = ehu.get_info_from_description(tuid_index-2)
                    ehu.adhoc_error_search(' ', earlier_str,v_tpid)
                    if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH):
                        so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH)
                    temp_tuid_index = 2
                    while (ehu.get_ticket_uid(temp_tuid_index)):
                        list_duplicate_ticket_uid.append(ehu.get_ticket_uid(temp_tuid_index))
                        temp_tuid_index = temp_tuid_index+1
                    output_sheet_eo.set_value(output_sheet_curr_row, 1, temp_ticket_uid)
                    output_sheet_eo.set_value(output_sheet_curr_row, 2, temp_sender)
                    output_sheet_eo.set_value(output_sheet_curr_row, 3, temp_receiver)
                    output_sheet_eo.set_value(output_sheet_curr_row, 4, v_tpid)
                    output_sheet_eo.set_value(output_sheet_curr_row, 5, v_doctype)
                    output_sheet_curr_row = output_sheet_curr_row+1
                    self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                    ehu.adhoc_error_search(v_ticket_uid, earlier_str, ' ')
                    if so.check_exists_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH):
                        so.click_element_by_xpath(LocalElementLocator.EH_SHOW_ALL_TAB_XPATH)
                tuid_index = tuid_index+1



        #so.click_element(AppConstants.DC4_TAB, "BY_NAME")
        #dc = DC4_Utility(self.v_task_type, self.v_driver, self.lo)
        #dc.company_search_by_name('Midlab Inc')
        #dc.company_search_by_ISA_ID('6166651648')
        #dc.company_search_by_TPID('620TSTWONDERTRE')

        self.v_driver.close()
        v_end_time = time.time()
        rf.update_sheet(self.v_username, 2, math.floor(v_end_time - v_start_time), str(datetime.date.today()))
 def thread1(self, ):
     login_obj = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                       self.lo)
     login_obj.login("Salesforce")
     time.sleep(5)