def test_standard_reports(self): reports_name_cases = SC.read_file_report_names_as_list('standard') report_names = [] report_case_num = [] for i in reports_name_cases: report_names.append(reports_name_cases[i]) report_case_num.append(i) driver = self.driver SC.login_(driver) reports.reports.go_to_op_enterprise(driver) reports.reports.go_to_op_standard(driver) for i in range(0, report_names.__len__() - 1): report_name = report_names[i] self.driver.save_screenshot('../pictures/' + report_name + '.png') reports.reports.find_report(driver, report_name) reports.reports.go_to_report_CS(driver, report_name) reports.reports.add_filters_besides_default_ones(driver) reports.reports.view_report(driver) reports.reports.switch_to_report_view_page(driver, report_name, report_case_num[i]) reports.reports.close_report_view_window(driver) reports.reports.close_report_cs_page(driver)
def switch_to_report_view_page(driver, report_name, report_case): view_report_window = driver.window_handles[1] driver.switch_to.window(view_report_window) print('------window1------' + report_name) if report_name == 'DRG Change Condition Detail': ACT.wait_until_title_contains(driver, 'DRG Change Detail') elif report_name == 'Top 50 Diagnoses by Present on Admission(POA)': ACT.wait_until_title_contains( driver, 'Top 50 Other Diagnoses by Present on Admission(POA)') elif report_name == 'Management Clinical Profile': ACT.wait_until_title_contains(driver, 'Evaluation') elif 'Frequency' in report_name: ACT.wait_until_title_contains(driver, 'Frequency') else: ACT.wait_until_title_contains(driver, report_name) print(view_report_window) print(driver.title) print( '---wait_presence_element--------RW_ReportToolbar_ExportGr_FormatList_DropDownList----------' ) print('-----driver.execute_script(document.redyState)--------') print(driver.execute_script('return document.readyState')) # wait report load fully ACT.wait_document_completed(driver) # take a screnshot print('---------take a screnshot-------------') SC.screen_shot_report_us_test_result(driver, report_name, report_case) print('switch_to_report_view_page' + report_name + '---------end')
def test_read_as_list_reports(self): # standard enterprise reports_dic_enterprise = SC.read_file_as_list_report_US299725('enterprise') reports_dic_standard = SC.read_file_as_list_report_US299725('standard') enterprise = list(reports_dic_enterprise.values()) for i in enterprise: print(i)
def test_wait(self): driver = webdriver.Firefox() SC.login_(driver) # Click "inpatient" inpatient = driver.find_element_by_id('aModuleSIP101') inpatient.click() # Click "report" report = driver.find_element_by_id('aIPModuleWorkplans') report.click()
def test_compatibility(self): reports_dic_standard_all = SC.read_file_as_list_report_US299725('standard') reports_dic_enterprise_all = SC.read_file_as_list_report_US299725('enterprise') print(reports_dic_standard_all.__len__()) print(reports_dic_enterprise_all.__len__()) reports_dic_standard_keys = list(reports_dic_standard_all.keys()) reports_dic_standard_values = list(reports_dic_standard_all.values()) reports_dic_standard = {} for dic in range(reports_dic_standard_all.__len__()): reports_dic_standard[reports_dic_standard_keys[dic]] = reports_dic_standard_values[dic] for i in reports_dic_standard.items(): print(i)
def test_read_file_report_names_as_list(self): reports_name_cases = SC.read_file_report_names_as_list('enterprise') report_names = [] report_case_num = [] for i in reports_name_cases: report_names.append(reports_name_cases[i]) report_case_num.append(i) print(report_names) print(report_case_num)
def swiitch_to_report_view_page(driver, report, report_case): window1 = driver.window_handles[1] driver.switch_to.window(window1) print('------window1------' + report) if report == 'DRG Change Condition Detail': ACT.wait_until_title_contains(driver, 'DRG Change Detail') elif report == 'Top 50 Diagnoses by Present on Admission(POA)': ACT.wait_until_title_contains( driver, 'Top 50 Other Diagnoses by Present on Admission(POA)') else: ACT.wait_until_title_contains(driver, report) print(window1) print(driver.title) print( '---wait_presence_element--------RW_ReportToolbar_ExportGr_FormatList_DropDownList----------' ) print('-----driver.execute_script(document.redyState)--------') print(driver.execute_script('return document.readyState')) ACT.wait_document_completed(driver) # if report == 'Case Listing': # ACT.wait_presence_element(driver, 'RdlViewer_ctl01_ctl05_ctl00') # else: # ACT.wait_presence_element(driver, 'RW_ReportToolbar_ExportGr_FormatList_DropDownList') # take a screnshot print('---------take a screnshot-------------') test_case_number = 'TC ' + str(report_case) + '-' + report if report == 'Top 50 CC/MCC Diagnoses': picture_path = 'pictures/Top 50 CC_MCC Diagnoses.png' else: picture_path = 'pictures/' + report + '.png' SC.file_exists_delete(picture_path) picture = driver.save_screenshot(picture_path) SC.write_test_result_as_docx(picture_path, test_case_number) print('swiitch_to_report_view_page---------end')
def test_enterprise_reports(self): field_list = [] field_dic = {} driver = self.driver SC.login_(driver) reports.reports.go_to_op_standard(driver) report_name = 'Visits Processed on Import' reports.reports.find_report(driver, report_name) reports.reports.go_to_report_CS(driver, report_name) # reports.reports.add_filters_besides_default_ones(driver) # set up filters ACT.wait_element_clickable(driver, By.ID, 'btnInsertClause') add_icon = driver.find_element_by_id('btnInsertClause') add_icon.click() driver.find_element_by_id('customsearch-grid-div') field_last = driver.find_element_by_xpath( './/div[@id="customsearch-grid-div"]/div/div[@class="k-grid-content"]/table/tbody/tr[last()]/td[3]/span' ) field_last.click() # cycle all the options under field dropdown field_names_xpath = '//div[@class="k-animation-container"][last()]/div/ul/li' field_names = driver.find_elements_by_xpath(field_names_xpath) print('----------------------------------------------------') field_values = [] for item in field_names: print(item.text) field_values.append(item.text) print('----------------------------------------------------') for i in range(0, len(field_values)): print('----------------------------------------------------') print(i) tools.spide_write_to_txt(field_values[i], '../Smart_commons/cs_fields.txt') print(field_values[i]) field_dic['id'] = field_values[i] if i == 0: print(i) else: driver.find_element_by_id('customsearch-grid-div') field_last = driver.find_element_by_xpath( '//div[@id="customsearch-grid-div"]/div/div[@class="k-grid-content"]/table/tbody/tr[last()]/td[3]/span' ) field_last.click() field_name = field_values[i] field_names_xpath = '//div[@class="k-animation-container"][last()]/div/ul/li' field_names = driver.find_elements_by_xpath(field_names_xpath) for i in field_names: print(i.text) field_xpath = '//div[@class="k-animation-container"][last()]/div/ul/li[text()="' + field_name + '"]' print(field_xpath) ACT.wait_presence_element_xpath(driver, field_xpath) ACT.wait_element_clickable(driver, By.XPATH, field_xpath) field_name_select = driver.find_element_by_xpath(field_xpath) field_name_select.click() print('------click----field_name-----------' + field_name) # operator # click "operator" button operator = driver.find_element_by_xpath( '//div[@id="customsearch-grid-div"]/div/div[@class="k-grid-content"]/table/tbody/tr[last()]/td[4]/span' ) operator.click() # cycle all the options under ope dropdown operator_names_xpath = '//div[@class="k-animation-container"][last()]/div/ul/li' operator_names = driver.find_elements_by_xpath( operator_names_xpath) operator_names[1].click() operators = '' for item in operator_names: tools.spide_write_to_txt(item.text, '../Smart_commons/cs_operators.txt') operators = operators + item.text + ',' print(item.text) field_dic['operators'] = operators # click 'value' field xpath = './/div[@id="customsearch-grid"]/div[@class="k-grid-content"]/table/tbody/tr[last()]/td[5]/div/div[6]/input' value_input = driver.find_element_by_xpath(xpath) value_input_property = value_input.get_property('disabled') print('----value_input_style-------') print(value_input_property) field_dic['type'] = 'input' field_dic['default'] = 'default' field_list.append(field_dic) tools.write_dics_list_to_xml('Fields', 'Field', field_list, '../Smart_commons/cs_fields.xml') for i in field_list: print(i)
def test_navigate_ip_report_cs_firefox(self): # profile = webdriver.FirefoxProfile() # profile.set_preference("network.proxy.type", 1) # profile.set_preference("network.proxy.http", "proxy.server.address") # profile.set_preference("network.proxy.http_port", "port_number") # profile.update_preferences() # driver = webdriver.Firefox(firefox_profile=profile) #activate a browser driver = webdriver.Firefox() driver.maximize_window() reports_dic_standard = SC.read_file_as_list_report_US299725('standard') reports_values = list(reports_dic_standard.values()) reports_keys = list(reports_dic_standard.keys()) SC.login_(driver) # go to report search page # IP_report.go_to_report_ip_Enterprise(driver) IP_report.go_to_report_ip_Standard(driver) for i in range(0, reports_dic_standard.__len__()): report = reports_values[i] # report = 'Frequency' # find "report name" try: IP_report.find_report_ip(driver, report) except: print('---try--except------'+report+'--not found-----') # continue # click "report name" IP_report.go_to_report_CS(driver, report) # add filters besides the default ones IP_report.add_filters_besides_default_ones(driver,i) # operator #value # value_a = driver.find_element_by_xpath( # './/div[@id="customsearch-grid-div"]/div/div[@class="k-grid-content"]/table/tbody/tr[last()]/td[5]/div/div[4]/span/a') # value_a.click() # # ACT.wait_invisibility_of_element_located(driver) # ACT.wait_element_clickable(driver, By.XPATH, # '//div[@id="dvLookupuGrid"]/div[@class="k-grid-content"]/table/tbody/tr[1]') # # value_select_tr1 = driver.find_element_by_xpath( # '//div[@id="dvLookupuGrid"]/div[@class="k-grid-content"]/table/tbody/tr[1]') # value_select_tr1.click() # # KEY.KeyboardKeys.keyDown(KEY.KeyboardKeys.VK_CODE['shift']) # # value_select_last = driver.find_element_by_xpath( # '//div[@id="dvLookupuGrid"]/div[@class="k-grid-content"]/table/tbody/tr[last()]') # value_select_last.click() #operator_dropdown = driver.find_elements_by_xpath('//div[@class="k-animation-container"][1]/div/ul/li') # Click "View report" IP_report.view_report_by_default_filters(driver) # Go to report view page IP_report.swiitch_to_report_view_page(driver, report, reports_keys[i]) # Export report # IP_report.export_report(driver, report) handles = driver.window_handles driver.close() driver.switch_to.window(handles[0]) ACT.wait_invisibility_of_element_located(driver) close = driver.find_element_by_xpath('//span[text()="close"]') close.click()
def test_US299725_enterprise_chrome(self): # executable_path = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" # os.environ["webdriver.chrome.driver"] = executable_path # options = webdriver.ChromeOptions() # options.extensions.clear() # driver = webdriver.Chrome(chrome_options=options) # SC.login_(driver) # # go to report search page # # IP_report.go_to_report_ip_Enterprise(driver) # IP_report.go_to_report_ip_Enterprise(driver) # capabilities = { # 'browserName': 'chrome', # 'chromeOptions': { # 'useAutomationExtension': False, # 'forceDevToolsScreenshot': True, # 'args': ['--start-maximized', '--disable-infobars'] # } # } # # driver = webdriver.Chrome(desired_capabilities=capabilities) # SC.login_(driver) # go to report search page # IP_report.go_to_report_ip_Enterprise(driver) # IP_report.go_to_report_ip_Enterprise(driver) # driver.maximize_window() reports_dic_standard = SC.read_file_as_list_report_US299725('standard') reports_values = list(reports_dic_standard.values()) reports_keys = list(reports_dic_standard.keys()) # reports_dic_enterprise = SC.read_file_as_list_report_US299725('enterprise') # reports_values = list(reports_dic_enterprise.values()) # reports_keys = list(reports_dic_enterprise.keys()) ones = reports_dic_standard.__len__() for i in range(0, ones): # executable_path = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" # os.environ["webdriver.chrome.driver"] = executable_path # options = webdriver.ChromeOptions() # options.extensions.clear() # driver = webdriver.Chrome(chrome_options=options) capabilities = { 'browserName': 'chrome', 'chromeOptions': { 'useAutomationExtension': False, 'forceDevToolsScreenshot': True, 'args': ['--disable-infobars'] # 'args': ['--start-maximized', '--disable-infobars'] } } driver = webdriver.Chrome(desired_capabilities=capabilities) SC.login_(driver) # go to report search page IP_report.go_to_report_ip_Standard(driver) # IP_report.go_to_report_ip_Enterprise(driver) report = reports_values[i] report = 'Medicare HAC Potential Impact' # report = 'Frequency' # find "report name" try: IP_report.find_report_ip(driver, report) except: print('---try--except------' + report + '--not found-----') # click "report name" IP_report.go_to_report_CS(driver, report) # add filters besides the default ones IP_report.add_filters_besides_default_ones(driver,i) # Click "View report" IP_report.view_report_by_default_filters(driver) # Go to report view page IP_report.swiitch_to_report_view_page(driver, report, reports_keys[i]) # Export report # IP_report.export_report(driver, report) # handles = driver.window_handles # print(handles.__len__()) # for handle in driver.window_handles: # print(handle) # print('-------window_handles------------------') # print(driver.current_window_handle) # driver.switch_to.window(driver.current_window_handle) # time.sleep(10) # # driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'W') # # print('--------------Keys.CONTROL+w--------------') # time.sleep(5) # driver.switch_to.window(driver.current_window_handle) # driver.close() driver.quit()
def test_US299725_IE11(self): # IE_path = r'C:\Program Files\Internet Explorer\ExtExport.exe' # os.environ['webdriver.ie.driver'] = IE_path # driver = webdriver.Ie(IE_path) caps = DesiredCapabilities.INTERNETEXPLORER caps = { 'ignoreProtectedModeSettings': True, 'ignore_protected_mode_settings': True, 'ignore_zoom_level': True, 'native_events': False, 'persistent_hover': False, 'ELEMENT_SCROLL_BEHAVIOR': True, 'require_window_focus': True } opts = IEoptions() opts.ignore_protected_mode_settings = True opts.ignore_zoom_level = True opts.require_window_focus = True opts.native_events = False opts.ignore_protected_mode_settings = True opts.persistent_hover = False opts.ELEMENT_SCROLL_BEHAVIOR = True # opts.ensure_clean_session = True # ie_options=opts,executable_path=IE_path, driver = webdriver.Ie(options=opts) reports_dic_enterprise = SC.read_file_as_list_report_US299725('enterprise') reports_values = list(reports_dic_enterprise.values()) reports_keys = list(reports_dic_enterprise.keys()) SC.login_(driver) # go to report search page # IP_report.go_to_report_ip_Enterprise(driver) IP_report.go_to_report_ip_Enterprise(driver) for i in range(10, 19): report = reports_values[i] # find "report name" try: IP_report.find_report_ip(driver, report) except: print('---try--except------' + report + '--not found-----') # click "report name" IP_report.go_to_report_CS(driver, report) # add filters besides the default ones IP_report.add_filters_besides_default_ones(driver, i) # Click "View report" IP_report.view_report_by_default_filters(driver) # Go to report view page IP_report.swiitch_to_report_view_page(driver, report, reports_keys[i]) # Export report # IP_report.export_report(driver, report) handles = driver.window_handles driver.close() driver.switch_to.window(handles[0]) ACT.wait_invisibility_of_element_located(driver) close = driver.find_element_by_xpath('//span[text()="close"]') close.click()
def test_read_as_list(self): # custom_search_fields.txt items = SC.read_file_as_list('reports_names.txt') for item in items: print(item)
def test_write_result(self): # Flag Comparison.png # 'Medicare Medical Necessity Flags.png' SC.write_test_result_as_docx('pictures/1.PNG', 'TC 123232 -xxxxx')
def test_docx_for_299725(self): pictures = 'pictures/DRG Clinical Profile.png' headings = 'Test Case 123456' SC.write_test_result_as_docx(pictures,headings)