def holidayPage4(self, Name="", Depth=10, foundIndex=16):
     """
     选择200条/页
     :return:
     """
     try:
         flag = uiautomation.TextControl(Name=Name,
                                         Depth=Depth,
                                         fondIndex=foundIndex)
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
Example #2
0
 def get_text_control(self, loc):
     try:
         if loc[0] == Wby.NAME:
             text_control = auto.TextControl(searchDepth=loc[2],
                                             Name=loc[1])
             logger.info("深度为_{}_,名字为_{}__的text_control获取成功".format(
                 loc[2], loc[1]))
             return text_control
         if loc[0] == Wby.AUTOMATIONID:
             text_control = auto.TextControl(searchDepth=loc[2],
                                             AutomationId=loc[1])
             logger.info("深度为_{}_,id为_{}__的text_control获取成功".format(
                 loc[2], loc[1]))
             return text_control
     except:
         if loc[0] == Wby.NAME:
             logger.exception("深度为_{}_,名字为_{}__的text_control获取失败".format(
                 loc[2], loc[1]))
         if loc[0] == Wby.AUTOMATIONID:
             logger.exception("深度为_{}_,id为_{}__的text_control获取失败".format(
                 loc[2], loc[1]))
def test_gitgui():
    # Clone폴더 값 정의
    clone_folder = "C:\\dev\\git\\UIAutomationExample"
    # Clone 대상 폴더가 존재할 경우 폴더를 지운다.
    import os
    if os.path.exists(clone_folder):
        os.system('rmdir /S /Q "{}"'.format(clone_folder))

    # Clone 대상 폴더가 없는지 확인한다.
    if os.path.exists(clone_folder):
        assert False, "clone대상폴더가 지워지지 않음"

    # GIT GUI를 실행시킨다.
    import uiautomation as auto
    # 검색영역 클릭하기
    auto.ButtonControl(searchDepth=3, Name='검색하려면 여기에 입력하십시오.').Click()
    # 검색영역에 값 입력하기
    auto.EditControl(searchDepth=3, Name='검색 상자').SendKeys('git gui')
    # Git GUI아이콘 클릭하기
    auto.TextControl(searchDepth=10, Name="Git GUI").Click()
    # 프로그램이 정상적으로 수행되었는지 확인한다.
    auto.WindowControl(searchDepth=1,  Name="Git Gui")

    # 상단 메뉴를 통해 Clone을 수행
    auto.MenuItemControl(searchDepth=8,  Name="Repository").Click()
    auto.MenuItemControl(searchDepth=8, Name="Repository")
    # inspect를 통해서 menu의 AutomationId가 48이므로 이를 활용
    auto.MenuItemControl(AutomationId = "48").Click()
    # 화면이 Clone Existing Repository 세부설정화면으로 이동되었는지 확인한다.
    # 아쉽게도 해당 APP은 "Clone Existing Repository"에 대한 정보를 확인할 수 없는 앱이어서
    # 이후 동작으로 확인할 수 밖에 없다.

    # Source location 및 Target Directory 값 정의
    source_location = "https://github.com/jjunghyup/UIAutomationExample.git"
    target_directory = "C:\\dev\\git\\UIAutomationExample"
    # Source Location값과 Target Directory값을 입력한다.
    auto.PaneControl(ClassName="TkChild", foundIndex=14).Click()
    auto.PaneControl(ClassName="TkChild", foundIndex=14).SendKeys(source_location)
    auto.PaneControl(ClassName="TkChild", foundIndex=11).Click()
    auto.PaneControl(ClassName="TkChild", foundIndex=11).SendKeys(target_directory)
    # 값이 정상적으로 입력된다.
    # 값을 Clipboard에 복사하고 붙여넣기 식으로 확인이 가능하지만 해당 내용은 이후에 작성 예정

    # Clone 버튼을 클릭한다.
    auto.PaneControl(ClassName="TkChild", foundIndex=18).Click()
    # Clone 대상폴더가 존재하는지 확인한다. 10초 동안 확인한다.
    result = False
    for i in range(0, 10):
        if os.path.exists(clone_folder):
           result = True

    assert result, "clone대상폴더가 존재 하지 않음"
 def currentMonth(self, Name="当月", Depth=22, foundIndex=13):
     """
     点击当月
     :param Name: 标签元素名称
     :param Depth: 空间深度
     :param foundIndex: 同种类控件序列号
     :return: 页签控件
     """
     try:
         flag = uiautomation.TextControl(Name=Name,
                                         Depth=Depth,
                                         fondIndex=foundIndex)
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
 def maskYes(self, Name="是", Depth=18, foundIndex=8):
     """
     点击选项:是
     :param Name: 标签元素名称
     :param Depth: 空间深度
     :param foundIndex: 同种类控件序列号
     :return: 页签控件
     """
     try:
         flag = uiautomation.TextControl(Name=Name,
                                         Depth=Depth,
                                         fondIndex=foundIndex)
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
 def last7days(self, Name="最近7天", Depth=22, foundIndex=9):
     """
     点击最近七天
     :param Name: 标签元素名称
     :param Depth: 空间深度
     :param foundIndex: 同种类控件序列号
     :return: 页签控件
     """
     try:
         flag = uiautomation.TextControl(Name=Name,
                                         Depth=Depth,
                                         fondIndex=foundIndex)
         flag.Click()
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
Example #7
0
def calc():
    os.system("start/b calc.exe")
    #找到计算器窗口
    # window = uiautomation.WindowControl(searchDepth=1,Name= "计算器")

    window = uiautomation.WindowControl(searchDepth=1, ClassName="CalcFrame")

    # print(window)
    #判断窗口是否存在
    if window.Exists():
        print("找到计算器了")
        #置顶窗口
        window.SetTopmost(isTopmost=True)
        #
        # #最大化窗口
        # window.Maximize()

        #激活窗口(从任务栏点出来)
        window.SetActive()

        #输出应用当前坐标
        # print(window.BoundingRectangle)

        # rest = window.BoundingRectangle
        # x = [rest.left,rest.right]
        # y = [rest.bottom,rest.top]
        # print(x,y)

    time.sleep(1)
    botton7 = uiautomation.ButtonControl(searchDepth=4, Name="7")
    botton7.Click()
    time.sleep(1)
    botton2 = uiautomation.ButtonControl(Name="加")
    botton2.Click()
    time.sleep(1)
    botton4 = uiautomation.ButtonControl(Name="4")
    botton4.Click()
    time.sleep(1)
    botton3 = uiautomation.ButtonControl(Name="等于")
    botton3.Click()
    time.sleep(1)
    reslult = uiautomation.TextControl(AutomationId="158")
    name = reslult.Name
    if int(name) == 11:
        print("测试成功")
        uiautomation.ButtonControl(Name="关闭").Click()
    else:
        print("测试失败")
 def operation(self, Name="操作", Depth=22, foundIndex=8):
     """
     操作
     :param Name:
     :param Depth:
     :param foundIndex:
     :return:
     """
     try:
         flag = uiautomation.TextControl(Name=Name,
                                         Depth=Depth,
                                         fondIndex=foundIndex)
         flag.Click()
         return flag
     except Exception as e:
         log.debug("Can not control EZAccess, because: %s" % e)
