Exemplo n.º 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)
Exemplo n.º 2
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 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):
        v_start_time = time.time()
        self.lo.log_to_file("INFO", "Login in to DC4 Pre-Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        rf = ReportFileUtility(self.v_task_type)
        SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        output_sheet = self.v_input_wb.get_sheet_by_name('Output')
        input_sheet = self.v_input_wb.get_sheet_by_name('Input')
        input_sheet_ex = ExcelOperations(self.v_task_type, input_sheet)
        output_sheet_ex = ExcelOperations(self.v_task_type, output_sheet)
        self.v_driver.maximize_window()
        Max_row = input_sheet.max_row
        current_row = 2
        #Max_row = output_sheet.max_row
        #current_row_output = 2

        lg.login("DC4 PreProd")

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

        self.v_driver.close()
        v_end_time = time.time()
        rf.update_sheet(self.v_username, 2,
                        math.floor(v_end_time - v_start_time),
                        str(datetime.date.today()))
    def 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'
Exemplo n.º 8
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