def call_check_accepted(self, v_supplier, v_retailer, v_doc_type, v_date):
     print("In Call check accepted")
     self.v_driver.execute_script("window.open('about:blank', 'tab3');")
     self.v_driver.switch_to.window("tab3")
     time.sleep(3)
     self.v_driver.get(
         "https://commerce.spscommerce.com/transaction-tracker/prod/transactions/"
     )
     time.sleep(8)
     tt_operations = TransactionTrackerOperations(self.v_driver, self.lo)
     tt_operations.search_process_for_process_test_file(
         v_supplier, v_retailer, v_doc_type, v_date, "preprod")
     time.sleep(5)
     SeleniumOperation = SeleniumOperations(self.v_driver, self.lo)
     # self.v_driver.switch_to.frame(1)
     time.sleep(2)
     a = SeleniumOperation.get_text_by_xpath(ElementLocator.accepted1)
     if a == "Accepted":
         print("First Parcel is Accepted")
         pass
     b = SeleniumOperation.get_text_by_xpath(ElementLocator.accepted2)
     if b == "Accepted":
         print("Second Parcel is Accepted")
         pass
     c = SeleniumOperation.get_text_by_xpath(ElementLocator.accepted3)
     if a == "Accepted":
         print("Third Parcel is Accepted")
         pass
    def validate_existing_trading_partnership(self, error_title,
                                              doc_type_list):
        selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                       self.v_driver,
                                                       self.log_file_object)
        supplier_web_id = ''
        retailer_web_id = ''
        for v_index in range(0, len(doc_type_list)):
            temp_doc = doc_type_list[v_index]
            i = 2
            while (1):
                form_path = '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                    i) + ']/td[9]'
                status_path = '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                    i) + ']/td[12]'
                if selenium_operation_object.check_exists_by_xpath(form_path):
                    if temp_doc == selenium_operation_object.get_text_by_xpath(
                            form_path):

                        if temp_doc == '810' or temp_doc == '846' or temp_doc == '855' or temp_doc == '856' or temp_doc == '940':
                            supplier_web_id = selenium_operation_object.get_text_by_xpath(
                                '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                                + str(i) + ']/td[5]')
                            retailer_web_id = selenium_operation_object.get_text_by_xpath(
                                '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                                + str(i) + ']/td[7]')
                        else:
                            supplier_web_id = selenium_operation_object.get_text_by_xpath(
                                '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                                + str(i) + ']/td[7]')
                            retailer_web_id = selenium_operation_object.get_text_by_xpath(
                                '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                                + str(i) + ']/td[5]')

                        if selenium_operation_object.get_text_by_xpath(
                                status_path) == 'true':
                            del doc_type_list[v_index]

                            break
                    #Find supplier and retailer web company uid
                    if temp_doc == '810' or temp_doc == '846' or temp_doc == '855' or temp_doc == '856' or temp_doc == '940':
                        supplier_web_id = selenium_operation_object.get_text_by_xpath(
                            '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                            + str(i) + ']/td[5]')
                        retailer_web_id = selenium_operation_object.get_text_by_xpath(
                            '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                            + str(i) + ']/td[7]')
                    else:
                        supplier_web_id = selenium_operation_object.get_text_by_xpath(
                            '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                            + str(i) + ']/td[7]')
                        retailer_web_id = selenium_operation_object.get_text_by_xpath(
                            '//*[@id="resultTable"]/table/tbody/tr[3]/td/table/tbody/tr['
                            + str(i) + ']/td[5]')

                else:
                    break
                i = i + 1
        return doc_type_list, supplier_web_id, retailer_web_id
    def error_status(self, parcel_uid, error_title):
        self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
        time.sleep(3)
        link = 'https://commerce.spscommerce.com/transaction-tracker/prod/transactions/' + parcel_uid + '/'
        self.v_driver.get(link)
        time.sleep(15)
        self.v_driver.switch_to.frame(0)
        time.sleep(2)

        selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                       self.v_driver,
                                                       self.log_file_object)
        time.sleep(2)
        if error_title == LocalElementLocator.ADHOC_ERROR_TITLE:

            path = '//*[@id="parcel-' + parcel_uid + '"]/div[2]/div/div/div[2]/form/div/button[2]'
            if not selenium_operation_object.check_exists_by_xpath(path):
                time.sleep(2)
                self.v_driver.get(link)
                time.sleep(10)
                self.v_driver.switch_to.frame(0)
                time.sleep(2)
                if not selenium_operation_object.check_exists_by_xpath(path):
                    return 0

            selenium_operation_object.click_element_by_xpath(path)
            i = 1
            while (1):

                path1 = '/html/body/app-reporting/div/div/div/div/div[2]/div/section/div[2]/div[2]/div[' + str(
                    i) + ']'
                temp = selenium_operation_object.get_text_by_xpath(path1)
                time.sleep(1)
                if parcel_uid in temp:
                    ans = self.v_driver.find_element_by_xpath(
                        '/html/body/app-reporting/div/div/div/div/div[2]/div/section/div[2]/div[2]/div['
                        + str(i + 1) + ']').text
                    id = ans.split('AdhocReporting ')[1]
                    id = id.split('\n')[0]
                    break
                i = i + 1

            selenium_operation_object.click_element_by_xpath(
                '//*[@id="parcel-' + id + '"]/div/div/div[1]/a/span/i[2]')
            status = selenium_operation_object.get_text_by_xpath(
                '//*[@id="parcel-' + id +
                '"]/div/ng-include/div/div/div[1]/div/div[2]/dl/div[2]/dd')
            if status == 'Accepted':
                return 1
            else:
                return 0

        else:
            return 1
