예제 #1
0
 def yztc_dl(self):
     '''判断当前是否跳转重新登录的提示'''
     result = automation.HyperlinkControl(Depth=11, Name='账号密码登录')
     if automation.WaitForExist(result, 5):
         result.Click()
         return 1
     else:
         raise ('yztc_dl异常')
예제 #2
0
 def lddb(self):
     # 判断页数是否是相同不相同则继续点击下一页
     time.sleep(5)
     name = REDIS_GZ.hget('specify_account_yctAppNo_page')
     for i in range(1, 3):
         time.sleep(2)
         automation.SendKeys('{Down}')
     for i in range(1, 6):
         for x in range(1, 8):
             res = REDIS_GZ.hget('specify_account_session')
             automation.SendKeys('{Down}')
             if 'false' == res['session']:
                 pyautogui.screenshot(IMGSRC)
                 imgobj = file + r'\th.jpg'
                 imsrc = ac.imread(IMGSRC)
                 imobj = ac.imread(imgobj)
                 match_result = ac.find_template(imsrc, imobj, 0.8)
                 if match_result:
                     automation.HyperlinkControl(Depth=17,
                                                 Name='退回修改',
                                                 foundIndex=i).Click()
                     if self.gain_session(name='退回修改') == 2:
                         return 1
                     elif self.restart_login == True:
                         return 1
                     else:
                         self.lddb()
                 imgobj = file + r'\txcg.jpg'
                 imobj = ac.imread(imgobj)
                 match_result = ac.find_template(imsrc, imobj, 0.8)
                 if match_result:
                     automation.HyperlinkControl(Depth=17,
                                                 Name='填报成功(查看详情)').Click()
                     if self.gain_session(name='填报成功') == 2:
                         return 1
                     elif self.restart_login == True:
                         return 1
                     else:
                         self.lddb()
             else:
                 continue
     if name['getpage'] == name['total']:
         return 1
     else:
         return
예제 #3
0
 def portal_yct(self):
     '''第一次跳转到登录页'''
     result = automation.EditControl(
         Depth=11, Name='开办企业申请信息填写人需进行实名认证,系统将跳转至“一网通办”总门户进行用户注册和认证')
     if automation.WaitForExist(result, 5):
         automation.HyperlinkControl(Depth=10, Name='确定').Click()
         return 1
     else:
         raise ('portal_yct异常')
예제 #4
0
 def attendanceStatistics(self):
     """
     选择考勤统计页签
     :param Name: 标签元素名称
     :param Depth: 空间深度
     :param foundIndex: 同种类控件序列号
     :return: 页签控件
     """
     try:
         flag = uiautomation.HyperlinkControl(
             AutomationId="LinkAttendanceData2")
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
예제 #5
0
 def changeaccount(self):
     time.sleep(2)
     try:
         automation.SendKeys('{Ctrl}k{Ctrl}k')
         time.sleep(2)
         automation.SendKeys(
             'http://yct.sh.gov.cn/portal_yct/webportal/handle_progress.do?x=12{Enter}'
         )
     except Exception as e:
         print(e)
     else:
         time.sleep(5)
         pyautogui.screenshot(IMGSRC)
         imgobj = file + r'\tc.jpg'
         imsrc = ac.imread(IMGSRC)
         imobj = ac.imread(imgobj)
         match_result = ac.find_template(imsrc, imobj, 0.8)
         if match_result:
             automation.HyperlinkControl(Depth=12, Name='退出').Click()
             time.sleep(5)
             REDIS_GZ.hset('specify_account_session', {'session': 'false'})
             automation.HyperlinkControl(Depth=11, Name='账号密码登录').Click()
         else:
             self.restart_login = True
