Exemplo n.º 1
0
 def __init__(self):
     FileDialog.__init__(self,QPath("/Classname='ExploreWClass' && Visible='True'"))
     locators = {
         '文件地址显示框'   :{'type':win.Control, 'root':self, 'locator': QPath('/ControlId = "0xA205" && Classname="Edit" && visible="True" && MaxDepth="5"')}, 
         
           }
     self.updateLocator(locators)
Exemplo n.º 2
0
 def __init__(self):
     FileDialog.__init__(self,QPath("/Classname='CabinetWClass' && Visible='True'"))
     locators = {
         '文件地址显示框'   :{'type':win.Control, 'root':self, 'locator': QPath('/ControlId = "0x3E9" && Classname="ToolbarWindow32" && visible="True" && MaxDepth="8"')}, 
         
           }
     self.updateLocator(locators)
Exemplo n.º 3
0
 def __init__(self):
     FileDialog.__init__(self,QPath("/Classname= 'CabinetWClass' && Visible='True'"))
     locators = {
         '文件.文件浏览窗口'   :{'type':win.Control, 'root':self, 'locator': QPath('/ControlId = "0x1" && visible="True" && MaxDepth="7"')}, #打开件夹后文件的展示窗口
         
           }
     self.updateLocator(locators)
Exemplo n.º 4
0
 def __init__(self, process_id):
     '''通过进程id查找文件窗口
     '''
     qp = QPath('|classname~="32770" && ProcessId="%s"' % process_id)
     super(UploadFileDialog, self).__init__(qp)
     import qt4c.wincontrols as win32
     self.updateLocator({
         '文件名展示框': {
             'type':
             win32.Control,
             'root':
             self,
             'locator':
             QPath(
                 '/ClassName="ComboBoxEx32" && Visible="True" /ClassName="ComboBox" && Visible="True"'
             )
         },
         '文件名': {
             'type': win32.Control,
             'root': '@文件名展示框',
             'locator': QPath('/ClassName="Edit" && Visible="True"')
         },
         '打开按钮': {
             'type': win32.Control,
             'root': self,
             'locator': QPath('/ClassName="Button" && Text="打开(&O)"')
         }
     })
Exemplo n.º 5
0
 def __init__(self):
     win.Window.__init__(self, locator=QPath("/Caption = '浏览文件夹' && Classname = '#32770' && Visible='True'"))
     locators = {
         '确定按钮'  :{'type':win.Control, 'root':self, 'locator': QPath("/Caption = '确定' && Visible='True' && maxDepth= '2'")},
         '取消按钮'  :{'type':win.Control, 'root':self, 'locator': QPath("/Caption = '取消' && Visible='True' && maxDepth= '2'")},
         '选择您要发送的文件夹':   {'type':win.TreeView, 'root':self, 'locator': QPath("/classname='SHBrowseForFolder ShellNameSpace Control' /ClassName='SysTreeView32' && Visible='True'")},           
                 }
     self.updateLocator(locators)
Exemplo n.º 6
0
 def __init__(self):
     FileDialog.__init__(self,QPath("/Caption = '浏览文件夹' && Classname = '#32770' && Visible='True'"))
     locators = {
         '保存按钮'   :{'type':win.ComboBox, 'root':self, 'locator': QPath('/Caption = "保存(&S)" && visible="True"')}, #打开按钮
         '保存类型'   :{'type':win.Control, 'root':self, 'locator': QPath('/Caption~="图像文件" && ClassName="ComboBox" && Visible="True"')}, #保存类型Combox            
          
                 }
     self.updateLocator(locators)
Exemplo n.º 7
0
    def __init__(self,qpath=None):
        '''constructor
        '''
        win.Window.__init__(self, locator=qpath)
        ControlContainer.__init__(self)
        locators = {
#            '打开按钮'     :{'type':win.Control, 'root':self, 'locator': QPath('/Caption = "打开(&O)" && visible="True"')}, #打开按钮
            '文件名编辑框' :{'type':win.Control, 'root':self, 'locator': QPath('/ClassName="ComboBoxEx32" && Visible="True"')},#顶上那个combobox
            '文件.文件路径展示框' :{'type':win.ComboBox, 'root':self, 'locator': QPath('/ControlId = "0x471" && visible="True" && MaxDepth = "2"')},#显示当前文件夹名称的combox
             '取消按钮':{'type':win.Control, 'root':self, 'locator': QPath('/Caption ~= "取消" && visible="True"')}, #取消按钮
                    }
        self.updateLocator(locators)