Example #9
0
def click_logout():
    ix_Window = uiautomation.WindowControl(Name="Avaya IX Workplace")
    ix_Window.SetFocus()

    btn_user = ix_Window.ButtonControl(Name="Open User Dashboard")
    btn_user.Click()
    time.sleep(1)

    btn_logout = ix_Window.ButtonControl(Name="SIGN OUT")
    btn_logout.Click()

    while uiautomation.TextControl(
            Name=
            "You have active calls, are you sure you want to logout application?"
    ).Exists(3):
        uiautomation.WindowControl(Name="Avaya IX Workplace").ButtonControl(
            Name="Yes").Click()
    time.sleep(2)
Example #10
0
 def DoubleClickByName(self, name):
     try:
         sleep(2)
         automation.TextControl(Name=name).DoubleClick()
     except Exception as e:
         print("文本点击异常" + '||原因:' + str(e))
Example #11
0
 def txtResults():
     return automation.TextControl(
         AutomationId="CalculatorResults")  # Windows 10
Example #12
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
Example #13
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
    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)
Example #15
0
 auto.Click(800, 500)
 auto.Click(500, 800)
 auto.ButtonControl(searchDepth=4,
                    Name=" 请选择X光片 ").GetNextSiblingControl().Click()
 time.sleep(1.5)
 auto.EditControl(searchDepth=6,
                  Name="文件名(N):").GetValuePattern().SetValue(z_path_name)
 auto.SendKey(0x0D)
 auto.SendKey(0x0D)
 auto.Click(600, 400)
 auto.Click(300, 600)
 auto.ButtonControl(searchDepth=4, Name=" 患者列表 ").Click()
 search_patient_name = auto.ButtonControl(searchDepth=4, Name="查找患者姓名")
 if not search_patient_name.Exists(maxSearchSeconds=60):
     print("查找失败")
 auto.TextControl(searchDepth=6, Name=patient_number).DoubleClick()
 auto.RadioButtonControl(searchDepth=6, Name="第二次测量").Click()
 auto.SendKey(0x0D)
 time.sleep(2)
 auto.ButtonControl(searchDepth=4, Name=" 请选择X光片 ").Click()
 time.sleep(1.5)
 auto.EditControl(searchDepth=6,
                  Name="文件名(N):").GetValuePattern().SetValue(c_path_name)
 auto.SendKey(0x0D)
 auto.Click(800, 500)
 auto.Click(500, 800)
 auto.ButtonControl(searchDepth=4,
                    Name=" 请选择X光片 ").GetNextSiblingControl().Click()
 time.sleep(1.5)
 auto.EditControl(searchDepth=6,
                  Name="文件名(N):").GetValuePattern().SetValue(z_path_name)
