示例#1
0
def print_page():
    print_page_controller = NewController('desktop.png', ['print_page.png'], 'WINDOW')
    flag = print_page_controller.click_position('print_test_page')
    time.sleep(5)
    if flag:
        co.pass_report("Local_USB_printer_print_test_page")
        submit_controller = NewController('desktop.png', ['submited_ok.png'], 'WINDOW')
        flag = submit_controller.click_position('submit')
    else:
        false_return('print test page')
        co.fail_report("Not found print_test_page button.", "Local_USB_printer_print_test_page")
        return False
    if flag:
        printer_properties_controller = NewController('desktop.png', ['printer_properties.png',
                                                                      'printer_properties_italic.png',
                                                                      'printer_properties_italic1.png'], 'WINDOW')
        flag = printer_properties_controller.click_position('printer_properties')
    else:
        false_return('submit')
        return False
    if flag:
        return True
    else:
        false_return('printer properties')
        return False
示例#2
0
def start_connection():
    my_logger.info('start connection')
    citrix_icon = NewController('desktop_root.png', ['citrix_icon.png'],
                                'ICON')
    t = citrix_icon.rightclick_position()
    time.sleep(1)
    pyautogui.press(['down', 'enter'])
    if not t:
        reason = 'failed to start connection'
        my_logger.info(reason)
        return reason
    else:
        return True
示例#3
0
def remove_rdp():
    my_logger.info('remove connection')
    rdp_icon = NewController('desktop_root.png',
                             ['rdp_icon.png', 'rdp_icon_2.png'], 'ICON')
    t = rdp_icon.rightclick_position('')
    time.sleep(1)
    pyautogui.press(['down', 'down', 'down', 'down', 'down'])
    pyautogui.press('enter')
    if not t:
        reason = 'failed to remove connection'
        my_logger.info(reason)
        #fail_report('failed to remove connection')
    else:
        return True
示例#4
0
def delete_printer():
    delete_printer_controller = NewController('desktop.png', ['printer_local.png'], 'WINDOW')
    flag = delete_printer_controller.rightclick_position('delete_printer')
    if flag:

        pyautogui.press(['down', 'down', 'down', 'down'])
        pyautogui.press('enter')
        confirm_deletion_controller = NewController('desktop.png', ['confirm.png'], 'WINDOW')
        confirm_deletion_controller.click_position( 'confirm_deletion')
    else:
        false_return('printer local')
        return False
    return True
示例#5
0
def select_desktop(name):
    broker = NewController('desktop_root.png',
                           ['citrix_broker.png', 'citrix_broker_italic.png'],
                           'ICON')
    flag = broker.click_position()
    if not flag:
        reason = 'failed to look up citrix broker'
        my_logger.info(reason)
        os.popen('pkill -f citrix')
        return reason
    pyautogui.hotkey('ctrl', 'alt', 'f5')
    time.sleep(5)
    pool = NewController('desktop_root.png', name, 'ICON')
    flag = pool.doubleclick_position()
    if flag:
        return True
    else:
        reason = 'failed to look up ' + ', '.join(name)
        my_logger.info(reason)
        os.popen('pkill -f citrixApps')
        return reason
示例#6
0
def enable_vpn():
    switch_to_vpn = NewController('desktop.png', ['system.png'], 'WINDOW',
                                  'config.yml')
    flag = switch_to_vpn.click_position('vpn.png')
    if flag:
        enable_vpn = NewController('desktop.png', ['system.png'], 'WINDOW',
                                   'config.yml')
        flag = enable_vpn.click_position('auto_start.png')
    else:
        return False
    if flag:
        pyautogui.press('down')
        pyautogui.press('enter')
        pyautogui.press('tab')
        time.sleep(2)
        pyautogui.typewrite("15.83.244.9")
        pyautogui.press('tab')
        pyautogui.typewrite("vpnclient")
        pyautogui.press('tab')
        pyautogui.typewrite("neoware")
        pyautogui.press('tab')
        pyautogui.typewrite("neoware")
        pyautogui.press('tab')