예제 #6
0
 def attendanceSummary(self, Name="考勤汇总", Depth=24, foundIndex=13):
     """
     选择原始数据页签
     :param Name: 标签元素名称
     :param Depth: 空间深度
     :param foundIndex: 同种类控件序列号
     :return: 页签控件
     """
     try:
         flag = uiautomation.HyperlinkControl(Name=Name,
                                              Depth=Depth,
                                              fondIndex=foundIndex)
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
예제 #7
0
 def attendanceMgt(self, Name="考勤处理", Depth=23, foundIndex=6):
     """
     选择原始数据页签
     :param Name: 标签元素名称
     :param Depth: 空间深度
     :param foundIndex: 同种类控件序列号
     :return: 页签控件
     """
     try:
         # flag = uiautomation.MenuItemControl(Name=Name, Depth=Depth, fondIndex=foundIndex)
         flag = uiautomation.HyperlinkControl(
             AutomationId="LinkAttendanceDeal1")
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
예제 #8
0
def _crystaldiskmark_run():
    try:
        auto.WindowControl(searchDepath = 1, Name = 'CrystalDiskMark 6.0.2 x64').GetWindowPattern().Close()
    except:
        time.sleep(1)
        
    run_path = os.path.join(os.path.expanduser("~"), 'Desktop')
    run_path += '//Performance Benchmark Tool//CrystalDiskMark//'
    os.chdir(run_path)
    #通过命令行安装,不使用strat以让程序阻塞
    os.system('start DiskMark64.exe')
    
    #打开程序并运行
    while(1):
        try:
            main_win = auto.WindowControl(searchDepath = 1, Name = 'CrystalDiskMark 6.0.2 x64')
            break
        except:
            time.sleep(1)
            
    main_win.HyperlinkControl(Name = 'All',searchDepath = 8).Click()
    #等待程序运行结束
    """ControlType: HyperlinkControl    ClassName:     AutomationId: All    Rect: (1193,145,1255,195)[62x50]    Name: Stop    Handle: 0x0(0)    Depth: 8    ValuePattern.Value: file:///C:/U"""
    while(1):
        time.sleep(10)
        if not auto.HyperlinkControl(searchDepath = 8,AutomationId = 'All',Name = 'Stop').Exists():
            break
        
            
    main_win = auto.WindowControl(searchDepath = 1, Name = 'CrystalDiskMark 6.0.2 x64')

    result_dict = {}
    result_dict['Seq_Q32T1_Read'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 6).Name
    print(main_win.DataItemControl(searchDepath = 7,FoundIndex = 6))
    result_dict['Seq_Q32T1_Write'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 7).Name    
    result_dict['4KiB_Q8T8_Read'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 9).Name
    result_dict['4KiB_Q8T8_Write'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 10).Name
    result_dict['4KiB_Q32T1_Read'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 12).Name
    result_dict['4KiB_Q32T1_Write'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 13).Name
    result_dict['4KiB_Q1T1_Read'] = main_win.DataItemControl(searchDepath = 7,foundIndex = 15).Name
    result_dict['4KiB_Q1T1_Write'] = main_win.DataItemControl(searchDepath = 7, foundIndex = 16).Name
    main_win.GetWindowPattern().Close()
    return result_dict