Example #16
0
def _3dmark11_run():
    try:
        auto.WindowControl(Name = '3DMark 11 Advanced Edition',searchDepth = 1,AutomationId = 'Window').GetWindowPattern().Close()
    except:
        time.sleep(1)

    run_path = 'C://Program Files//Futuremark//3DMark 11//'
    os.chdir(run_path)
    os.system('start 3DMarkLauncher.exe')
    #等待更新窗口出现并关闭
    time.sleep(10)
    
    try:
        if auto.WindowControl(searchDepth = 1,Name = 'Update Available' ).Exists():
            auto.WindowControl(searchDepth = 1,Name = 'Update Available' ).GetWindowPattern().Close()
    except:
        if auto.WindowControl(searchDepth = 1,Name = '更新可用' ).Exists():
            auto.WindowControl(searchDepth = 1,Name = '更新可用' ).GetWindowPattern().Close()
              
          
    auto.WindowControl(Name = '3DMark 11 Advanced Edition',searchDepth = 1,AutomationId = 'Window').SetActive()
    auto.TabItemControl(searchDepth = 3,AutomationId = 'ResultTab').Click()
    tab_result = auto.TabItemControl(searchDepth = 3,AutomationId = 'ResultTab')

    if tab_result.CheckBoxControl(searchDepth = 4).GetTogglePattern().ToggleState == 1:
        tab_result.CheckBoxControl(searchDepth = 4).Click()
    
 
    
    
    #跳转到basic选项卡运行测试并等待结果
    auto.TabItemControl(searchDepth = 3,Name = 'Basic',AutomationId = 'BasicTab').Click(waitTime = 1)
    auto.RadioButtonControl(searchDepth = 4,AutomationId = 'PresetPerformanceRadioButton').Click(waitTime = 1)
    auto.RadioButtonControl(searchDepth = 4,AutomationId = 'RunBenchmarkRadioButton').Click(waitTime = 1)
    auto.RadioButtonControl(searchDepth = 4,AutomationId = 'StretchedScalingModeRadioButton').Click(waitTime = 1)
    try:
        auto.ButtonControl(searchDepth = 4,Name = 'Run 3DMark 11').Click(waitTime = 1)
    except:
        auto.ButtonControl(searchDepth = 4,Name = '运行 3DMark 11').Click(waitTime = 1)
        
 
    #等待运行结果
    while(1):
        time.sleep(30)
        try:
            if auto.TabItemControl(AutomationId = 'ResultTab',searchDepth = 3).GetSelectionItemPattern().IsSelected == True :
                time.sleep(2)
                break
        except:
            time.sleep(10)
    
        
    auto.WindowControl(Name = '3DMark 11 Advanced Edition').SetActive()
    #光标移动到结果读取结果  
    auto.TabItemControl(searchDepth = 3,AutomationId = 'ResultTab').Click()
    result_dict = {}
    result_dict['Score'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineScoreLabel').Name
    result_dict['Graphics Score'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineGraphicsScoreLabel').Name
    result_dict['Physics Score'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflinePhysicsScoreLabel').Name
    result_dict['Combined Score'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineCombinedScoreLabel').Name
    result_dict['GT1'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineGT1ResultLabel').Name
    result_dict['GT2'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineGT2ResultLabel').Name
    result_dict['GT3'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineGT3ResultLabel').Name
    result_dict['GT4'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineGT4ResultLabel').Name
    result_dict['PT'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflinePTResultLabel').Name
    result_dict['CT'] = auto.TextControl(searchDepth = 4, AutomationId = 'OfflineCTResultLabel').Name
    
    #关闭窗口
    auto.WindowControl(Name = '3DMark 11 Advanced Edition',searchDepth = 1,AutomationId = 'Window').GetWindowPattern().Close()
    
    return result_dict
# # 查找cas
cas = automation.WindowControl(searchDepth=1, AutomationId='myMainWindow', Name='Login')
# 可以判断window是否存在,如果不判断,找不到window的话会抛出异常
if automation.WaitForExist(cas, 3):
    automation.Logger.WriteLine("CAS exists now",logFile="cas.txt")
else:
    automation.Logger.WriteLine("CAS does not exist after 3 seconds",logFile="cas.txt")
cas.SetActive()
# # 登录
login = automation.ButtonControl(searchFromControl=cas,AutomationId ="btn_login")
# login=cas.ButtonControl(AutomationId ="btn_login")
login.Click()
# 查找病例
patientManager = automation.WindowControl(Name = 'PatientManager',AutomationId='myMainWindow')
patientManager.SetActive()
patient = automation.TextControl(searchFromControl=patientManager,Name = 'LI QIANG',ClassName="TextBlock",foundIndex=1)
patient.Click()
# # 进入三维重建
_3dRebuidBtn = patientManager.ButtonControl(AutomationId="_3dRebuidBtn")
_3dRebuidBtn.Click()
time.sleep(10)
lung = patientManager.ImageControl(AutomationId="lung")
lung.Click()
# 设置窗宽窗位
WL = patientManager.EditControl(AutomationId="WL")
WL.SetValue("600")
WB = patientManager.EditControl(AutomationId="WB")
WB.SetValue("1400")
w_OK = patientManager.ButtonControl(AutomationId = "w_OK")
w_OK.Click()
wwwl_preset = patientManager.ComboBoxControl(AutomationId="wwwl_preset")
Example #18
0
    # 点击7,记得选择搜索深度为7
    # button7 = uiautomation.ButtonControl(searchDepth=4, Name="day_7_24")
    # button7.Click()

    # 练习1+2 并断言
    button3 = uiautomation.ButtonControl(searchDepth=4, Name="3")
    button3.Click()
    button_add = uiautomation.ButtonControl(searchDepth=4, Name="加")
    button_add.Click()
    button7 = uiautomation.ButtonControl(searchDepth=4, Name="day_7_24")
    button7.Click()
    button_sum = uiautomation.ButtonControl(searchDepth=4, Name="等于")
    button_sum.Click()

    sumdata = uiautomation.TextControl(searchDepth=4, AutomationId="158")
    print(sumdata)
    data = sumdata.Name
    print(data)

    if data == "10":
        print("测试成功")
    else:
        print("测试失败")