コード例 #4
0
 def return_capability_uid(self):
     so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
     #capabilities_sheet = so.call_excel_sheet('Capabilities')
     capabilities_sheet = self.v_input_wb.get_sheet_by_name('Capabilities')
     for row_counter in range(5, 6):
         for col_counter in range(2, (capabilities_sheet.max_column) + 1):
             so.click_element_by_xpath(
                 LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB)
             sheet_value_capability_notes = str(
                 capabilities_sheet.cell(row=row_counter - 1,
                                         column=col_counter).value)
             so.send_text_by_xpath(
                 LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB_NOTES,
                 sheet_value_capability_notes)
             so.click_element_by_xpath(
                 LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB_SEARCH)
             #print(len(so.list_elements_by_xpath(LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_TABLE)))
             if len(
                     so.list_elements_by_xpath(
                         LocalElementLocator.
                         DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_TABLE)
             ) == 2:
                 notes_content = str(
                     so.get_text_by_xpath(
                         LocalElementLocator.
                         DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_NOTES))
                 if sheet_value_capability_notes == notes_content:
                     print("New Capability UID Created:")
                     print(
                         so.get_text_by_xpath(
                             LocalElementLocator.
                             DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_CAPABILITY_UID
                         ))
                     capability_uid = str(
                         so.get_text_by_xpath(
                             LocalElementLocator.
                             DC4_PREPROD_CAPABILITY_TAB_SEARCHED_RESULT_CAPABILITY_UID
                         ))
                     capabilities_sheet.cell(
                         row=row_counter,
                         column=col_counter).value = capability_uid
                     #self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                 else:
                     print(
                         "Mess is done, Clean It :/ The Note that caused Issue"
                     )
                     print(sheet_value_capability_notes)
             else:
                 print("No Result Found for:")
                 print(sheet_value_capability_notes)
     self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
    def get_info_from_description(self, index):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        path = '//*[@id="form1:table1:' + str(index) + ':commandLink1"]'
        so.click_element_by_xpath(path)
        doctype = so.get_text_by_xpath(
            LocalElementLocator.EH_DOCTYPE_INFO_XPATH)
        doctype = doctype.split(' ')[0]
        TPID = so.get_text_by_xpath(
            LocalElementLocator.EH_DESCRIPTION_INFO_XPATH)
        if 'Document:' in TPID:
            TPID = TPID.split('Document:')[1]
            TPID = TPID.split('\n')[0]
            #TPID = re.sub('\W+', '', TPID)

        else:
            TPID = 'Invalid TPID'
        return TPID, doctype
    def search_retailer_profile(self, profie_name):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        self.show_all('//*[@id="form1:table1-nb__xc_c"]', 'all')
        profile_flag = 0
        row_index = 2

        while (profile_flag == 0):
            V_relationship_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
                row_index) + ']/td[4]'
            if so.check_exists_by_xpath(V_relationship_profile_path):
                V_relationship_profile_name = so.get_text_by_xpath(
                    V_relationship_profile_path)
                if V_relationship_profile_name == profie_name:
                    ret_row_index = row_index - 2
                    V_relationship_retailer_name_path = '//*[@id="form1:table1:' + str(
                        ret_row_index) + ':commandLink2"]'
                    V_relationship_retailer_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
                        row_index) + ']/td[6]'
                    if so.check_exists_by_xpath(
                            V_relationship_retailer_name_path):
                        V_relationship_retailer_name = so.get_text_by_xpath(
                            V_relationship_retailer_name_path)
                        ret_row_index = row_index - 2
                        so.click_element_by_xpath(
                            V_relationship_retailer_name_path)
                        so.click_element_by_xpath(
                            '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a'
                        )
                        self.lo.log_to_file("INFO", "Retailer company Found")
                    else:
                        return False
                    if so.check_exists_by_xpath(
                            V_relationship_retailer_profile_path):
                        V_relationship_retailer_profile_name = so.get_text_by_xpath(
                            V_relationship_retailer_profile_path)
                        self.lo.log_to_file("INFO", "Retailer profile found")
                    else:
                        return False
                    profile_flag = 1
                    return V_relationship_retailer_name, V_relationship_retailer_profile_name, row_index
                else:
                    row_index = row_index + 1
            else:
                self.lo.log_to_file("INFO", "Retailer profile not found")
                return False, False, False
 def get_receiver_name(self, index):
     so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
     #receiver_path = '//*[@id="form1:table1:' + str(index) + ':outputText17"]'
     receiver_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
         index) + ']/td[7]'
     if so.check_exists_by_xpath(receiver_path):
         return so.get_text_by_xpath(receiver_path)
     else:
         return False
 def get_receiver_name(self, v_index):
     selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                    self.v_driver,
                                                    self.log_file_object)
     v_receiver_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
         v_index) + ']/td[7]'
     if selenium_operation_object.check_exists_by_xpath(v_receiver_path):
         return selenium_operation_object.get_text_by_xpath(v_receiver_path)
     else:
         return False
 def get_unique_doc_types(self, v_doc_type):
     list_doc_type = []
     list_doc_type.append(v_doc_type)
     selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                    self.v_driver,
                                                    self.log_file_object)
     v_index = 2
     while (1):
         v_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
             v_index) + ']/td[8]/text()[1]'
         if selenium_operation_object.check_exists_by_xpath(v_path):
             if v_doc_type != selenium_operation_object.get_text_by_xpath(
                     v_path):
                 list_doc_type.append(
                     selenium_operation_object.get_text_by_xpath(v_path))
         else:
             break
         v_index = v_index + 1
     return list_doc_type
    def get_ticket_uid(self, index):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        #ticket_uid_path = '//*[@id="form1:table1:'+str(index)+':commandLink1"]'
        ticket_uid_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
            index) + ']/td[3]'

        if so.check_exists_by_xpath(ticket_uid_path):
            return so.get_text_by_xpath(ticket_uid_path)
        else:
            return False