def main():
    firefoxWindow = automation.WindowControl(searchDepth = 1, ClassName = 'MozillaWindowClass')
    if not firefoxWindow.Exists(0):
        automation.Logger.WriteLine('please run Firefox first', automation.ConsoleColor.Yellow)
        return
    firefoxWindow.ShowWindow(automation.ShowWindow.Maximize)
    firefoxWindow.SetActive()
    time.sleep(1)
    tab = automation.TabControl(searchFromControl= firefoxWindow)
    newTabButton = automation.ButtonControl(searchFromControl= tab, searchDepth= 1)
    newTabButton.Click()
    edit = automation.EditControl(searchFromControl= firefoxWindow)
    # edit.Click()
    edit.SendKeys('http://global.bing.com/?rb=0&setmkt=en-us&setlang=en-us{Enter}')
    time.sleep(2)
    searchEdit = automation.FindControl(firefoxWindow,
                           lambda c:
                           (isinstance(c, automation.EditControl) or isinstance(c, automation.ComboBoxControl)) and c.Name == 'Enter your search term'
                           )
    # searchEdit.Click()
    searchEdit.SendKeys('Python-UIAutomation-for-Windows site:github.com{Enter}', 0.05)
    link = automation.HyperlinkControl(searchFromControl= firefoxWindow, SubName = 'yinkaisheng/Python-UIAutomation-for-Windows')
    automation.Win32API.PressKey(automation.Keys.VK_CONTROL)
    link.Click()  #press control to open the page in a new tab
    automation.Win32API.ReleaseKey(automation.Keys.VK_CONTROL)
    newTab = automation.TabItemControl(searchFromControl= tab, SubName = 'yinkaisheng/Python-UIAutomation-for-Windows')
    newTab.Click()
    starButton = automation.ButtonControl(searchFromControl= firefoxWindow, Name = 'Star this repository')
    if starButton.Exists(5):
        automation.GetConsoleWindow().SetActive()
        automation.Logger.WriteLine('Star Python-UIAutomation-for-Windows after 2 seconds', automation.ConsoleColor.Yellow)
        time.sleep(2)
        firefoxWindow.SetActive()
        time.sleep(1)
        starButton.Click()
        time.sleep(2)