示例#7
0
def write_offset_to_printer_yml():
    add_printer_controller = NewController('desktop.png', ['printer_local.png'], 'WINDOW')
    add_printer_controller.click_position_tool('add_icon1.png')
    edit_dict = {'add_printer': add_printer_controller.relative_offset}
    add_printer_controller.dump_to_yaml(edit_dict)
    new_printer_controller = NewController('desktop.png', ['new_printer.png'], 'WINDOW')
    new_printer_controller.click_position_tool('HP_Laserjet_P2035.png')
    edit_dict['chose_printer'] = new_printer_controller.relative_offset
    new_printer_controller.click_position_tool('forward.png')
    edit_dict['confirm'] = new_printer_controller.relative_offset
    new_printer_controller.click_position_tool('apply.png')
    edit_dict['prepare_print'] = new_printer_controller.relative_offset
    new_printer_controller.dump_to_yaml(edit_dict)
    print_page_controller = NewController('desktop.png', ['print_page.png'], 'WINDOW')
    print_page_controller.click_position_tool('print_test_page.png')
    edit_dict['print_test_page'] = print_page_controller.relative_offset
    print_page_controller.dump_to_yaml(edit_dict)
    time.sleep(15)
    submit_controller = NewController('desktop.png', ['submited_ok.png'], 'WINDOW')
    submit_controller.click_position_tool('ok_copy.png')
    edit_dict['submit'] = submit_controller.relative_offset
    submit_controller.dump_to_yaml(edit_dict)
    printer_properties_controller = NewController('desktop.png', ['printer_properties.png',
                                                                  'printer_properties_italic.png', 
                                                                  'printer_properties_italic1.png'], 'WINDOW')
    printer_properties_controller.click_position_tool('ok_small.png')
    edit_dict['printer_properties'] = printer_properties_controller.relative_offset
    printer_properties_controller.dump_to_yaml(edit_dict)
    delete_printer_controller = NewController('desktop.png', ['printer_local.png'], 'WINDOW')
    delete_printer_controller.click_position_tool('printer.png')
    delete_printer_controller.rightclick_position_tool('printer.png')
    edit_dict['delete_printer'] = delete_printer_controller.relative_offset
    delete_printer_controller.dump_to_yaml(edit_dict)
    confirm_deletion_controller = NewController('desktop.png', ['confirm.png'], 'WINDOW')
    confirm_deletion_controller.click_position_tool('delete.png')
    edit_dict['confirm_deletion'] = confirm_deletion_controller.relative_offset
    confirm_deletion_controller.dump_to_yaml(edit_dict)
    cancel_usbupdate_contrller = NewController('desktop.png', ['USB_update.png'], 'WINDOW')
    cancel_usbupdate_contrller.click_position_tool('usb_cancel.png')
    edit_dict['USB_Update'] = cancel_usbupdate_contrller.relative_offset
    cancel_usbupdate_contrller.dump_to_yaml(edit_dict)
示例#8
0
def cancel_print_page():
    cancel = NewController('desktop.png', ['cancel.png'], 'ICON')
    cancel.click_position('')
示例#9
0
def add_printer():
    add_printer_controller = NewController('desktop.png', ['printer_local.png'], 'WINDOW')
    flag = add_printer_controller.click_position('add_printer')
    if flag:
        new_printer_controller = NewController('desktop.png', ['new_printer.png'], 'WINDOW')
        new_printer_controller.click_position('chose_printer')
        new_printer_controller.click_position('confirm')
        time.sleep(8)
        new_printer_controller.click_position('prepare_print')
        return True
    else:
        false_return('printer local')
        return False
示例#10
0
def close_usbupdate_window():
    cancel_usbupdate_contrller = NewController('desktop.png', ['USB_update.png'], 'WINDOW')
    if cancel_usbupdate_contrller.click_position('USB_Update'):
        return True
    else:
        return False
示例#11
0
def write_offset_to_startup_yml():
    add.open_window('network',
                    "./Test_Data/1920x1200/template_file/control_panel.png")
    time.sleep(2)
    switch_to_vpn = NewController('desktop.png', ['system.png'], 'WINDOW',
                                  'control_panel.yml')
    switch_to_vpn.click_position_tool('vpn.png')
    edit_dict = {'switch_to_vpn': switch_to_vpn.relative_offset}
    switch_to_vpn.dump_to_yaml(edit_dict)
    enable_vpn = NewController('desktop.png', ['system.png'], 'WINDOW',
                               'control_panel.yml')
    enable_vpn.click_position_tool('auto_start.png')
    edit_dict['enable_auto_start'] = enable_vpn.relative_offset
    enable_vpn.dump_to_yaml(edit_dict)
    enable_vpn.click_position_tool('vpn_type.png')
    pyautogui.press('down')
    pyautogui.press('enter')
    pyautogui.press('tab')
    time.sleep(2)
    apply_vnc_change = NewController('desktop.png', ['control_panel.png'],
                                     'WINDOW', 'control_panel.yml')
    apply_vnc_change.click_position_tool('control_panel_apply.png')
    edit_dict['apply_vpn_change'] = apply_vnc_change.relative_offset
    apply_vnc_change.dump_to_yaml(edit_dict)
    add.close_window("./Test_Data/1920x1200/template_file/control_panel.png")