コード例 #11
0
 def select_customer(self, customer_type, customer_name):
     self.lo.log_to_file(
         "INFO", "Executing TransactionTrackerOperations.select_customer()")
     so = SeleniumOperations(self.v_task_type, self.driver, self.lo)
     print("Search for: " + str(customer_name))
     time.sleep(2)
     if customer_type == "Company":
         so.send_text_by_xpath(LocalElementLocator.COMPANY_SEARCH_INPUTBOX,
                               customer_name)
     if customer_type == "Trading Partner":
         so.send_text_by_xpath(LocalElementLocator.TRADING_SEARCH_INPUTBOX,
                               customer_name)
     time.sleep(2)
     count = self.driver.find_elements_by_xpath(
         LocalElementLocator.DROP_DOWN_LIST)
     for i in range(len(count)):
         if customer_type == "Company":
             customer_from_TT = so.get_text_by_xpath(
                 LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_1 +
                 str(i) +
                 LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_2)
         if customer_type == "Trading Partner":
             customer_from_TT = so.get_text_by_xpath(
                 LocalElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_1
                 + str(i) +
                 LocalElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_2)
         if customer_name.lower() == customer_from_TT.lower():
             if customer_type == "Company":
                 so.click_element_by_xpath(
                     LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_1 +
                     str(i) +
                     LocalElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_2)
             if customer_type == "Trading Partner":
                 so.click_element_by_xpath(
                     LocalElementLocator.
                     CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_1 + str(i) +
                     LocalElementLocator.
                     CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_2)
             break
     time.sleep(2)
    def 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 select_customer(self, v_customer_type, v_customer_name):

        self.log.log_to_file(
            self, "INFO",
            "Executing TransactionTrackerOperations.select_customer()")
        selenium_operations_object = SeleniumOperations(self.driver, self.log)
        time.sleep(2)
        if v_customer_type == "Company":
            selenium_operations_object.send_text_by_xpath(
                ElementLocator.COMPANY_SEARCH_INPUTBOX, v_customer_name)
        if v_customer_type == "Trading Partner":
            selenium_operations_object.send_text_by_xpath(
                ElementLocator.TRADING_SEARCH_INPUTBOX, v_customer_name)
        time.sleep(2)
        count = self.driver.find_elements_by_xpath(
            ElementLocator.DROP_DOWN_LIST)
        for i in range(len(count)):
            if v_customer_type == "Company":
                v_customer_from_TT = selenium_operations_object.get_text_by_xpath(
                    ElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_1 + str(i) +
                    ElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_2)
            if v_customer_type == "Trading Partner":
                v_customer_from_TT = selenium_operations_object.get_text_by_xpath(
                    ElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_1 +
                    str(i) +
                    ElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_2)
            if v_customer_name.lower() == v_customer_from_TT.lower():
                if v_customer_type == "Company":
                    selenium_operations_object.click_element_by_xpath(
                        ElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_1 +
                        str(i) + ElementLocator.CUSTOMER_FROM_TT_FOR_COMPANY_2)
                if v_customer_type == "Trading Partner":
                    selenium_operations_object.click_element_by_xpath(
                        ElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_1 +
                        str(i) +
                        ElementLocator.CUSTOMER_FROM_TT_FOR_TRADING_PARTNER_2)
                break
        time.sleep(2)
 def get_info_from_description(self, v_index):
     selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                    self.v_driver,
                                                    self.log_file_object)
     v_path = '//*[@id="form1:table1:' + str(50 +
                                             v_index) + ':commandLink1"]'
     if selenium_operation_object.check_exists_by_xpath(v_path) == True:
         v_path = v_path
     else:
         v_path = '//*[@id="form1:table1:' + str(
             v_index) + ':commandLink1"]'
     selenium_operation_object.click_element_by_xpath(v_path)
     v_doctype = selenium_operation_object.get_text_by_xpath(
         LocalElementLocator.EH_DOCTYPE_INFO_XPATH)
     v_doctype = v_doctype.split(' ')[0]
     v_TPID = selenium_operation_object.get_text_by_xpath(
         LocalElementLocator.EH_DESCRIPTION_INFO_XPATH)
     if 'Document:' in v_TPID:
         v_TPID = v_TPID.split('Document: ')[1]
         v_TPID = v_TPID.split('\n')[0]
     else:
         v_TPID = 'Invalid v_TPID'
     return v_TPID, v_doctype
 def search_by_parcel_id_and_download(self, parcel_id):
     self.create_file_save_path("supplier", "retailer")
     print("search_by_parcel_id_and_download method")
     self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK +
                     parcel_id)
     so = SeleniumOperations(self.v_task_type, self.driver, self.lo)
     time.sleep(1)
     self.driver.switch_to.frame(0)
     time.sleep(1)
     PARCEL_FIRST_STAGE_ID = so.get_text_by_xpath(
         LocalElementLocator.PARCEL_FIRST_STAGE_ID)
     self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK +
                     parcel_id + "/parcel/" + PARCEL_FIRST_STAGE_ID)
     time.sleep(2)
     self.driver.switch_to.frame(0)
     so.click_element_by_xpath(LocalElementLocator.DOWNLOAD_LOGO_BUTTON)
     time.sleep(3)
 def get_parcel(self, rows):
     row = int(rows)
     selenium_operations_object = SeleniumOperations(self.driver, self.log)
     file_broker = selenium_operations_object.get_text_by_xpath(
         ElementLocator.file_broker_xpath)
     print(file_broker)
     ExcelOperations.set_value_to_cell(ElementLocator.Edi_Parcel_file, row,
                                       1, file_broker)
     selenium_operations_object.click_element_by_xpath(
         f'//*[@id="parcel-{str(file_broker)}"]/div/div/div[2]/div/a/div/div'
     )
     time.sleep(3)
     selenium_operations_object.click_element_by_xpath(
         ElementLocator.Download_xpath)
     selenium_operations_object.click_element_by_xpath(
         ElementLocator.BackToTransaction)
     selenium_operations_object.click_element_by_xpath(
         ElementLocator.BackToSearch)
コード例 #17
0
    def get_CM_parcels(self, input_sheet, row):
        self.lo.log_to_file(
            "INFO", "Executing TransactionTrackerOperations.get_CM_parcels()")
        whilevalue = 1
        while (whilevalue):
            try:
                so = SeleniumOperations(self.v_task_type, self.driver, self.lo)
                eo = ExcelOperations(self.v_task_type, input_sheet)
                error_parcel_comment = ''
                without_error_parcel_comment = ''
                without_error_parcel_count = 0
                error_parcel_count = 0
                j = 1
                while (1):
                    i = 1
                    parcel_id = self.driver.find_element_by_xpath(
                        LocalElementLocator.PARCEL_ID_1 + str(i) +
                        LocalElementLocator.PARCEL_ID_2)
                    while (parcel_id.is_enabled()):
                        try:
                            parcel_id1 = self.driver.find_element_by_xpath(
                                LocalElementLocator.PARCEL_ID_1 + str(i) +
                                LocalElementLocator.PARCEL_ID_2).text
                        except NoSuchElementException:
                            break
                        status = so.get_text_by_xpath(
                            LocalElementLocator.STATUS_1 + str(i) +
                            LocalElementLocator.STATUS_2)
                        document_id = so.get_text_by_xpath(
                            LocalElementLocator.DOCUMENT_ID_1 + str(i) +
                            LocalElementLocator.DOCUMENT_ID_2)
                        parcel_date_time = so.get_text_by_xpath(
                            LocalElementLocator.PARCEL_DATE_TIME_1 + str(i) +
                            LocalElementLocator.PARCEL_DATE_TIME_2)
                        if "CM" in document_id:
                            if "Completed w/o Errors" in status:
                                without_error_parcel_count = without_error_parcel_count + 1
                                without_error_parcel_comment = without_error_parcel_comment + str(
                                    without_error_parcel_count
                                ) + ") Parcel ID: " + str(
                                    parcel_id1) + " (Document ID: " + str(
                                        document_id
                                    ) + ") with status: " + str(
                                        status
                                    ) + " [" + parcel_date_time + "]" + "\n"
                            if "Completed w/Errors" in status:
                                error_parcel_count = error_parcel_count + 1
                                error_parcel_comment = error_parcel_comment + str(
                                    error_parcel_count
                                ) + ") Parcel ID: " + str(
                                    parcel_id1) + " (Document ID: " + str(
                                        document_id
                                    ) + ") with status: " + str(
                                        status
                                    ) + " [" + parcel_date_time + "]" + "\n"
                        i = i + 1
                        j = j + 1
                        try:
                            parcel_id = self.driver.find_element_by_xpath(
                                LocalElementLocator.PARCEL_ID_1 + str(i) +
                                LocalElementLocator.PARCEL_ID_2)
                        except NoSuchElementException:
                            self.lo.log_to_file(
                                "INFO",
                                "NoSuchElementException in TransactionTrackerOperations.get_CM_parcels()"
                            )
                    next_button = self.driver.find_element_by_xpath(
                        LocalElementLocator.NEXT_SEARCH_BTN)

                    if (next_button.is_enabled()):
                        next_button = self.driver.find_element_by_xpath(
                            LocalElementLocator.NEXT_SEARCH_BTN)
                        next_button.click()
                        time.sleep(2)

                    else:
                        eo.set_value(row, 6, without_error_parcel_count)
                        eo.set_value(row, 7, without_error_parcel_comment)
                        eo.set_value(row, 8, error_parcel_comment)
                        self.driver.get(
                            LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK)
                        break
            except NoSuchElementException:
                break
        try:
            parcel_id1 = self.driver.find_element_by_xpath(
                LocalElementLocator.LAST_PARCEL_ID).text
        except NoSuchElementException:
            self.driver.get(LocalElementLocator.TRANSACTION_TRACKER_PROD_LINK)
            whilevalue == 0
            time.sleep(2)