예제 #10
0
def _3dmark_run():
    try:
        auto.PaneControl(searchDepth = 1,Name = '3DMark Professional Edition - Google Chrome').GetPattern(10009).Close()
    except:
        time.sleep(1)
    
    try:
    
        auto.WindowControl(Name = '3DMark Professional Edition',searchDepth = 1).GetWindowPattern().Close()
            
    except:
        time.sleep(1)


    run_path = 'C://Program Files//UL//3DMark//'
    os.chdir(run_path)
    os.system('start 3DMark.exe')
   
    time.sleep(5)
    
    
    try:
        setup_path = 'C://Program Files (x86)//Google//Chrome//Application'
        os.chdir(setup_path)
    except:
        setup_path = os.path.join(os.path.expanduser("~"), 'AppData')
        setup_path +='//Local//Google//Chrome//Application//'
        os.chdir(setup_path)
        
    
    while(1):
        try:
            web_path = 'start chrome.exe --start-maximized ' + auto.TextControl(searchDepth = 8,Name = 'HOME').GetLegacyIAccessiblePattern().Value
            break
        except:
            time.sleep(1)
            
        try:
            web_path = 'start chrome.exe --start-maximized ' + auto.HyperlinkControl(searchDepth = 8,Name = 'HOME').GetLegacyIAccessiblePattern().Value
            break
        except:
            time.sleep(1)
            
    os.system(web_path)   

        #关闭提示
    time.sleep(4)
    try: 
        auto.ButtonControl(searchDepth = 3,Name = 'Advanced').Click()
        auto.HyperlinkControl(searchDepth = 5,Name = 'Proceed to 127.0.0.1 (unsafe)').Click()
    except:
        time.sleep(1)
        
    try: 
        auto.ButtonControl(searchDepth = 3,Name = '高级').Click()
        auto.HyperlinkControl(searchDepth = 5,Name = '继续前往127.0.0.1(不安全)').Click()
    except:
        time.sleep(1)
        
    try:
        auto.PaneControl(searchDepth = 1,Name = '3DMark Professional Edition - Google Chrome').SetActive()
    except:
        time.sleep(1)
        
    result_dict = {}
    #跳转到basic选项卡运行测试并等待结果
    while(1):
        try:
            auto.HyperlinkControl(searchDepth= 8,Name = 'BENCHMARKS').Click()
           
            break
        except:
            time.sleep(1)
            
            
     
    time.sleep(3)
      
    while(1):
        try:
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').SendKeys('{Down 3}')
            auto.TextControl(searchDepth = 14,Name = 'Time Spy').Click()
            time.sleep(2)
            auto.HyperlinkControl(searchDepth = 15,Name = 'RUN').Click()
            break
        except:
            time.sleep(1)
    
    
    #等待运行结果
    while(1):
        try:
            if not auto.TextControl(searchDepth = 11,Name = 'Running benchmark').Exists(0.1):
                break
        except:
            time.sleep(3)
            
   
    #光标移动到结果读取结果  
    
    
    time_spy = {}
       
        
    while(1):
        try:    
            try:
                time_spy['Score'] = "".join(auto.CustomControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())
                time_result = auto.CustomControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
            except:
                time_spy['Score'] = "".join(auto.GroupControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())
                time_result = auto.GroupControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
                
  
            time_spy['Graphics Score'] = "".join(time_result.ListControl(searchDepth = 11,foundIndex = 1).TextControl(foundIndex = 3).Name.split())  

            time_spy['CPU score'] = "".join(time_result.ListControl(searchDepth = 11,foundIndex = 4).TextControl(foundIndex = 3).Name.split())

            result_dict['Time Spy'] = time_spy
       
            break
        except:
       
            time.sleep(1)
    


    time.sleep(180)
    #fire strike
    while(1):
        try:
            auto.HyperlinkControl(searchDepth= 8,Name = 'BENCHMARKS').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').SendKeys('{Down 15}')
            auto.TextControl(searchDepth = 14,Name = 'Fire Strike').Click()
            time.sleep(2)
            auto.HyperlinkControl(searchDepth = 15,Name = 'RUN').Click()
            break
        except:
            time.sleep(1)
            
    while(1):
        try:
            if not auto.TextControl(searchDepth = 11,Name = 'Running benchmark').Exists():
                break
        except:
            time.sleep(3)
            
    fire_strike = {}  

    while(1):
        try:
        
            try:
                fire_strike['Score'] = "".join(auto.CustomControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())      
                fire_result = auto.CustomControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
            except:
                fire_strike['Score'] = "".join(auto.GroupControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())
                fire_result = auto.GroupControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
                
            fire_strike['Graphics score'] = "".join(fire_result.ListControl(searchDepth = 11,foundIndex = 1).TextControl(foundIndex = 3).Name.split())
            fire_strike['Physics score'] = "".join(fire_result.ListControl(searchDepth = 11,foundIndex = 4).TextControl(foundIndex = 3).Name.split())
            fire_strike['Combined score'] = "".join(fire_result.ListControl(searchDepth = 11,foundIndex = 6).TextControl(foundIndex = 3).Name.split())    
            result_dict['Fire Strike'] = fire_strike
            break
        except:
            time.sleep(1)
            
    time.sleep(180)
    #Night raid
    while(1):
        try:
            auto.HyperlinkControl(searchDepth= 8,Name = 'BENCHMARKS').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').SendKeys('{Down 25}')
            auto.TextControl(searchDepth = 14,Name = 'Night Raid').Click()
            time.sleep(2)
            break
        except:
            time.sleep(1)
            
    try:     
        if auto.HyperlinkControl(searchDepth = 15,Name = 'INSTALL').Exists():
            auto.HyperlinkControl(searchDepth = 15,Name = 'INSTALL').Click()
    except:
        time.sleep(1)
        
        
    while(1):
        try:
            auto.HyperlinkControl(searchDepth = 15,Name = 'RUN').Click()
            break
        except:
            time.sleep(10)
            
    while(1):
        try:
            if not auto.TextControl(searchDepth = 11,Name = 'Running benchmark').Exists():
                break
        except:
            time.sleep(3)
            
    night_raid = {}

    while(1):
        try:
            try:
                night_raid['Score'] = "".join(auto.CustomControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())

                night_result = auto.CustomControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
            except:
                night_raid['Score'] = "".join(auto.GroupControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())
                night_result = auto.GroupControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')   
                
            night_raid['Graphics score'] = "".join(night_result.ListControl(searchDepth = 11,foundIndex = 1).TextControl(foundIndex = 3).Name.split())
            night_raid['CPU score'] = "".join(night_result.ListControl(searchDepth = 11,foundIndex = 4).TextControl(foundIndex = 3).Name.split())
            result_dict['Night Raid'] = night_raid
            break
        except:
            time.sleep(1)
    
    time.sleep(180)        
    #sky drive
    while(1):
        try:
        
            auto.HyperlinkControl(searchDepth= 8,Name = 'BENCHMARKS').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').SendKeys('{Down 25}')
            auto.TextControl(searchDepth = 14,Name = 'Sky Diver').Click()
            time.sleep(2)
            auto.HyperlinkControl(searchDepth = 15,Name = 'RUN').Click()
            break
        except:
            time.sleep(1)
            
    while(1):
        try:
            if not auto.TextControl(searchDepth = 11,Name = 'Running benchmark').Exists():
                break
        except:
            time.sleep(3)
    
    sky_drive = {}
    while(1):
        try:
            try:
                sky_drive['Score'] = "".join(auto.CustomControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())
                sky_result = auto.CustomControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
            except:
                sky_drive['Score'] = "".join(auto.GroupControl(searchDepth = 10,AutomationId = 'viewResultsControls').TextControl(foundIndex = 3).Name.split())
                sky_result = auto.GroupControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')   
                
            sky_drive['Graphics score'] = "".join(sky_result.ListControl(searchDepth = 11,foundIndex = 1).TextControl(foundIndex = 3).Name.split())
            sky_drive['Physics score'] = "".join(sky_result.ListControl(searchDepth = 11,foundIndex = 4).TextControl(foundIndex = 3).Name.split())
            sky_drive['Combined score'] = "".join(sky_result.ListControl(searchDepth = 11,foundIndex = 9).TextControl(foundIndex = 3).Name.split())
            result_dict['Sky Drive'] = sky_drive  
            break
        except:
            time.sleep(1)
      
    time.sleep(180)
    
    #api
    while(1):
        try:
            auto.HyperlinkControl(searchDepth= 8,Name = 'BENCHMARKS').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').Click()
            auto.TextControl(searchDepth = 11,Name = 'Benchmarks').SendKeys('{Down 30}')
            auto.TextControl(searchDepth = 14,Name = 'API Overhead feature test').Click()
            time.sleep(2)
            auto.HyperlinkControl(searchDepth = 15,Name = 'RUN').Click()
            break
        except:
            time.sleep(1)
         
    while(1):
        try:
            if not auto.TextControl(searchDepth = 11,Name = 'Running benchmark').Exists():
                break
        except:
            time.sleep(3)
    
    
    api_score = {}

    while(1):
        try:  
            api_result = auto.GroupControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')
               
            api_score['DirectX 11 multi-thread'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 1).TextControl(foundIndex = 3).Name.split())
            api_score['DirectX 11 single-thread'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 2).TextControl(foundIndex = 3).Name.split())
            api_score['DirectX 12'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 3).TextControl(foundIndex = 3).Name.split())
            api_score['Vulkan'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 4).TextControl(foundIndex = 3).Name.split())
            result_dict['api'] = api_score
            break
            
        except:
            api_result = auto.CustomControl(searchDepth = 10,AutomationId = 'RESULT_SINGLE')       
            api_score['DirectX 11 multi-thread'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 1).TextControl(foundIndex = 3).Name.split())
            api_score['DirectX 11 single-thread'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 2).TextControl(foundIndex = 3).Name.split())
            api_score['DirectX 12'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 3).TextControl(foundIndex = 3).Name.split())
            api_score['Vulkan'] = "".join(api_result.ListControl(searchDepth = 11,foundIndex = 4).TextControl(foundIndex = 3).Name.split())
            result_dict['api'] = api_score  
            break
            
    #关闭窗口
    while(1):
        try:
            auto.PaneControl(searchDepth = 1,Name = '3DMark Professional Edition - Google Chrome').GetPattern(10009).Close()
            auto.WindowControl(Name = '3DMark Professional Edition',searchDepth = 1).GetWindowPattern().Close()
            break
        except:
            time.sleep(1)
    
    return result_dict