Exemplo n.º 8
0
 def test_instance(self):
     self.assertEqual(
         QPath('/Text="标题" /Instance="1"')._parsed_qpath, [{
             'Text': ['=', '标题']
         }, {
             'Instance': ['=', "1"]
         }])
Exemplo n.º 9
0
 def __init__(self):
     FileDialog.__init__(self,QPath("|Caption ~= '选择文件/文件夹' && Classname ~= '#32770' && Visible='True'"))
     locators = {
         '发送按钮'   :{'type':win.Control, 'root':self, 'locator': QPath('/Caption = "发送(&S)" && visible="True"')}, #打开按钮
         '图像.文件类型'   :{'type':win.Control, 'root':self, 'locator': QPath('/Caption~= "图像文件" && visible="True"')}, #打开图片窗口的文件类型Combox
         '文件.文件类型':{'type':win.Control, 'root':self, 'locator': QPath('/Caption~= "All Files" && visible="True"')}, #打开文件窗口的文件类型Combox
         '输入框':{'type':win.Control, 'root':self, 'locator': QPath("/ClassName='ComboBoxEx32'&&Visible='True'/ClassName='ComboBox'/ClassName='Edit'")}, #输入框              
         'xp内容显示区':{'type':win.Control, 'root':self, 'locator':QPath("/Caption='FolderView'&&Visible='True'&&MaxDepth = '2'") }, #输入框
         'win7内容显示区':{'type':win.Control, 'root':self, 'locator':QPath("/ClassName='DirectUIHWND'&&Visible='True'&&MaxDepth = '5'") }, #输入框    
         '打开.文件浏览窗口':{'type':win.Control, 'root':self, 'locator': QPath("/ClassName='SHELLDLL_DefView'&&Visible='True'&&MaxDepth = '4'")}, #XP打开文件里的文件浏览窗口      
         '打开.win7文件浏览窗口':{'type':win.Control, 'root':self, 'locator': QPath("/ClassName='SHELLDLL_DefView'&&Visible='True'&&MaxDepth = '4'")}, #win7打开文件里的文件浏览窗口       
           }
     self.updateLocator(locators)
Exemplo n.º 10
0
 def __init__(self):
     FileDialog.__init__(self,QPath("/Caption ~= '存' && Classname = '#32770' && Visible='True'"))
     locators = {
          '保存按钮'   :{'type':win.Control, 'root':self, 'locator': QPath('/Caption = "保存(&S)" && visible="True"')}, #打开按钮
         '取消按钮'   :{'type':win.Control, 'root':self, 'locator': QPath('/Caption = "取消" && visible="True"')}, #打开按钮
         '输入框'    :{'type':win.Control, 'root':self, 'locator': QPath('/ClassName="ComboBoxEx32" && Visible="True"/ClassName="ComboBox" /ClassName="Edit"')},#xp
         'win7输入框'     :{'type':win.Control, 'root':self, 'locator': QPath('/ClassName="Edit"&&MaxDepth = "5"')},#win7
         '保存类型'   :{'type':win.ComboBox, 'root':self, 'locator': QPath('/Caption ~= "\." &&ClassName="ComboBox" && Visible="True" ')}, #保存类型Combox            
         '保存在'   :{'type':win.Control, 'root':self, 'locator':  QPath('/ClassName="ComboBox" && Visible="True" &&Instance = "0"')}, #xp保存类型Combox            
         '文件路径选择框'   :{'type':win.Control, 'root':self, 'locator':  QPath('/ClassName="Breadcrumb Parent" && Visible="True" &&MaxDepth = "5"/ClassName="ToolbarWindow32"')}, #win7上的文件路径
         '文件路径编辑框'   :{'type':win.Control, 'root':self, 'locator':  QPath('/ClassName="WorkerW"/ClassName="Edit"&&MaxDepth = "6"')}, #win7上的文件路径
               }
     self.updateLocator(locators)
