示例#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
示例#2
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'])
        print('检查桌面池...')
        if not self.wait_element(CommonLib.PaneControl(AutomationId='793')):
            print('桌面池没有出现, 测试Fail')
            return False
        time.sleep(3)
        # launch desktop or app
        if profile['AppName']:
            CommonLib.WindowControl(Name='VMware Horizon Client').Click()
            # must add above click, or else will below focus fail
            app_name = CommonLib.PaneControl(Name=profile['AppName'])
            app_name.SetFocus()
            app_name.DoubleClick()
            wait_time = 30000
            current_cycle = 0
            while 1:
                if current_cycle > wait_time:
                    break
                """
                Code here to check app windows show up
                """
        elif profile['DesktopName']:
            print('让需要启动的桌面图标{}显示出来'.format(profile['DesktopName']))
            CommonLib.WindowControl(Name='VMware Horizon Client').Click()
            # must add above click, or else will below focus fail
            desktop_name = CommonLib.PaneControl(Name=profile['DesktopName'])
            desktop_name.SetFocus()
            desktop_name.DoubleClick()
            print('检查VMWare Session窗口{}是否出现'.format(profile['DesktopName']))
            if self.wait_element(
                    CommonLib.WindowControl(Name=profile['DesktopName']), 30):
                print('开始上传test_vmware.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('开始点击license对话框')
                x, y = self.get_resolution()
                CommonLib.Click(int(x / 2), int(y / 3))
                CommonLib.SendKey(CommonLib.Keys.VK_ESCAPE)
                # ------------------------------------------------------------
                print('开始等待vdi的结果返回,300s')
                status = self.get_test_status(ftp, 300)
                ftp.close()
                if not status:
                    print('获取vdi返回结果超时(300秒)')
                    return False
                print('finished wait get test status', status)
                if status.upper() == 'PASS':
                    print('logon pass')
                    print('检查session窗口{}是否关系(logoff成功)'.format(
                        profile['DesktopName']))
                    if self.wait_element(
                            CommonLib.WindowControl(
                                Name=profile['DesktopName']), 180, False):
                        EasyshellLib.getElement('VMwarePool').Close()
                    else:
                        print('Logoff 超时!!')
                else:
                    print('测试Fail, 收到VDI的结果没有PASS')
                print('所有VMWare测试结束')

        else:
            print('do not need to launch session or app')
            return