コード例 #18
0
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 Supplier_Setup_Check(self, v_supplier, v_retailer, v_document_type,
                             v_erp, current_row):
        v_document_type_1 = str(v_document_type)
        v_document_type_2 = '875'
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                      self.lo)
        selenium_operations = SeleniumOperations(self.v_task_type,
                                                 self.v_driver, self.lo)

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

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

        selenium_operations.click_element_by_xpath(AppConstants.DC4_TAB)

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

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

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

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

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

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

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

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

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

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

                    time.sleep(3)

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

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

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

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

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

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

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

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

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

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

                    if doc_type == v_document_type_1:
                        if service != 'DoNotRoute' and service != 'WEBtoService':
                            print("850 capability exist")
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:table1:0:table2:' +
                                str(counter - 2) + ':tableSelectMany1"]')
                            print("Capability selected")
                            selenium_operations.click_element_by_xpath(
                                '//*[@id="form1:table1:0:table2:disableCapability"]/img'
                            )
                            time.sleep(10)
                            break
                    counter = counter + 1
                path = 'Close'
    def retailer_setup_check(self, v_supplier, v_retailer, v_document_type,
                             current_row):
        v_document_type_1 = str(v_document_type)
        v_document_type_2 = '875'
        self.lo.log_to_file("INFO", "Login in to DC4 Pre_Prod")
        lg = Login(self.v_task_type, self.v_driver, self.v_input_wb, self.lo)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)

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

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

        so.click_element_by_xpath(AppConstants.DC4_TAB)

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

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

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

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

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

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

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

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

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

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

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

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

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

        time.sleep(10)
    def 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 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 check_supplier_profile(self, profie_name, v_doc, row_index):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        self.show_all('//*[@id="form1:table1-nb__xc_c"]', 'all')
        V_relationship_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
            row_index) + ']/td[4]'
        if so.check_exists_by_xpath(V_relationship_profile_path):
            v_supplier_profile_path = '//*[@id="form1:table1:' + str(
                row_index - 2) + ':commandLink3"]'
            so.click_element_by_xpath(v_supplier_profile_path)
            self.lo.log_to_file("INFO", "In supplier profile")
            so.click_element_by_xpath(
                '//*[@id="form1:table1"]/table[2]/tbody/tr[2]/td[2]/div/a[2]')
            #print('Click on show')
            doc_flag = 0
            map_row_index = 2
            #print(doc_flag)
            while (doc_flag == 0):
                #print('Entry in while')
                v_supplier_profile_doc_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                    map_row_index) + ']/td[3]'
                if so.check_exists_by_xpath(v_supplier_profile_doc_path):
                    v_supplier_profile_doc = so.get_text_by_xpath(
                        v_supplier_profile_doc_path)
                    if v_supplier_profile_doc == v_doc:
                        v_supplier_doc_status_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                            map_row_index) + ']/td[9]'
                        if so.check_exists_by_xpath(
                                v_supplier_doc_status_path):
                            v_supplier_doc_status = so.get_text_by_xpath(
                                v_supplier_doc_status_path)
                            if v_supplier_doc_status == 'Active':
                                v_supplier_doc_service_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                    map_row_index) + ']/td[10]'
                                if so.check_exists_by_xpath(
                                        v_supplier_doc_service_path):
                                    v_supplier_doc_service = so.get_text_by_xpath(
                                        v_supplier_doc_service_path)
                                    if v_supplier_doc_service == 'FItoService':
                                        self.lo.log_to_file(
                                            "INFO",
                                            "Doc found, status is active, service is correct"
                                        )
                                        v_supplier_profile_map_version = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                            map_row_index) + ']/td[6]'
                                        if so.check_exists_by_xpath(
                                                v_supplier_profile_map_version
                                        ):
                                            v_supplier_profile_map_version_display = so.get_text_by_xpath(
                                                v_supplier_profile_map_version)
                                            v_supplier_profile_map_name = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                map_row_index) + ']/td[4]'
                                            if so.check_exists_by_xpath(
                                                    v_supplier_profile_map_name
                                            ):
                                                v_supplier_profile_map_name_display = so.get_text_by_xpath(
                                                    v_supplier_profile_map_name
                                                )
                                            else:
                                                return False
                                        else:
                                            return False
                                        return v_supplier_profile_map_version_display, v_supplier_profile_map_name_display, map_row_index
                                        doc_flag = 1
                                    else:
                                        map_row_index = map_row_index + 1
                                        print('Service not FItoService')
                                else:
                                    self.lo.log_to_file(
                                        "INFO",
                                        "No services present in supplier profile"
                                    )
                                    return False
                            else:
                                map_row_index = map_row_index + 1
                        else:
                            return False
                    else:
                        map_row_index = map_row_index + 1
                else:
                    self.lo.log_to_file("INFO", "No docs added")
                    doc_flag = 1
                    V_new_map_row_index = self.add_capbility(
                        v_doc, profie_name, row_index)
                    return v_supplier_profile_map_version_display, v_supplier_profile_map_name_display, V_new_map_row_index

                profile_flag = 1
        else:
            print('Relationship not found')
            return False
    def add_capbility(self, v_doc, profie_name, row_index):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        v_add_capability_path = '//*[@id="form1:table1:0:table2:addExistingCapability"]'

        print(self.v_driver.current_window_handle)
        if so.check_exists_by_xpath(v_add_capability_path):
            so.click_element_by_xpath(v_add_capability_path)
            time.sleep(1)
            self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
            time.sleep(1)
            self.v_driver.switch_to.frame(0)
            time.sleep(1)
            self.lo.log_to_file("INFO", "Adding capability")
            v_search_existing_path = '//*[@id="form1:showDetailHeader1__xc_"]'
            if so.check_exists_by_xpath(v_search_existing_path):
                so.click_element_by_xpath(v_search_existing_path)
                so.send_text_by_xpath('//*[@id="form1:inputText3"]',
                                      'FItoService')
                so.send_text_by_xpath('//*[@id="form1:inputText5"]', '850')
                self.show_all('//*[@id="form1:showOneChoice2"]', '0')
                self.lo.log_to_file("INFO", "Data sent")
                so.click_element_by_xpath('//*[@id="form1:commandButton2"]')
                self.lo.log_to_file("INFO", "Clicked on search")
                capability_row_index = 0
                capability_flag = 0
                capability_2013 = 'Standard NetSuite Sales Order RSX Order v7.4 Governance (LEGACY SIP)'
                capability_2015 = 'Standard NetSuite Sales Order RSX Order v7.4 Governance (LEGACY SIP) | v3'
                capability_2017_1 = 'Standard NetSuite Sales Order RSX Order v7.7 Governance_v1'
                capability_2017 = 'Standard NetSuite Sales Order RSX Order v7.4 (2017)'
                while (capability_flag == 0):
                    self.lo.log_to_file("INFO", "Inside while")
                    v_choose_capbability_path = '// *[ @ id = "form1:table1:' + str(
                        capability_row_index) + ':outputText6"]'
                    if so.check_exists_by_xpath(v_choose_capbability_path):
                        self.lo.log_to_file("INFO", "Inside If1")
                        v_capability_name = so.get_text_by_xpath(
                            v_choose_capbability_path)
                        print(v_capability_name)
                        if (v_capability_name == capability_2013
                                or v_capability_name == capability_2015
                                or v_capability_name == capability_2017
                                or v_capability_name == capability_2017_1):
                            self.lo.log_to_file("INFO", "Inside If2")
                            so.click_element_by_xpath(
                                '//*[@id="form1:table1:' +
                                str(capability_row_index) +
                                ':tableSelectMany1"]')
                            self.lo.log_to_file("INFO", "Tick checkbox")
                            so.click_element_by_xpath(
                                '//*[@id="form1:table1:commandButton1"]')
                            self.lo.log_to_file("INFO", "Click choose")
                            capability_flag = 1
                            capability_row_index = capability_row_index + 1
                            self.lo.log_to_file("INFO", "Row++")
                            doc_flag = 0
                            map_row_index = 2
                            while (doc_flag == 0):
                                v_supplier_profile_doc_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                    map_row_index) + ']/td[3]'
                                if so.check_exists_by_xpath(
                                        v_supplier_profile_doc_path):
                                    v_supplier_profile_doc = so.get_text_by_xpath(
                                        v_supplier_profile_doc_path)
                                    if v_supplier_profile_doc == v_doc:
                                        v_supplier_doc_status_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                            map_row_index) + ']/td[9]'
                                        if so.check_exists_by_xpath(
                                                v_supplier_doc_status_path):
                                            v_supplier_doc_status = so.get_text_by_xpath(
                                                v_supplier_doc_status_path)
                                            if v_supplier_doc_status == 'Active':
                                                v_supplier_doc_service_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                    map_row_index) + ']/td[10]'
                                                if so.check_exists_by_xpath(
                                                        v_supplier_doc_service_path
                                                ):
                                                    v_supplier_doc_service = so.get_text_by_xpath(
                                                        v_supplier_doc_service_path
                                                    )
                                                    if v_supplier_doc_service == 'FItoService':
                                                        self.lo.log_to_file(
                                                            "INFO",
                                                            "Doc found, status is active, service is correct"
                                                        )
                                                        v_supplier_profile_map_version = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                            map_row_index
                                                        ) + ']/td[6]'
                                                        if so.check_exists_by_xpath(
                                                                v_supplier_profile_map_version
                                                        ):
                                                            v_supplier_profile_map_version_display = so.get_text_by_xpath(
                                                                v_supplier_profile_map_version
                                                            )
                                                            v_supplier_profile_map_name = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                                map_row_index
                                                            ) + ']/td[4]'
                                                            if so.check_exists_by_xpath(
                                                                    v_supplier_profile_map_name
                                                            ):
                                                                v_supplier_profile_map_name_display = so.get_text_by_xpath(
                                                                    v_supplier_profile_map_name
                                                                )
                                                            else:
                                                                return False
                                                        else:
                                                            return False
                                                        return map_row_index
                                                        doc_flag = 1
                                                    else:
                                                        map_row_index = map_row_index + 1
                                                        print(
                                                            'Service not FItoService'
                                                        )
                                                else:
                                                    self.lo.log_to_file(
                                                        "INFO",
                                                        "No services present in supplier profile"
                                                    )
                                                    return False
                                            else:
                                                map_row_index = map_row_index + 1
                                        else:
                                            return False
                                    else:
                                        map_row_index = map_row_index + 1
                        else:
                            self.lo.log_to_file("INFO", "Inside else2")
                            capability_row_index = capability_row_index + 1
                            return False
                    else:
                        return False
    def retailer_v_check(self, v_supplier, v_retailer, v_document_type,
                         current_row):
        v_document_type_1 = str(v_document_type)
        v_document_type_2 = '875'
        self.lo.log_to_file("INFO", "Login in to DC4 Prod")
        login = Login(self.v_task_type, self.v_driver, self.v_input_wb,
                      self.lo)
        selenium_operations = SeleniumOperations(self.v_task_type,
                                                 self.v_driver, self.lo)

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

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

        selenium_operations.click_element_by_xpath(AppConstants.DC4_TAB)

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

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

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

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

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

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

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

                    retailer_version = selenium_operations.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                        + str(counter) + ']/td[8]')
                    capability_name = selenium_operations.get_text_by_xpath(
                        '//*[@id="form1:table1:0:table2:' + str(counter) +
                        ':outputText14"]')
                    print(retailer_version)
                    print(capability_name)

                    if retailer_version == " ":
                        retailer_version = self.retailer_ver_check(
                            doc_type, capability_name)
                        excel_operations.set_value(current_row, 10,
                                                   retailer_version)
                        retailer_capability_version = selenium_operations.get_text_by_xpath(
                            '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                            + str(counter) + ']/td[6]')
                        excel_operations.set_value(
                            current_row, 11, retailer_capability_version)
                        self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                        break
                    else:
                        excel_operations.set_value(current_row, 10,
                                                   retailer_version)
                        retailer_capability_version = selenium_operations.get_text_by_xpath(
                            '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr['
                            + str(counter) + ']/td[6]')
                        excel_operations.set_value(
                            current_row, 11, retailer_capability_version)
                        self.v_input_wb.save(AppConstants.INPUT_FILE_PATH)
                        break

                elif service == 'DoNotRoute':
                    print("850 capability is not available")
    def search_retailer_map(self, document, retailer_profile_name,
                            supplier_profile_name, supplier_name):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        input_text = '//*[@id="form1:inputText1"]'
        so.send_text_by_xpath(input_text, supplier_name)
        so.click_element_by_xpath('//*[@id="form1:commandButton1"]')
        profile_flag = 0
        row_index = 2
        while (profile_flag == 0):
            V_retailer_relationship_profile_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[' + str(
                row_index) + ']/td[6]'
            if so.check_exists_by_xpath(V_retailer_relationship_profile_path):
                V_relationship_retailer_profile_name = so.get_text_by_xpath(
                    V_retailer_relationship_profile_path)
                self.lo.log_to_file("INFO",
                                    "Relationship found at retailer side")
                if V_relationship_retailer_profile_name == supplier_profile_name:
                    V_relationship_retailer_profile_path = '// *[ @ id = "form1:table1:' + str(
                        row_index - 2) + ':commandLink3"]'
                    #so.click_element_by_xpath(V_relationship_retailer_profile_path)
                    if so.check_exists_by_xpath(
                            V_relationship_retailer_profile_path):
                        so.click_element_by_xpath(
                            V_relationship_retailer_profile_path)
                        self.lo.log_to_file("INFO", "In retailer profile")
                        V_retailer_profile_show_path = '//*[@id="form1:table1"]/table[2]/tbody/tr[2]/td[2]/div/a[2]'
                        if so.check_exists_by_xpath(
                                V_retailer_profile_show_path):
                            so.click_element_by_xpath(
                                '//*[@id="form1:table1"]/table[2]/tbody/tr[2]/td[2]/div/a[2]'
                            )
                            map_flag = 0
                            map_row_index = 2
                            while (map_flag == 0):
                                V_retailer_doc_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                    map_row_index) + ']/td[3]'
                                if so.check_exists_by_xpath(
                                        V_retailer_doc_path):
                                    V_retailer_document = so.get_text_by_xpath(
                                        V_retailer_doc_path)
                                    if V_retailer_document == document:
                                        self.lo.log_to_file(
                                            "INFO", V_retailer_document)
                                        print("Retailer Document = " +
                                              V_retailer_document)
                                        self.lo.log_to_file(
                                            "INFO", "Doc Found")
                                        V_retailer_doc_status_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                            map_row_index) + ']/td[9]'
                                        if so.check_exists_by_xpath(
                                                V_retailer_doc_status_path):
                                            V_reatiler_doc_status = so.get_text_by_xpath(
                                                V_retailer_doc_status_path)
                                            if V_reatiler_doc_status == 'Active':
                                                self.lo.log_to_file(
                                                    "INFO", "Status is Active")
                                                print(
                                                    "Retailer Dcoument Status = "
                                                    + V_reatiler_doc_status)
                                                V_retailer_doc_service_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                    map_row_index) + ']/td[10]'
                                                if so.check_exists_by_xpath(
                                                        V_retailer_doc_service_path
                                                ):
                                                    V_reatiler_doc_service = so.get_text_by_xpath(
                                                        V_retailer_doc_service_path
                                                    )
                                                    if V_reatiler_doc_service == 'CommerceEDIfromService' or V_reatiler_doc_service == 'CommerceEDItoService' or V_reatiler_doc_service == 'B2BfromService' or V_reatiler_doc_service == 'B2BtoService':
                                                        self.lo.log_to_file(
                                                            "INFO",
                                                            "Services are correct"
                                                        )
                                                        print(
                                                            "Retailer doc service = "
                                                            +
                                                            V_reatiler_doc_service
                                                        )
                                                        if (document == '850'):
                                                            V_retailer_doc_version_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                                map_row_index
                                                            ) + ']/td[8]'
                                                            if so.check_exists_by_xpath(
                                                                    V_retailer_doc_version_path
                                                            ):
                                                                V_retailer_doc_version = so.get_text_by_xpath(
                                                                    V_retailer_doc_version_path
                                                                )
                                                                self.lo.log_to_file(
                                                                    "INFO",
                                                                    "Retailer version found"
                                                                )
                                                                print(
                                                                    "Retailer map version for 850 =  "
                                                                    +
                                                                    V_retailer_doc_version
                                                                )
                                                                so.click_element_by_xpath(
                                                                    '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a'
                                                                )
                                                                input_text = '//*[@id="form1:inputText1"]'
                                                                so.send_text_by_xpath(
                                                                    input_text,
                                                                    supplier_name
                                                                )
                                                                so.click_element_by_xpath(
                                                                    '//*[@id="form1:commandButton1"]'
                                                                )
                                                                supp_row_index = row_index - 2
                                                                V_relationship_supplier_name_path = '//*[@id="form1:table1:' + str(
                                                                    supp_row_index
                                                                ) + ':commandLink2"]'
                                                                so.click_element_by_xpath(
                                                                    V_relationship_supplier_name_path
                                                                )
                                                                so.click_element_by_xpath(
                                                                    '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a'
                                                                )
                                                                return V_retailer_document, V_reatiler_doc_status, V_reatiler_doc_service, V_retailer_doc_version

                                                            else:
                                                                self.lo.log_to_file(
                                                                    "INFO",
                                                                    "Versions not present"
                                                                )
                                                                return False
                                                        else:
                                                            V_retailer_doc_version_path = '//*[@id="form1:table1:0:table2"]/table/tbody/tr[3]/td/table/tbody/tr[' + str(
                                                                map_row_index
                                                            ) + ']/td[7]'
                                                            if so.check_exists_by_xpath(
                                                                    V_retailer_doc_version_path
                                                            ):
                                                                V_retailer_doc_version = so.get_text_by_xpath(
                                                                    V_retailer_doc_version_path
                                                                )
                                                                self.lo.log_to_file(
                                                                    "INFO",
                                                                    "Retailer version found"
                                                                )
                                                                print(
                                                                    "Retailer map version for"
                                                                    +
                                                                    document +
                                                                    " = " +
                                                                    V_retailer_doc_version
                                                                )
                                                                supp_row_index = row_index - 2
                                                                V_relationship_supplier_name_path = '//*[@id="form1:table1:' + str(
                                                                    supp_row_index
                                                                ) + ':commandLink2"]'
                                                                so.click_element_by_xpath(
                                                                    V_relationship_supplier_name_path
                                                                )
                                                                so.click_element_by_xpath(
                                                                    '//*[@id="form1:panelPage1"]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a'
                                                                )
                                                                return V_retailer_document, V_reatiler_doc_status, V_reatiler_doc_service, V_retailer_doc_version
                                                            else:
                                                                self.lo.log_to_file(
                                                                    "INFO",
                                                                    "Versions not present"
                                                                )
                                                                return False
                                                        map_flag = 1
                                                    else:
                                                        map_row_index = map_row_index + 1
                                                else:
                                                    self.lo.log_to_file(
                                                        "INFO",
                                                        "No services present in retailer profile"
                                                    )
                                                    return False
                                            else:
                                                map_row_index = map_row_index + 1
                                        else:
                                            return False
                                    else:
                                        map_row_index = map_row_index + 1
                                else:
                                    self.lo.log_to_file(
                                        "INFO",
                                        "No documents present in retailer profile"
                                    )
                                    map_flag = 1
                                    return False
                        else:
                            return False
                    else:
                        return False
                    profile_flag = 1
                else:
                    row_index = row_index + 1
            else:
                return false