Exemplo n.º 11
0
 def test_maxdepth(self):
     self.assertEqual(
         QPath('/UIType="UIA" /Text="消息" && MaxDepth="3"')._parsed_qpath, [{
             'UIType': ['=', 'UIA']
         }, {
             'MaxDepth': ['=', '3'],
             'Text': ['=', '消息']
         }])
Exemplo n.º 12
0
    def Url(self):
        '''返回当前的URL地址
        '''
        qpstr = "/classname='WorkerW' && visible='True' /classname='ReBarWindow32' \
        /classname~='(Address|ComboBox)' && Instance='0' /maxdepth='3' && classname='Edit'"

        addr_edit = win32.Control(root=self, locator=QPath(qpstr))
        return addr_edit.Caption
Exemplo n.º 13
0
    def ie_window(self):
        '''获取Internet Explorer_Server对应的ie窗口
        '''
        iever = IEBrowser.get_version()
        iever = int(iever.split('.')[0])
        if iever < 6:
            raise RuntimeError("不支持IE%s" % iever)
        elif iever == 6:  # ie6
            qp = QPath("/classname='Shell DocObject View' && visible='True'/classname='Internet Explorer_Server'")
        elif iever == 7:
            qp = QPath("/classname='TabWindowClass' && visible='True'/maxdepth='3' && classname='Internet Explorer_Server'")
        else:
            qp = QPath("/classname='Frame Tab' && visible='True'/maxdepth='3' && classname='Internet Explorer_Server'")

        ie_window = win32.Control(root=self, locator=qp)
        ie_window._timeout = self._timeout
        ie_window.HWnd
        return ie_window
Exemplo n.º 14
0
 def get_chrome_window_list(self, pid):
     '''通过pid查找对应的chrome窗口列表
     '''
     from qt4c.exceptions import ControlAmbiguousError
     qp_str = r"/ClassName='Chrome_WidgetWin_1' && ProcessId='%d' && Visible='True' %%s /ClassName='Chrome_RenderWidgetHostHWND' && Visible='True'" % pid
     try:
         win = Window(locator=QPath(qp_str % ''))
         if win.exist() and win.Valid:  # 这句话才会真正去查找控件;增加有效性判断
             return [win]
         else:
             return []
     except ControlAmbiguousError as e:
         pattern = re.compile(r'找到(\d+)个控件')
         ret = pattern.search(str(e))
         if not ret: raise
         win_num = int(ret.group(1))
         win_list = []
         for i in range(win_num):
             win = Window(locator=QPath(qp_str % ("&& Instance='%d'" % i)))
             if win.exist(): win_list.append(win)
         return win_list
Exemplo n.º 15
0
    def __init__(self, process_id):
        '''初始化,进程id

        :params process_id: 窗口进程id
        :type process_id: int
        '''
        self._pid = process_id
        qpstr = "|classname='IEFrame' && visible='True'|classname='WorkerW' && visible='True'\
        |classname='ReBarWindow32' |classname='Address Band Root' && Instance='0' |maxdepth='3' && classname='Edit' && ProcessId='%d'" % process_id
        old_timeout = win32.Control._timeout
        win32.Control._timeout = self._timeout
        addr_edit = win32.Control(locator=QPath(qpstr))
        win32gui.BringWindowToTop(addr_edit.TopLevelWindow.HWnd)  # 激活ie窗口,并显示在最前端
        win32.Control._timeout = old_timeout
        win32.Window.__init__(self, root=addr_edit.TopLevelWindow)
        # 实现窗口最大化的逻辑
        time.sleep(0.005)  # 优化最大化的视觉效果