예제 #11
0
def _pcmark10_run():
 
    try:
        auto.PaneControl(searchDepth = 1,Name = 'PCMark 10 Professional Edition - Google Chrome').GetPattern(10009).Close()
    except:
        time.sleep(1)
     
    try:
        auto.WindowControl(Name = 'PCMark 10 Professional Edition',searchDepth = 1).GetWindowPattern().Close()
    except:
        time.sleep(1)

    run_path = 'C://Program Files//UL//PCMark 10//'
    os.chdir(run_path)
    
    
    os.system('start /max PCMark10.exe')
    
    time.sleep(15)

    """
    while(1):
        try:
            auto.ListItemControl(searchDepth = 7,Name = 'BENCHMARKS').Click(waitTime = 1)
            if auto.TextControl(searchDepth = 4,Name = 'IGNORE').Exists():
                auto.TextControl(searchDepth = 4,Name = 'IGNORE').Click()
            break
        except:
            time.sleep(1)
        
        time.sleep(10)
    """   

    try:
        setup_path = 'C://Program Files (x86)//Google//Chrome//Application'
        os.chdir(setup_path)
    except:
        setup_path = os.path.join(os.path.expanduser("~"), 'AppData')
        setup_path +='//Local//Google//Chrome//Application//'
        os.chdir(setup_path)
        
    
    while(1):
        try:
            web_path = 'start chrome.exe --start-maximized ' + auto.TextControl(searchDepth = 8,Name = 'HOME').GetLegacyIAccessiblePattern().Value
            break
        except:
            time.sleep(1)
            
        try:
            web_path = 'start chrome.exe --start-maximized ' + auto.HyperlinkControl(searchDepth = 8,Name = 'HOME').GetLegacyIAccessiblePattern().Value

            break
        except:
            time.sleep(1)
    
     
    os.system(web_path)   

        #关闭提示
    time.sleep(4)
 
    try: 
        auto.ButtonControl(searchDepth = 3,Name = 'Advanced').Click()
        auto.HyperlinkControl(searchDepth = 5,Name = 'Proceed to 127.0.0.1 (unsafe)').Click()
    except:
        time.sleep(1)
        
    try: 
        auto.ButtonControl(searchDepth = 3,Name = '高级').Click()
        auto.HyperlinkControl(searchDepth = 5,Name = '继续前往127.0.0.1(不安全)').Click()
    except:
        time.sleep(1)
        
  
    try:
        auto.PaneControl(searchDepth = 1,Name = 'PCMark 10 Professional Edition - Google Chrome').SetActive()
    except:
        time.sleep(1)
    

    #跳转到basic选项卡运行测试并等待结果
  
    while(1):
        try:
            auto.HyperlinkControl(searchDepth= 5,AutomationId = 'headerLogo').Click()
            auto.HyperlinkControl(searchDepth= 8,Name = 'BENCHMARKS').Click()
           
            break
        except:
            time.sleep(1)
            
            
     
            
    
    time.sleep(5)
    while(1):
        try:
            auto.TextControl(searchDepth = 13,Name = 'PCMark 10 Extended').Click()
            time.sleep(2)
            auto.HyperlinkControl(searchDepth = 10,Name = 'RUN').Click()
            break
        except:
            time.sleep(1)
    
    
    #等待运行结果
    while(1):
        try:
            if auto.PaneControl(Name = 'PCMark 10 progress - Google Chrome',searchDepth = 1).Exists() == False :
                break
        except:
            time.sleep(10)
    
        

    #光标移动到结果读取结果  
    time.sleep(2)
    result_dict = {}
    while(1):
        
        if auto.GroupControl(searchDepth = 8,AutomationId = 'viewResults').Exists(0.1):
            result_win = auto.GroupControl(searchDepth = 8,AutomationId = 'viewResults')    
            break
            
        elif auto.CustomControl(searchDepth = 8,AutomationId = 'viewResults').Exists(0.1):
            result_win = auto.CustomControl(searchDepth = 8,AutomationId = 'viewResults')
            break
        
        
    print(result_win)
    time.sleep(2)
    i = 0
    while(1):
        if i == 20:
            i = 0
            
        try:
            if result_win.CustomControl(searchDepth = 9,foundIndex = i).TextControl(searchDepth = 10,Name = 'PCMark 10 Extended').Exists(0.1):
                print(result_win.CustomControl(searchDepth = 9,foundIndex = i).TextControl(searchDepth = 10))
                result_dict['Score'] = "".join(result_win.CustomControl(Depath = 9,foundIndex = i+1).TextControl(foundIndex = 1).Name.split())
                break  
        except:
            time.sleep(1)
            
        try:    
            if result_win.GroupControl(searchDepth = 9,foundIndex = i).TextControl(searchDepth = 10,Name = 'PCMark 10 Extended').Exists(0.1):
                print(result_win.GroupControl(searchDepth = 9,foundIndex = i).TextControl(searchDepth = 10))
                result_dict['Score'] = "".join(result_win.GroupControl(Depath = 9,foundIndex = i+1).TextControl(foundIndex = 1).Name.split())
                break            
        except:
            time.sleep(1)
        
        print(i)
        i += 1  
      
 
    
    try:
        result_dict['Essentials'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 1).TextControl(foundIndex = 3).Name.split())
        result_dict['App Start-up Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 2).TextControl(foundIndex = 5).Name.split())
        result_dict['Video Conferencing Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 3).TextControl(foundIndex = 5).Name.split())
        result_dict['Web Browsing Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 4).TextControl(foundIndex = 5).Name.split())
        result_dict['Productivity'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 5).TextControl(foundIndex = 3).Name.split())
        result_dict['Spreadsheets Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 6).TextControl(foundIndex = 5).Name.split())
        result_dict['Writing Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 7).TextControl(foundIndex = 5).Name.split())
        result_dict['Digital Content Creation'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 8).TextControl(foundIndex = 3).Name.split())
        result_dict['Photo Editing Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 9).TextControl(foundIndex = 5).Name.split())
        result_dict['Rendering and Visualization Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 10).TextControl(foundIndex = 5).Name.split())
        result_dict['Video Editing Score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 11).TextControl(foundIndex = 5).Name.split())
        
        result_dict['Gaming'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 12).TextControl(foundIndex = 3).Name.split())
        result_dict['Graphics score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 13).TextControl(foundIndex = 5).Name.split())           
        result_dict['Physics score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 14).TextControl(foundIndex = 5).Name.split())            
        result_dict['Combined score'] = "".join(result_win.ListControl(searchDepth = 9,foundIndex = 15).TextControl(foundIndex = 5).Name.split()) 
        
     
        #关闭窗口
 
        auto.PaneControl(searchDepth = 1,Name = 'PCMark 10 Professional Edition - Google Chrome').GetPattern(10009).Close()
        auto.WindowControl(Name = 'PCMark 10 Professional Edition',searchDepth = 1).GetWindowPattern().Close()
    except:
        auto.PaneControl(searchDepth = 1,Name = 'PCMark 10 Professional Edition - Google Chrome').GetPattern(10009).Close()
        auto.WindowControl(Name = 'PCMark 10 Professional Edition',searchDepth = 1).GetWindowPattern().Close()

    
    return result_dict
예제 #12
0
    def find(self, ControlTypeName="Control", **kwargs):

        if ControlTypeName == "Control":
            control = auto.Control(**kwargs)

        if ControlTypeName == "ButtonControl":
            control = auto.ButtonControl(**kwargs)

        if ControlTypeName == "CalendarControl":
            control = auto.CalendarControl(**kwargs)

        if ControlTypeName == "CheckBoxControl":
            control = auto.CheckBoxControl(**kwargs)

        if ControlTypeName == "ComboBoxControl":
            control = auto.ComboBoxControl(**kwargs)

        if ControlTypeName == "CustomControl":
            control = auto.CustomControl(**kwargs)

        if ControlTypeName == "DataGridControl":
            control = auto.DataGridControl(**kwargs)

        if ControlTypeName == "DataItemControl":
            control = auto.DataItemControl(**kwargs)

        if ControlTypeName == "DocumentControl":
            control = auto.DocumentControl(**kwargs)

        if ControlTypeName == "EditControl":
            control = auto.EditControl(**kwargs)

        if ControlTypeName == "GroupControl":
            control = auto.GroupControl(**kwargs)

        if ControlTypeName == "HeaderControl":
            control = auto.HeaderControl(**kwargs)

        if ControlTypeName == "HeaderItemControl":
            control = auto.HeaderItemControl(**kwargs)

        if ControlTypeName == "HyperlinkControl":
            control = auto.HyperlinkControl(**kwargs)

        if ControlTypeName == "ImageControl":
            control = auto.ImageControl(**kwargs)

        if ControlTypeName == "ListControl":
            control = auto.ListControl(**kwargs)

        if ControlTypeName == "ListItemControl":
            control = auto.ListItemControl(**kwargs)

        if ControlTypeName == "MenuControl":
            control = auto.MenuControl(**kwargs)

        if ControlTypeName == "MenuBarControl":
            control = auto.MenuBarControl(**kwargs)

        if ControlTypeName == "MenuItemControl":
            control = auto.MenuItemControl(**kwargs)

        if ControlTypeName == "PaneControl":
            control = auto.PaneControl(**kwargs)

        if ControlTypeName == "ProgressBarControl":
            control = auto.ProgressBarControl(**kwargs)

        if ControlTypeName == "RadioButtonControl":
            control = auto.RadioButtonControl(**kwargs)

        if ControlTypeName == "ScrollBarControl":
            control = auto.ScrollBarControl(**kwargs)

        if ControlTypeName == "SemanticZoomControl":
            control = auto.SemanticZoomControl(**kwargs)

        if ControlTypeName == "SeparatorControl":
            control = auto.SeparatorControl(**kwargs)

        if ControlTypeName == "SliderControl":
            control = auto.SliderControl(**kwargs)

        if ControlTypeName == "SpinnerControl":
            control = auto.SpinnerControl(**kwargs)

        if ControlTypeName == "SplitButtonControl":
            control = auto.SplitButtonControl(**kwargs)

        if ControlTypeName == "StatusBarControl":
            control = auto.StatusBarControl(**kwargs)

        if ControlTypeName == "TabControl":
            control = auto.TabControl(**kwargs)

        if ControlTypeName == "TabItemControl":
            control = auto.TabItemControl(**kwargs)

        if ControlTypeName == "TextControl":
            control = auto.TextControl(**kwargs)

        if ControlTypeName == "ThumbControl":
            control = auto.ThumbControl(**kwargs)

        if ControlTypeName == "TitleBarControl":
            control = auto.TitleBarControl(**kwargs)

        if ControlTypeName == "ToolBarControl":
            control = auto.ToolBarControl(**kwargs)

        if ControlTypeName == "ToolTipControl":
            control = auto.ToolTipControl(**kwargs)

        if ControlTypeName == "TreeControl":
            control = auto.TreeControl(**kwargs)

        if ControlTypeName == "TreeItemControl":
            control = auto.TreeItemControl(**kwargs)

        if ControlTypeName == "WindowControl":
            control = auto.WindowControl(**kwargs)

        if control.Exists():
            return control
        else:
            name = kwargs.__str__().replace(":", ":")
            Log.logger().error("元素查找失败%s" % name)
            autogui.screenshot("../log/%s.png" % name)