コード例 #27
0
    def process(self, path):
        tto = TransactionTrackerOperations
        print("in task filter method")
        #rf = ReportFileUtility(self.v_task_type)
        # self.v_input_sheet = self.v_input_wb.get_sheet_names("InputData")
        print("input data sheet selected")
        row_count = self.v_data_sheet.max_row
        print(row_count)

        eo = ExcelOperations(self.v_task_type, self.v_data_sheet)
        supplier_name = self.v_data_sheet.cell(row=2, column=1).value
        retailer_name = self.v_data_sheet.cell(row=2, column=2).value
        doc_type = self.v_data_sheet.cell(row=2, column=3).value
        date = self.v_data_sheet.cell(row=2, column=4).value
        ptfu = Process_Test_Files_Utility(self.v_task_type, self.lo,
                                          self.v_driver, self.v_input_wb)
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        time.sleep(3)
        self.v_driver.switch_to.frame(0)
        time.sleep(2)
        ptfu.search_by_names(supplier_name, retailer_name, doc_type, date)
        # ptfu.search_by_names("CAULIPOWER","Amazon.com","850","09/20/2018")
        ptfu.get_five_parcels()

        path = '../Applications/Workflows/ProcessTestFiles/AppResources/parcelIDsforSearch.txt'
        #path = 'D:\parcelIDsforSearch.txt'

        with open(path) as f:
            parcel_id_for_vali_and_autoit = ''
            for line in f:
                parcel = line.replace('\n', '')
                print("Download Parcel ID : " + str(parcel))
                #self.v_driver.switch_to.frame(0)
                ptfu.search_by_parcel_id(str(parcel))

                #generated_parcel_id = ptfu.save_page_source_and_generate_parcel_id_from_dom()

                #xpath_for_click = ptfu.generate_xpath_for_TT(generated_parcel_id)
                parcel_id_for_validation_and_autoit = so.get_text_by_xpath(
                    "//aside[text()='Transformations']/following::a[@title='View']/div[1]/following::span[2]"
                )
                print("downloaded parcel ID :" +
                      str(parcel_id_for_validation_and_autoit))
                so.click_element_by_xpath(
                    "//aside[text()='Transformations']/following::a[@title='View'][1]/div/div"
                )

                parcel_id_for_vali_and_autoit = parcel_id_for_vali_and_autoit + parcel_id_for_validation_and_autoit + "\n"
                print(parcel_id_for_validation_and_autoit)

                element = WebDriverWait(self.v_driver, 20).until(
                    EC.element_to_be_clickable((
                        By.XPATH,
                        "html/body/div[1]/section/section/div/div/section/div/div[3]/div[1]/div/div[1]/div/div/div/a/i"
                    )))
                element.click()
                time.sleep(2)
                # shutil.copy(downloaded_parcel_path, copy_to_path)

                if 'str' in line:
                    #time.sleep(4)
                    break

            file = open(
                "../Applications/Workflows/ProcessTestFiles/AppResources/parcel_id_for_validation_and_autoit.txt",
                "w+")
            file.write(parcel_id_for_vali_and_autoit)