Exemplo n.º 16
0
    def __init__(self, app):
        # qp = QPath("/ClassName='CalcFrame' && Text='计算器' && Visible='True' && ProcessId='%s'" % app.ProcessId)
        qp = QPath("/ClassName='CalcFrame' && Text='计算器' && Visible='True'")
        super(UIAMainPanel, self).__init__(locator=qp)
        self._app = app

        locators = {
            '按键0': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='0'")},
            '按键1': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='1'")},
            '按键2': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='2'")},
            '按键3': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='3'")},
            '按键4': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='4'")},
            '按键5': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='5'")},
            '按键6': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='6'")},
            '按键7': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='7'")},
            '按键8': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='8'")},
            '按键9': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='9'")},
            '按键.': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='十进制分隔符'")},
            'BackSpace': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='BackSpace 键'")},
            '清除': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='清除'")},
            '除号': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='除'")},
            '乘号': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='乘'")},
            '加号': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='加'")},
            '减号': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='减'")},
            '取反': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='求反'")},
            '根号': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='平方根'")},
            '倒数': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='倒数'")},
            '等号': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='等于'")},
            '结果': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Static' && MaxDepth='4' && Name='结果'")},

            # 科学型
            '度': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='度'")},
            '弧度': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='弧度'")},
            '梯度': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='梯度'")},
            'pie': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='圆周率'")},
            'sin': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='正弦'")},
            'cos': {'type': uia.Control, 'root': self, 'locator': QPath("/UIType='UIA' && ClassName='Button' && MaxDepth='4' && Name='余弦'")}

        }

        self.updateLocator(locators)
Exemplo n.º 17
0
 def test_desc(self):
     self.assertEqual(
         QPath('/ControlId="0x64"')._parsed_qpath, [{
             'ControlId': ['=', '0x64']
         }])
Exemplo n.º 18
0
 def test_text(self):
     self.assertEqual(
         QPath('/Text="标题"')._parsed_qpath, [{
             'Text': ['=', '标题']
         }])
Exemplo n.º 19
0
 def test_type(self):
     self.assertEqual(
         QPath('/Type="WebView"')._parsed_qpath, [{
             'Type': ['=', 'WebView']
         }])
Exemplo n.º 20
0
 def test_id(self):
     self.assertEqual(
         QPath('/Id="webview"')._parsed_qpath, [{
             'Id': ['=', 'webview']
         }])
Exemplo n.º 21
0
    def __init__(self, app):
        # qp = QPath("/ClassName='CalcFrame' && Text='计算器' && Visible='True' && ProcessId='%s'" % app.ProcessId)
        qp = QPath("/ClassName='CalcFrame' && Text='计算器' && Visible='True'")
        super(MainPanel, self).__init__(locator=qp)
        self._app = app

        locators = {
            '按键0': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x82'")
            },
            '按键1': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x83'")
            },
            '按键2': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='CalcFrame' /ClassName='#32770' && Instance='1' /ClassName='Button' && Instance='10'"
                )
            },
            '按键3': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x85'")
            },
            '按键4': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x86'")
            },
            '按键5': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x87'")
            },
            '按键6': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x88'")
            },
            '按键7': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x89'")
            },
            '按键8': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x8A'")
            },
            '按键9': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x8B'")
            },
            '按键.': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x54'")
            },
            'BackSpace': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x53'")
            },
            '清除': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x51'")
            },
            '除号': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x5B'")
            },
            '乘号': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x5C'")
            },
            '加号': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x5D'")
            },
            '减号': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x5E'")
            },
            '取反': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x50'")
            },
            '根号': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x6E'")
            },
            '倒数': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x72'")
            },
            '等号': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x79'")
            },
            '结果': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Static' && MaxDepth='3' && ControlId='0x96'")
            },

            # 科学型
            '度': {
                'type': win.Control,
                'root': self,
                'locator':
                QPath("/ClassName='Button' && MaxDepth='3' && Text='度'")
            },
            '弧度': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath("/ClassName='Button' && MaxDepth='3' && Text='弧度'")
            },
            '梯度': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath("/ClassName='Button' && MaxDepth='3' && Text='梯度'")
            },
            'pie': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x78'")
            },
            'sin': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x66'")
            },
            'cos': {
                'type':
                win.Control,
                'root':
                self,
                'locator':
                QPath(
                    "/ClassName='Button' && MaxDepth='3' && ControlId='0x67'")
            }
        }

        self.updateLocator(locators)