Ejemplo n.º 1
0
 def logon(self, profile):
     print('判断是否安装rootca, 如果没装则装到root下面')
     if not self.check_cert('rootca'):
         self.install_ca('.\\test_data\\rootca.cer')
     print('判断autolaunch是否off, 如果为off, 手动启动connection')
     if profile['Autolaunch'] == 'OFF':
         self.utils(profile, 'launch', 'conn')
     time.sleep(profile['Launchdelay'])
     time.sleep(5)
     if not EasyshellLib.getElement('StorePool').Exists():
         print('Storefront桌面池没有启动, 测试FAIL!')
         return False
     if profile['DesktopName']:
         CommonLib.TextControl(
             Name=profile['DesktopName']).GetParentControl().Click()
         wnd = self.wait_element(
             CommonLib.WindowControl(
                 RegexName='{} - .*'.format(profile['DesktopName'])), 30)
         if wnd:
             print('开始上传test_storefont.txt, 等待15秒')
             os.system('echo test_logon>{}'.format(self.local_file))
             ftp = CommonLib.FTPUtils(self.ftp_token['ip'],
                                      self.ftp_token['username'],
                                      self.ftp_token['password'])
             ftp.change_dir(self.log_path)
             ftp.upload_file(self.local_file, self.local_file)
             # -------close license expire dialog for windows7- -----------
             time.sleep(15)
             # ------------------------------------------------------------
             print('开始等待vdi的结果返回,300s')
             status = self.get_test_status(ftp, 300)
             ftp.close()
             if not status:
                 print('获取vdi返回结果超时(300秒)')
                 return False
             if status.upper() == 'PASS':
                 print('logon pass')
                 print('检查session窗口{}是否关系(logoff成功)'.format(
                     profile['DesktopName']))
                 if self.wait_element(
                         CommonLib.WindowControl(
                             RegexName='{} - Desktop Viewer'.format(
                                 profile['DesktopName'])), 180, False):
                     EasyshellLib.getElement('Disconnect').Click()
                 else:
                     print('Logoff 超时!!')
             else:
                 print('测试Fail, 收到VDI的结果没有PASS')
             print('所有Storefont测试结束')
     elif profile['AppName']:
         return True
     else:
         print('No app or desktop need to be launch, logon exit')
         if EasyshellLib.getElement('Disconnect').Exists():
             EasyshellLib.getElement('Disconnect').Click()
         return True
Ejemplo n.º 2
0
 def utils(self, profile='', op='exist', item='normal'):
     """
     :param profile:  test profile, [test1,test2,,standardApp...]
     :param op: test option [exist | notexist | shown | edit | delete |launch |default]
     :param item: specific for connection, if item=connection, connection button element=textcontrol.getparent,
             else element=textcontrol.getparent.getparent
     :return: Bool
     """
     name = profile["Name"]
     if op.upper() == 'NOTEXIST':
         if CommonLib.TextControl(Name=name).Exists(0, 0):
             self.Logfile('Check {}-{} Not Exist Fail'.format(
                 profile, name))
             self.capture(
                 profile,
                 'Check {}-{} Not Exist Fail'.format(profile, name))
             return False
         else:
             self.Logfile('Check {}-{} Not Exist PASS'.format(
                 profile, name))
             return True
     if CommonLib.TextControl(Name=name).Exists(0, 0):
         txt = CommonLib.TextControl(Name=name)
     else:
         print("{}-{} Not Exist".format(profile, name))
         return False
     if 'CONN' in item.upper():
         appControl = txt.GetParentControl()
     else:
         appControl = txt.GetParentControl().GetParentControl()
     launch = txt  # type=txtcontrol
     if appControl.ButtonControl(AutomationId='editButton').Exists(1, 1):
         edit = appControl.ButtonControl(AutomationId='editButton')
     else:
         edit = appControl.ButtonControl(AutomationId='EditButton')
     if appControl.ButtonControl(AutomationId='deleteButton').Exists(1, 1):
         delete = appControl.ButtonControl(AutomationId='deleteButton')
     else:
         delete = appControl.ButtonControl(AutomationId='DeleteButton')
     if op.upper() == 'LAUNCH':
         launch.Click()
         return True
     elif op.upper() == 'EDIT':
         edit.Click()
         return True
     elif op.upper() == 'SHOWN':
         if txt.IsOffScreen:
             return False
         else:
             return True
     elif op.upper() == 'DEFAULT':
         print('home')
         appControl.ButtonControl(AutoamtionId='homeButton').Click()
     elif op.upper() == 'DELETE':
         try:
             delete.Click()
             EasyshellLib.getElement('DeleteYes').Click()
             EasyshellLib.getElement('APPLY').Click()
             return True
         except:
             self.Logfile("[FAIL]:App {} Delete\nErrors:\n{}\n".format(
                 name, traceback.format_exc()))
             self.capture(
                 profile, "[FAIL]:App {} Delete\nErrors:\n{}\n".format(
                     name, traceback.format_exc()))
             return False
     else:
         return True