コード例 #28
0
    def add_new_capability(self):
        so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
        po_service_uid = "1007"
        return_documents_service_uid = "1006"

        #capabilities_sheet=so.call_excel_sheet('Capabilities')
        capabilities_sheet = self.v_input_wb.get_sheet_by_name('Capabilities')

        #Loop to Iterate through the Capabilities Excel Sheet
        #for row_counter in range (1,(capabilities_sheet.max_row)+1):
        for row_counter in range(1, 2):
            for col_counter in range(2, (capabilities_sheet.max_column) + 1):
                so.click_element_by_xpath(
                    LocalElementLocator.DC4_PREPROD_CAPABILITY_TAB)
                so.click_element_by_xpath(
                    LocalElementLocator.DC4_PREPROD_ADD_CAPABILITY_BUTTON)
                sheet_value = capabilities_sheet.cell(row=row_counter,
                                                      column=col_counter).value

                #Switch to Create Capability Child Window;
                so.switch_child_window_handle()
                so.switch_to_default_frame()
                time.sleep(2)
                #Click on the Search Service Torch; Switch to the Search Service Child Window
                so.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_CREATE_CAPABILITY_SERVICE_TORCH)
                time.sleep(2)
                so.switch_child_window_handle()
                so.switch_to_default_frame()

                #If Condition to validate serviceUID input based on Inbound/Outbound Documents
                if str(sheet_value) == "850" or str(
                        sheet_value) == "850 Outbound":
                    so.send_text_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_CREATE_CAPABILITY_SERVICE_SERVICE_UID,
                        po_service_uid)
                else:
                    so.send_text_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_CREATE_CAPABILITY_SERVICE_SERVICE_UID,
                        return_documents_service_uid)
                so.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_SEARCH_SERVICES_SEARCH_BUTTON)
                so.get_text_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID)
                #print(so.get_text_by_xpath(LocalElementLocator.DC4_PREPROD_CREATE_CAPABILITY_SERVICE_SERVICE_UID))
                #print(so.get_text_by_xpath(LocalElementLocator.DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID))
                sheet_value_service_uid_validation = str(
                    capabilities_sheet.cell(row=row_counter + 1,
                                            column=col_counter).value)
                print("Adding Capability")
                print(
                    so.get_text_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID))

                #Validating ServiceUID Input with the SearchResult & Clicking Choose
                if sheet_value_service_uid_validation == str(
                        so.get_text_by_xpath(
                            LocalElementLocator.
                            DC4_PREPROD_SEARCH_SERVICES_SEARCH_RESULT_SERVICE_UID
                        )):
                    so.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_SEARCH_SERVICES_CHOOSE_BUTTON)
                else:
                    print("Service Validation Failed")
                    return
                time.sleep(1)
                so.switch_child_window_handle()
                so.switch_to_default_frame()
                so.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_CREATE_CAPABILITY_CAPABILITY_TORCH)
                time.sleep(1)
                so.switch_child_window_handle()
                so.switch_to_default_frame()
                sheet_value_capability_name = str(
                    capabilities_sheet.cell(row=row_counter + 2,
                                            column=col_counter).value)
                print(sheet_value_capability_name)
                so.send_text_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_DATATYPE_NAME,
                    sheet_value_capability_name)
                so.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_SEARCH_BUTTON
                )
                datatype_name_result_table_count = len(
                    so.list_elements_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_DATATYPE_NAME_RESULT_TABLE
                    ))
                #print(datatype_name_result_table_count)
                if datatype_name_result_table_count > 2:
                    self.v_driver.close()
                    so.switch_child_window_handle()
                    self.v_driver.close()
                    return
                else:
                    so.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_SEARCHED_CAPABILITY_CHECKBOX
                    )
                    so.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_PREPROD_CREATE_CAPABILITY_SEARCH_DATATYPES_CHOOSE_BUTTON
                    )
                time.sleep(1)
                so.switch_child_window_handle()
                so.switch_to_default_frame()
                sheet_value_capability_notes = str(
                    capabilities_sheet.cell(row=row_counter + 3,
                                            column=col_counter).value)
                so.send_text_by_xpath(
                    LocalElementLocator.DC4_PREPROD_CREATE_CAPABILITY_NOTES,
                    sheet_value_capability_notes)
                so.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_PREPROD_CREATE_CAPABILITY_SUBMIT_BUTTON)
                so.switch_parent_window_handle()
                #so.switch_to_default_frame()
            print("Great! New Capabilities have been Added :) ")
    def add_web_company(self, sender, v_status):
        flag = 0
        selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                       self.v_driver,
                                                       self.log_file_object)
        time.sleep(2)
        default_handle = self.v_driver.current_window_handle
        self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
        time.sleep(2)
        self.v_driver.switch_to.frame(0)
        time.sleep(2)
        #Check in library for web company uid
        web_uid = self.error_hospital_machine_learning_object.get_supplier_info(
            sender)
        if web_uid != False:
            selenium_operation_object.send_text_by_id(
                LocalElementLocator.DC4_ADD_TRADING_PARTNERSHIP_COMPANYUID_ID,
                web_uid)
            selenium_operation_object.click_element_by_xpath(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON)
            time.sleep(3)
            if selenium_operation_object.check_exists_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY):
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
                flag = 1
                v_status = v_status + '\nFound web company from previous results'
                self.v_driver.switch_to.window(self.v_driver.window_handles[0])
                time.sleep(2)
                return v_status, flag

        selenium_operation_object.send_text_by_id(
            LocalElementLocator.
            DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_ID, sender)
        selenium_operation_object.click_element_by_xpath(
            LocalElementLocator.
            DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON)
        time.sleep(2)
        if selenium_operation_object.check_exists_by_xpath(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY):
            i = 2
            web_id = ' '
            path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                i) + ']/td[2]'
            while (1):
                if selenium_operation_object.check_exists_by_xpath(path):
                    temp_web_id = selenium_operation_object.get_text_by_xpath(
                        path)
                    if temp_web_id != web_id and flag == 0:
                        web_id = temp_web_id
                        flag = 1
                    elif temp_web_id != web_id:
                        flag = 2
                        break
                else:
                    break
                i = i + 1
                path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                    i) + ']/td[2]'
            if flag == 2:
                v_status = v_status + '\nMultiple web companies'
            else:
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
        else:
            sender = '%' + sender.replace(' ', '%') + '%'
            selenium_operation_object.send_text_by_id(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_ID, sender)
            selenium_operation_object.click_element_by_xpath(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON)
            time.sleep(2)
            if selenium_operation_object.check_exists_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY):
                i = 2
                web_id = ' '
                path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                    i) + ']/td[2]'
                while (1):
                    if selenium_operation_object.check_exists_by_xpath(path):
                        temp_web_id = selenium_operation_object.get_text_by_xpath(
                            path)
                        if temp_web_id != web_id and flag == 0:
                            web_id = temp_web_id
                            flag = 1
                        elif temp_web_id != web_id:
                            flag = 2
                            break
                    else:
                        break
                    i = i + 1
                    path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                        i) + ']/td[2]'
                if flag == 2:
                    v_status = v_status + '\nMultiple web companies'
                else:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
            else:
                v_status = v_status + "No web company found"

        if flag == 0 or flag == 2:

            if easygui.ynbox(
                    "Deadpool is unable to find web company. Do you want to add it manually?\n\nNote:- Add correct web comapany manually then select 'Yes' else 'No'"
            ):
                flag = 1
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
            else:
                handles = list(self.v_driver.window_handles)
                handles.remove(default_handle)
                self.v_driver.close()
                time.sleep(2)

                self.v_driver.switch_to.window(default_handle)

        if flag == 1:
            self.v_driver.switch_to.window(self.v_driver.window_handles[0])
        time.sleep(2)
        return v_status, flag
コード例 #30
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