def run(): log = co.logger() testname = "Local_USB_printer_print_test_page" pyautogui.hotkey('ctrl', 'alt', 'end') co.check_resolution() co.check_network_status() if not cp.check_printer_by_system(testname): return if cp.check_printers() > 0: cp.clear_previous_printer() flag = ad.open_window('printer', "./Test_Data/1920x1200/template_file/printers_localhost.png") if flag: flag = ad.add_printer() else: return False if flag: log.logger.info("Printer added successful.") flag = cp.check_printer_added() else: return False if flag: ad.print_page() flag = ad.delete_printer() else: return False if flag: log.logger.info("Printer deleted successful.") ad.close_window("./Test_Data/1920x1200/template_file/printers_localhost.png") return True else: return False
def change_view_sec_allow_all(reg_dir): log = common_function.logger() uuid = os.popen("mclient --quiet get \"" + reg_dir + "\"").readlines() length = len(uuid) if length == 0: log.error("no vmware connection created") return False uuid_vmware = uuid[0].strip() os.popen( 'mclient set %s/viewSecurityLevel "Allow all connections" && mclient --quiet commit' % uuid_vmware) time.sleep(1) get_sec_level = os.popen("mclient --quiet get %s/viewSecurityLevel" % uuid_vmware).readlines()[0].strip() return get_sec_level
def clear_connections(connection_type): log = common_function.logger() # If there are active connections, stop them. conn_type_list = [ "custom", "firefox", "freerdp", "ssh", "telnet", "view", "xdmcp", "xen", "all" ] for conn_type in conn_type_list: if conn_type == connection_type: if connection_type == "all": active_connections = os.popen( "connection-mgr listActive | awk '{print $1}'").readlines( ) else: active_connections = os.popen( "connection-mgr listActive | grep %s | awk '{print $1}'" % conn_type).readlines() length = len(active_connections) if length != 0: for conn in active_connections: conn = conn.strip() os.popen("connection-mgr stop %s" % conn) # Delete connections according to connection_type # If connection_type is "all", create a list for all connection types then delete if connection_type == "all": connection_types = os.popen( "mclient --quiet get \"root/ConnectionType\"").readlines() print("connection types: ", connection_types) for var in connection_types: var = var.strip() connections = os.popen( "mclient --quiet get %s/connections" % var).readlines() if len(connections) != 0: for conn_specified in connections: conn_specified = conn_specified.strip() os.popen( "mclient --quiet delete %s && mclient commit" % conn_specified) else: connections = os.popen("mclient --quiet get root/ConnectionType/%s/connections" % conn_type).\ readlines() if len(connections) != 0: for conn_specified in connections: conn_specified = conn_specified.strip() os.popen( "mclient --quiet delete %s && mclient commit" % conn_specified)
import time import pyautogui import Test_Script.common_function as co from Lib.thinpro_citrix import NewController import Test_Script.Check_window as cw log = co.logger() 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)
def run(): file_name = 'Connectivity_static_wireless' log = report.logger() wire = wireless.Wireless('R1_TC_5G_n', 'static_wireless_password') check_wireless = wire.check_wireless() if check_wireless is not True: report.fail_report('Fail:%s' % check_wireless, file_name) return False try: with open('test.txt', 'r') as test: wire.switch_root() if test.readlines()[0] == 'pass': os.remove('test.txt') return True else: os.remove('test.txt') return False except: print('continue') boot_times = wire.read_boot_time() if boot_times is False: wire.switch_wired('1', 'down') boot_times = 1 wire.switch_root() if boot_times == '1': wire.clear_profiles() wire.open_wireless() add_wireless = wire.add_wireless() if add_wireless is not True: report.fail_report('Fail:%s' % add_wireless, file_name) write() wire.switch_wired('remove', 'up') return False apply_settings = wire.apply_settings() if apply_settings is not True: report.fail_report('Fail:%s' % apply_settings, file_name) write() wire.switch_wired('remove', 'up') return False if wire.check_profile() is False: report.fail_report('Fail:add profile fail', file_name) write() wire.switch_wired('remove', 'up') return False time.sleep(25) if wire.static_method() is not True: report.fail_report('Fail:not find IPv4 option', file_name) write() wire.switch_wired('remove', 'up') return False time.sleep(25) if wire.ping() is False: report.fail_report( 'Fail:ping to static wireless fail after change method to static', file_name) write() wire.switch_wired('remove', 'up') pag.hotkey('ctrl', 'alt', 'f4') return False wire.write_boot_time('2') wire.reboot() if boot_times == '2': time.sleep(5) if wire.ping() is False: report.fail_report( 'Fail:ping to static wireless fail after reboot', file_name) write() wire.switch_wired('remove', 'up') return False wire.open_wireless() delete_profile = wire.delete_profiles() if delete_profile is not True: report.fail_report('Fail:%s' % delete_profile, file_name) pag.hotkey('ctrl', 'alt', 'f4') write() wire.switch_wired('remove', 'up') return False time.sleep(10) if wire.ping() is False: log.info('delete profile,ping test success') report.pass_report(file_name) write('pass') wire.switch_wired('remove', 'up') else: report.fail_report( 'Fail:delete profile complete,but can ping to network,check time delay os connection', file_name) write() wire.switch_wired('remove', 'up') return False
from Test_Script import thinpro_view from Test_Script import view_ftp from Test_Script import certificate import pyautogui as pag import time import os from Test_Script import common_function as report from Test_Script import get_config as gc blast_usbr_log = report.logger() def run(server_name='blast_server_name'): file_name = 'VMware_win10_USB_key_USBR_blast' local_usb = check_usb() if local_usb is not True: report.fail_report(local_usb, file_name) return False operation = '//15.83.240.98/Automation/Linux/scripts/usbkey_redirection.exe' cer = certificate.Cert('ROOTCA') find_cert = cer.check_cert() if find_cert is False: insert = cer.import_cert() if insert is False: report.fail_report('import cert fail', file_name) return False blast_usbr_log.info('import cert success for %s' % file_name) name, password = '******', 'password' case = thinpro_view.View(server_name, name, password) case.del_connection() case.create_connection()
import traceback import Lib.main_function as mf from Test_Script import common_function as comfun log = comfun.logger() def execute_main_function(config_file='main_function.yml'): file = './Test_Data/1920x1200/config_file/' + config_file with open(file, 'r') as f: yml_obj = mf.ordered_yaml_load(file) for key, value in yml_obj.items(): if value == 'Y': try: eval(key) # yml_obj[key] = "N" # with open(file, 'w') as f: # mf.ordered_yaml_dump(yml_obj, f, default_flow_style=False) except Exception: error = traceback.format_exc() log.info(error) else: pass
def run(): file_name = 'Connectivity_WPA2P' log = report.logger() wire = wireless.Wireless('R1_TC_2.4G_n_WPA2P', 'WPA2P_password') check_wireless = wire.check_wireless() if check_wireless is not True: report.fail_report('Fail:%s' % check_wireless, file_name) return False try: with open('test.txt', 'r') as test: wire.switch_root() if test.readlines()[0] == 'pass': os.remove('test.txt') return True else: os.remove('test.txt') return False except: print('continue') boot_times = wire.read_boot_time() if boot_times is False: wire.switch_wired('1', 'down') boot_times = '1' wire.switch_root() if boot_times == '1': wire.clear_profiles() wire.open_wireless() add_wireless = wire.add_wireless() if add_wireless is not True: report.fail_report('Fail:%s' % add_wireless, file_name) write() wire.switch_wired('remove', 'up') return False connect_wpa2a = wire.connect_with_security() if connect_wpa2a is not True: report.fail_report('Fail:%s' % connect_wpa2a, file_name) write() wire.switch_wired('remove', 'up') return False if wire.check_profile() is False: pag.hotkey('ctrl', 'alt', 'f4') report.fail_report('Fail:not found wireless profile', file_name) write() wire.switch_wired('remove', 'up') return False time.sleep(25) if wire.ping() is False: report.fail_report('Fail:ping to network fail,check if the wifi is or not available, or delay too short', file_name) write() wire.switch_wired('remove', 'up') return False log.info('connect wireless success') check_connect = wire.check_auto_connect() if check_connect is not True: pag.hotkey('ctrl', 'alt', 'tab') time.sleep(1) pag.hotkey('ctrl', 'alt', 'f4') report.fail_report('Fail:%s' % check_connect, file_name) write() wire.switch_wired('remove', 'up') return False if wire.del_profile() is not True: report.fail_report('Fail:delete profile fail', file_name) write() wire.switch_wired('remove', 'up') return False time.sleep(10) if wire.ping() is False: pag.hotkey('ctrl', 'alt', 'f4') log.info('delete profile,ping test success') report.pass_report(file_name) write('pass') wire.switch_wired('remove', 'up') else: pag.hotkey('ctrl', 'alt', 'f4') report.fail_report('Fail:delete profile complete,but can ping to network,check time delay os connection', file_name) write() wire.switch_wired('remove', 'up') return False
def __init__(self, cert_name='ROOTCA'): self.cert_name = cert_name self.log = common_function.logger()
from Test_Script import wired_common import os import pyautogui import time from Test_Script import common_function log = common_function.logger() # Description: Get value for vpn info from registry. # Parameters: # Input: N/A # Output: reg_auto_start, reg_gw, reg_group, reg_type, reg_username # Example: vpn_info_reg = get_value_from_reg() def get_value_from_reg(): vpn_reg = wired_common.get_config("./Test_Data/WiredNetwork/", "wired_configuration.yml", "vpn_reg") reg_auto_start_string = "mclient --quiet get " + vpn_reg + "/AutoStart" reg_auto_start = os.popen(reg_auto_start_string).readlines()[0].strip() reg_gw_string = "mclient --quiet get " + vpn_reg + "/VPNC/Gateway" reg_gw = os.popen(reg_gw_string).readlines()[0].strip() reg_group_string = "mclient --quiet get " + vpn_reg + "/VPNC/Group" reg_group = os.popen(reg_group_string).readlines()[0].strip() reg_type_string = "mclient --quiet get " + vpn_reg + "/Type" reg_type = os.popen(reg_type_string).readlines()[0].strip() reg_username_string = "mclient --quiet get " + vpn_reg + "/VPNC/Username" reg_username = os.popen(reg_username_string).readlines()[0].strip() return reg_auto_start, reg_gw, reg_group, reg_type, reg_username def set_vpn_as_cisco(target_type, vpn_cisco_gw, vpn_cisco_gn, vpn_cisco_gp,
from Test_Script import thinpro_view from Test_Script import view_ftp from Test_Script import common_function as report from Test_Script import view_common_functions from Test_Script import common_connection import time import os from Test_Script import get_config log_for_vmware_spec = report.logger() # Create instance of log def run_single(server_name, operation, name, password): case = thinpro_view.ViewSpec(server_name, name, password) name_in_config = get_config.get_config(name) common_connection.clear_connections("view") # case.del_vmware_in_task_bar() # Delete vmware in task bar if exists # case.del_connection() # If vmware view exists in task bar, kill the process of vmware. max_loc = case.image_match('vmware_in_task_bar', 1) if max_loc is not None: os.popen('pkill vmware') vm_process = os.popen("ps -A | grep vmware").readlines() if len(vm_process) == 0: log_for_vmware_spec.info("Kill process for vmware successfully.") case.create_connection() if name == 'spec_username2': username = case.edit_connection_spec2() else: username = case.edit_connection()
from Test_Script import thinpro_view from Test_Script import view_ftp from Test_Script import certificate import pyautogui as pag import time import os from Test_Script import common_function as report from Test_Script import get_config as gc pcoip_usbr_log = report.logger() def run(server_name='pcoip_server_name'): file_name = 'VMware_win10_USB_key_USBR_pcoip' local_usb = check_usb() if local_usb is not True: report.fail_report(local_usb, file_name) return False operation = '//15.83.240.98/Automation/Linux/scripts/usbkey_redirection.exe' cer = certificate.Cert('ROOTCA') find_cert = cer.check_cert() if find_cert is False: insert = cer.import_cert() if insert is False: report.fail_report('import cert fail', file_name) return False pcoip_usbr_log.info('import cert success for %s' % file_name) name, password = '******', 'password' case = thinpro_view.View(server_name, name, password) case.del_connection() case.create_connection()
from Lib.thinpro_citrix import NewController import time import pyautogui import datetime from Test_Script import certificate from Lib import my_ftp import os import subprocess from Test_Script.common_function import logger, pass_report, fail_report my_logger = logger() myftp = my_ftp.MyFtp() def write_citrix_offset_to_yml(): remove_citrix() create_citrix() citrix_icon = NewController('desktop_root.png', ['citrix_icon.png'], 'ICON') citrix_icon.rightclick_position('') 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') rdp_connnection_table_controller.click_position_tool( 'connection_table_current_mode.png') edit_dict = { 'connection_table_current_mode':
def __init__(self, server_name, username, password): self.server_name = server_name self.username = username self.password = password self.log = common_function.logger()