示例#12
0
def write_rdp_offset_to_yml():
    # remove_rdp()
    # create_rdp()
    rdp_icon = NewController('desktop_root.png', ['rdp_icon.png'], 'ICON')
    rdp_icon.rightclick_position('')
    pyautogui.press(['down', 'down'])
    pyautogui.press('enter')

    rdp_connnection_table_controller = NewController(
        'desktop_connection.png', ['rdp_title.png', 'rdp_title_italic.png'],
        'WINDOW', 'rdp_config.yml')
    edit_dict = {}
    # rdp_connnection_table_controller.click_position_tool('connection_table_current_mode.png')
    # edit_dict = {'connection_table_current_mode': rdp_connnection_table_controller.relative_offset}
    # pyautogui.press(['down', 'enter'])
    rdp_connnection_table_controller.click_position_tool(
        'rdp_table_url.png', (0.9, 0.5))
    edit_dict[
        'rdp_table_url'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.click_position_tool(
        'rdp_table_use_predefined.png')
    edit_dict[
        'rdp_table_use_predefined'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.click_position_tool(
        'rdp_table_user.png', (0.9, 0.5))
    edit_dict[
        'rdp_table_user'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.click_position_tool(
        'rdp_table_password.png', (0.9, .5))
    edit_dict[
        'rdp_table_password'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.click_position_tool(
        'rdp_table_domain.png', (0.9, 0.5))
    edit_dict[
        'rdp_table_domain'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.click_position_tool(
        'rdp_local_resource.png')
    edit_dict[
        'rdp_local_resource'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.click_position_tool('rdp_high_level.png')
    edit_dict[
        'rdp_high_level'] = rdp_connnection_table_controller.relative_offset
    # rdp_connnection_table_controller.click_position_tool(root, 'ok.png')
    # edit_dict['ok'] = rdp_connnection_table_controller.relative_offset
    rdp_connnection_table_controller.dump_to_yaml(edit_dict)
示例#13
0
def verify_smartcard_local(desktop_list):
    # print("verify smartcard local")
    # --------------------check pin appear------------------------------
    pin_list = ["pin.png"]
    pin = NewController("desktop_root.png", pin_list, "ICON")
    pin_flag = pin.click_position()
    if pin_flag:
        my_logger.info("input pin")
        pyautogui.press("0")
        pyautogui.press("0")
        pyautogui.press("0")
        pyautogui.press("0")
        time.sleep(1)
        pyautogui.press("enter")
        time.sleep(5)
        my_logger.info('select desktop')
        flag = script_general.select_desktop(desktop_list)
        print(flag)
        # --------------------add verify_smartcard---------------
        #  no need  verify_smartcard()
        if flag is False:
            print("can't find desktop")
            return flag
        else:
            # fail_report('select desktop fail')
            time.sleep(20)
            launch_error = ["xd_smartcard_unable_to_launch.png"]
            launch = NewController("desktop_root.png", launch_error, "ICON")
            launch_flag = launch.click_position()
            if launch_flag:
                log.error("can't launch remote desktop")
                log.info("will kill Citrix process")
                os.popen("pkill -f Citrix")
                fail_report(test_name)
                return False
            else:
                print("login to remote desktop")
                time.sleep(5)
                pg.press("ctrl")
                smartcard_list = ["xd_smartcard_switch_smart_card_3.png"]
                smartcard = NewController("desktop_root.png", smartcard_list,
                                          "ICON")
                smartcard_flag = smartcard.click_position()
                if smartcard_flag:
                    util = RDPUtil()
                    sign_in_option = util.wait_element([
                        'Test_Data/1366x768/template_file/xd_smartcard_sign_in_options_10_0.png'
                    ])
                    if sign_in_option:
                        verify_smartcard()
                    return True
    else:
        # --------------------check if smartcard and smartcard reader not found-------------------
        list = ["xd_smartcard_not_found_error.png"]
        smart_card_not_found = NewController("desktop_root.png", list, "ICON")
        not_found_flag = smart_card_not_found.click_position()
        if not_found_flag:
            cancel_list = ["xd_smartcard_not_found_cancel.png"]
            cancel_button = NewController("desktop_root.png", cancel_list,
                                          "ICON")
            cancel_button.click_position()
            smartcard_button = ["xd_smartcard_not_found_error2.png"]
            citrix_error = NewController("desktop_root.png", smartcard_button,
                                         "ICON")
            error_flag = citrix_error.click_position()
            if error_flag:
                ok_list = ["xd_smartcard_not_found_ok.png"]
                ok_button = NewController("desktop_root.png", ok_list, "ICON")
                ok_button.click_position()
                my_logger.error("can't find smartcard, test fail")
                fail_report("Failed, can't find smartcard")
                return False
        else:
            # --------------------check if smartcard not valid---------------
            not_valid_list = ["xd_smartcard_not_valid.png"]
            smart_card_not_valid = NewController("desktop_root.png",
                                                 not_valid_list, "ICON")
            not_valid_flag = smart_card_not_valid.click_position()
            if not_valid_flag:
                cancel_list = ["xd_smartcard_not_found_cancel.png"]
                cancel_button = NewController("desktop_root.png", cancel_list,
                                              "ICON")
                cancel_button.click_position()
                smartcard_button = ["xd_smartcard_not_found_error2.png"]
                citrix_error = NewController("desktop_root.png",
                                             smartcard_button, "ICON")
                error_flag = citrix_error.click_position()
                if error_flag:
                    ok_list = ["xd_smartcard_not_found_ok.png"]
                    ok_button = NewController("desktop_root.png", ok_list,
                                              "ICON")
                    ok_button.click_position()
                    my_logger.error("smartcard not valid, test fail")
                    fail_report("Failed, smartcard not valid")
                    return False
    process = os.popen('ps -ef | grep Citrix\\ Error | grep -v grep').read()
    if process:
        log.error("get error window")
        log.info("will kill Citrix process")
        os.popen("pkill -f Citrix")
        return False
示例#14
0
def edit_connection_storefront_smartcard():
    url = load_yaml('storefront_server')
    my_logger.info('edit connection')
    icon_list = ['citrix_icon.png']
    citrix_icon = NewController('desktop_root.png', icon_list, 'ICON')
    citrix_icon.rightclick_position()
    time.sleep(1)
    pyautogui.press(['down', 'down'])
    pyautogui.press('enter')
    rdp_connnection_table_controller = NewController(
        'desktop_connection.png', ['edit_title.png', 'edit_title_italic.png'],
        'WINDOW', 'citrix_config.yml')
    my_logger.info('click current mode button')
    flag = rdp_connnection_table_controller.click_position(
        'connection_table_current_mode')
    if flag:
        pyautogui.press(['down', 'enter'])
        my_logger.info('click URL button')
        rdp_connnection_table_controller.click_position('connection_table_url')
        pyautogui.typewrite(url)
        my_logger.info('click predefined smartcard')
        rdp_connnection_table_controller.click_position('smart_card')
        pyautogui.press(['tab', 'down'])
        # my_logger.info('click predefined user, password...button')
        # rdp_connnection_table_controller.click_position('connection_table_use_predefined')
        # my_logger.info('click user button')
        # rdp_connnection_table_controller.click_position('connection_table_user')
        # pyautogui.typewrite('automation')
        # my_logger.info('click password button')
        # rdp_connnection_table_controller.click_position('connection_table_password')
        # pyautogui.typewrite('Shanghai2014')
        # my_logger.info('click domain button')
        # rdp_connnection_table_controller.click_position('connection_table_domain')
        # pyautogui.typewrite('sh.dto')
        button_list = ['ok.png']
        my_logger.info('click ok button')
        ok_button = NewController('desktop_root.png', button_list, 'ICON')
        ok_button.click_position()
        return True
    else:
        #capture_screen()
        reason = 'failed to find edit window'
        my_logger.info(reason)
        # fail_report('failed to open edit window')
        os.popen('pkill -f CitrixApps')
        return reason