Beispiel #1
0
 def buttons(self):
     '''Alert控件上的所有按钮
     '''
     # -*- iOS8
     if re.search('^[8|9]', self._ios_version):
         self._buttons = self.find_elements(
             QPath(
                 "/classname='UIACollectionView'/classname='UIACollectionCell'/classname='UIAButton' && visible=true"
             ))
         if len(self._buttons) == 0:
             self._buttons = self.find_elements(
                 QPath(
                     "/classname='UIACollectionView'/classname='UIACollectionCell' && visible=true"
                 ))
         # 避免性能测试使用libimobiledevice
         # if self._ios_type == Device.EnumDeviceType.iPad : self._buttons = self.find_elements(QPath("/classname='UIACollectionView'/classname='UIACollectionCell'/classname='UIAButton' && visible=true"))
         # else                                            : self._buttons = self.find_elements(QPath("/classname='UIACollectionView'/classname='UIACollectionCell' && visible=true"))
     # -*- iOS7
     if re.search('^7', self._ios_version):
         self._buttons = self.find_elements(
             QPath(
                 "/classname='UIATableView'/classname='UIATableCell' && visible=true"
             ))
     # -*- iOS6
     if re.search('^6', self._ios_version):
         self._buttons = self.find_elements(
             "/classname='UIAButton' && visible=true")
     # -*-
     if len(self._buttons) > 0: return self._buttons
     # -*-
     raise Exception('未找到有效按钮,请检查Alert类内的子对象是否正确的QPath')
Beispiel #2
0
 def _init_window(self):
     from qt4i.icontrols import Element, Window
     from qt4i.qpath import QPath
     self._win = Window(self)
     self._win.updateLocator({
         'Safari': {
             'type': Element,
             'root': self,
             'locator': "Safari"
         },
         'url输入框.未激活键盘': {
             'type': Element,
             'root': self,
             'locator': QPath("/name='URL' & maxdepth=9 & instance=1")
         },
         'url输入框': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/name~='地址|Address|URL' & maxdepth=9 & instance=1")
         },
         '打开url': {
             'type': Element,
             'root': self,
             'locator': QPath("/name~='^打开$|^Open$' & maxdepth=15")
         },
     })
     self._win.Controls['Safari'].click()
Beispiel #3
0
    def __init__(self, app):
        Window.__init__(self, app)
        self._device = self._app.device

        locators = {
            '更多信息': {
                'type':
                Element,
                'root':
                self,
                'locator':
                QPath(
                    "/classname = 'Button' & label = '更多信息' & visible = true & maxdepth = 11"
                )
            },
            '输入框': {
                'type':
                Element,
                'root':
                self,
                'locator':
                QPath(
                    "/classname = 'TextField' & visible = true & maxdepth = 11"
                )
            },
            '名称': {
                'type': Element,
                'root': self,
                'locator': 'qt4i'
            },
        }

        self.updateLocator(locators)
Beispiel #4
0
 def __init__(self, root, locator=None, **ext):
     if locator is None:
         if INS_IOS_DRIVER:
             locator = QPath(
                 "/classname='UIAWindow'/classname='UIAActionSheet'")
         else:
             locator = QPath("/classname='Sheet' & maxdepth = 20")
     Element.__init__(self, root=root, locator=locator, **ext)
     self._ios_version = self._app.device.ios_version
     self._buttons = []
Beispiel #5
0
 def __init__(self, root, locator=None, **ext):
     if locator is None:
         if INS_IOS_DRIVER:
             locator = QPath(
                 "/classname='UIAWindow'/classname='UIATableView'")
         else:
             locator = QPath("/classname='Table' & maxdepth = 20")
     Element.__init__(self, root, locator, **ext)
     if isinstance(root, Window):
         for key, value in six.iteritems(root._locators):
             if value['root'] == '@%s' % self.user_name:
                 self.updateLocator({key: value})
     self._cells = []
Beispiel #6
0
 def __init__(
     self,
     root,
     locator=QPath("/classname='UIAWindow'/classname='UIAActionSheet'")):
     Window.__init__(self, root=root, locator=locator)
     self._ios_version = self._app.device.ios_version
     self._buttons = []
Beispiel #7
0
 def __init__(self,
              root,
              locator=QPath("/classname='UIAAlert' & maxdepth = 20"),
              **ext):
     Element.__init__(self, root=root, locator=locator, **ext)
     self._ios_version = self._app.device.ios_version
     self._title = None
     self._buttons = []
Beispiel #8
0
 def _init_window(self):
     from qt4i.icontrols import Element, Window
     from qt4i.qpath import QPath
     self._win = Window(self)
     self._win.updateLocator({
         'Safari': {'type': Element, 'root': self, 'locator': self._app_name},
         'url输入框.未激活键盘': {'type': Element, 'root': self, 'locator': QPath("/name='URL' & maxdepth=9 & instance=1")},
         'url输入框': {'type': Element, 'root': self,
                    'locator': QPath("/name~='地址|Address|URL' & maxdepth=9 & instance=1")},
         '打开url': {'type': Element, 'root': self, 'locator': QPath("/name~='^打开$|^Open$' & maxdepth=15")},
         'StatusBar': {'type': Element, 'root': self,
                       'locator': QPath("/classname = 'StatusBar' & visible = true & maxdepth = 2")},
     })
     if self._url_scheme:
         self._win.Controls['Safari'].click()
     else:
         self.start()
Beispiel #9
0
 def __init__(
     self,
     root,
     locator=QPath(
         "/classname='UIAWindow'/classname='UIAImage'/classname='UIASlider' && visible=true"
     )):
     Window.__init__(self, root=root, locator=locator)
     self._ios_version = self._app.device.ios_version
Beispiel #10
0
 def __init__(self,
              root,
              locator=QPath("/classname='UIAWindow'/classname='UIAAlert'")):
     Window.__init__(self, root=root, locator=locator)
     self._ios_version = self._app.device.ios_version
     self._ios_type = self._app.device.ios_type
     self._title = None
     self._buttons = []
Beispiel #11
0
    def title(self):
        '''提示文本内容
        '''
        if INS_IOS_DRIVER:
            self._title = Element(
                root=self,
                locator=QPath(
                    "/classname='UIAScrollView'/classname='UIAStaticText' && visible=true"
                ))
        else:
            self._title = Element(
                root=self,
                locator=QPath(
                    "/classname='StaticText' & visible=true & maxdepth=10"))

        if self._title is not None:
            return self._title
        raise Exception('未找到有效标题,请检查Alert类内的子对象是否正确的QPath')
Beispiel #12
0
 def title(self):
     '''提示文本内容
     '''
     # -*- iOS6
     if re.search('^6', self._ios_version):
         self._title = Element(
             root=self,
             locator=QPath("/classname='UIAStaticText' && visible=true"))
     else:
         self._title = Element(
             root=self,
             locator=QPath(
                 "/classname='UIAScrollView'/classname='UIAStaticText' && visible=true"
             ))
     # -*-
     if self._title is not None: return self._title
     # -*-
     raise Exception('未找到有效标题,请检查Alert类内的子对象是否正确的QPath')
Beispiel #13
0
    def buttons(self):
        '''ActionSheet上面的所有按钮
        '''
        if re.search('^7', self._ios_version):
            self._buttons = self.find_elements(
                QPath("/classname='UIAButton' && visible=true"))
        else:
            self._buttons = self.find_elements(
                QPath(
                    "/classname='UIACollectionView'/classname='UIACollectionCell'/classname='UIAButton' && visible=true"
                ))
            other_buttons = self.find_elements(
                QPath("/classname='UIAButton' && visible=true"))
            if other_buttons:
                self._buttons.extend(other_buttons)

        if len(self._buttons) > 0:
            return self._buttons
        raise Exception('未找到有效按钮,请检查ActionSheet类内的控件QPath是否正确')
Beispiel #14
0
 def __init__(self, app):
     self._app = app
     Window.__init__(self, self._app)
     self.scroll_win = Element(self._app, 'WebView')
     locators = {
         'webview': {
             'type': IOSWebView,
             'root': self.scroll_win,
             'locator': QPath("/classname='WebView'")
         },
     }
     self.updateLocator(locators)
Beispiel #15
0
 def set_host_proxy(self, server, port, wifi_name): 
     '''设置host代理
     
     :param server: 服务器名
     :type server: str
     :param port: 端口号
     :type port: int
     :param wifi: wifi名
     :type wifi: str
     '''
     #ios版本
     version = int(self._device.ios_version[0])
     if version == 1 :
         version = int(self._device.ios_version[:2])   
     time.sleep(1)                            #添加保护
     #进入无线局域网
     if self._win.Controls['无线局域网'].wait_for_exist(2,0.05):
         self._win.Controls['无线局域网'].click()
     time.sleep(1)                            #添加保护
     from qt4i.icontrols import Element
     from qt4i.qpath import QPath
     self._win.updateLocator({
         'wifi_name':{'type':Element, 'root':self, 'locator':wifi_name},       
         'wifi_title':{'type':Element, 'root':self, 
             'locator':QPath("/classname='NavigationBar' & maxdepth=4 & name='%s'" % wifi_name)},       
         })
     self._win.Controls['wifi_name'].click()
     time.sleep(1)                            #添加保护
     if self._win.Controls['wifi_title'].exist():
         logger.info('已经是%s, 无需切换WiFi' % wifi_name)
     else:
         #再点击一次进入代理设置
         self._win.Controls['wifi_name'].click()
     
     if version == 11 :
         self._win.Controls['配置代理'].click()
         
     self._win.Controls['手动'].click()
     #服务器框
     server_text_field = self._win.Controls['服务器']
     server_text_field.click()
     server_text_field.value = server + '\n'
     #端口框
     port_text_field = self._win.Controls['端口']
     port_text_field.value = port
 
     if version == 11 :
         self._win.Controls['存储'].click()    
         if self._win.Controls['wifi_name'].wait_for_exist(2,0.05):
             self._win.Controls['wifi_name'].click()
     self._win.Controls['返回.无线局域网'].click()
     self._win.Controls['设置'].click()
Beispiel #16
0
 def __init__(self, root, locator=QPath("/classname='UIAWindow'")):
     Window.__init__(self, root=root, locator=locator)
     self.updateLocator({
         'UIATableCell': {
             'type': Element,
             'root': self,
             'locator': QPath("/classname='UIATableCell'")
         },
         '帐号框': {
             'type':
             Element,
             'root':
             '@UIATableCell',
             'locator':
             QPath(
                 "/classname='UIATextField' && name~='QQ号' && visible=true"
             )
         },
         "密码框": {
             'type':
             Element,
             'root':
             '@UIATableCell',
             'locator':
             QPath(
                 "/classname='UIASecureTextField' && label~='密码' && visible=true"
             )
         },
         "登陆按钮": {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname='UIAButton' && label='登陆QQ' && visible=true"
             )
         },
     })
Beispiel #17
0
 def __init__(self, app):
     self._app = app
     self._device = self._app.device
     Window.__init__(self, self._app)
     self.scroll_win = Window(self._app, "ScrollView")
     locators = {
         'webview': {
             'type': IOSWebView,
             'root': self.scroll_win,
             'locator': QPath("/classname='Other'")
         },
     }
     self.updateLocator(locators)
Beispiel #18
0
 def buttons(self):
     '''Alert控件上的所有按钮
     '''
     if INS_IOS_DRIVER:
         if re.search('^[8|9]', self._ios_version):
             self._buttons = self.find_elements(
                 QPath(
                     "/classname='UIACollectionView'/classname='UIACollectionCell'/classname='UIAButton' && visible=true"
                 ))
         elif re.search('^7', self._ios_version):
             self._buttons = self.find_elements(
                 QPath(
                     "/classname='UIATableView'/classname='UIATableCell' && visible=true"
                 ))
         if len(self._buttons) == 0:
             self._buttons = self.find_elements(
                 QPath(
                     "/classname='UIACollectionView'/classname='UIACollectionCell' && visible=true"
                 ))
     else:
         self._buttons = self.find_elements(
             QPath("/classname='Button' & visible=true & maxdepth=10"))
     if len(self._buttons) > 0: return self._buttons
     raise Exception('未找到有效按钮,请检查Alert类内的子对象是否正确的QPath')
Beispiel #19
0
    def __init__(self, app):
        Window.__init__(self, app)
        self._device = self._app.device

        locators = {
            '通用': {
                'type':
                Element,
                'root':
                self,
                'locator':
                QPath("/classname = 'Cell' & label = '通用' & maxdepth = 7")
            },
            '关于本机': {
                'type':
                Element,
                'root':
                self,
                'locator':
                QPath(
                    "/classname = 'StaticText' & label = '关于本机' & visible = true & maxdepth = 12"
                )
            },
            '名称': {
                'type':
                Element,
                'root':
                self,
                'locator':
                QPath(
                    "/classname = 'StaticText' & label = '名称' & visible = true & maxdepth = 11"
                )
            },
        }

        self.updateLocator(locators)
Beispiel #20
0
 def __init__(self,
              root,
              locator=QPath("/classname='UIASlider' & maxdepth = 20"),
              **ext):
     Element.__init__(self, root=root, locator=locator, **ext)
     self._ios_version = self._app.device.ios_version
Beispiel #21
0
 def _init_window(self):
     from qt4i.icontrols import Element, Window
     from qt4i.qpath import QPath
     self._win = Window(self)
     self._win.updateLocator({
         '无线局域网': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='无线局域网' && maxdepth=8")
         },
         '无线开关': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Switch' && name='无线局域网' && maxdepth=12")
         },
         '设置': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Button' && name='设置' && maxdepth=5")
         },
         '蜂窝移动网络': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Cell' && name='蜂窝移动网络' && maxdepth=8")
         },
         '蜂窝开关': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Switch' && name='蜂窝移动数据' && maxdepth=12")
         },
         '飞行开关': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Switch' && name='飞行模式' && maxdepth=9")
         },
         '开发者': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='开发者' && maxdepth=8")
         },
         'status': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Cell' && name='Status' && maxdepth=11")
         },
         'Enable': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Switch' && name='Enable' && maxdepth=12")
         },
         '100%Loss': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Cell' && name='100% Loss' && maxdepth=11")
         },
         '3G': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='3G' && maxdepth=11")
         },
         'DSL': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='DSL' && maxdepth=11")
         },
         'Edge': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='Edge' && maxdepth=11")
         },
         'High Latency DNS': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname='Cell' && name='High Latency DNS' && maxdepth=11"
             )
         },
         'LTE': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='LTE' && maxdepth=11")
         },
         'Very Bad Network': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname='Cell' && name='Very Bad Network' && maxdepth=11"
             )
         },
         'Wi-Fi': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath("/classname='Cell' && name='Wi-Fi' && maxdepth=11")
         },
         'WI-Fi 802.11ac': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname='Cell' && name='Wi-Fi 802.11ac' && maxdepth=11"
             )
         },
         'ADD': {
             'type': Element,
             'root': self,
             'locator':
             QPath("/classname='Cell' && name='ADD' && maxdepth=11")
         },
         '返回': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname='Button' && name='返回' && maxdepth=5 && instance=1"
             )
         },
         #ios10
         '手动': {
             'type': Element,
             'root': self,
             'locator': "手动"
         },
         '关闭': {
             'type': Element,
             'root': self,
             'locator': "关闭"
         },
         '服务器': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname = 'TextField' & label = '服务器' & maxdepth = 11")
         },
         '端口': {
             'type':
             Element,
             'root':
             self,
             'locator':
             QPath(
                 "/classname = 'TextField' & label = '端口'  & maxdepth = 11")
         },
         #ios11
         '配置代理': {
             'type': Element,
             'root': self,
             'locator': "配置代理"
         },
         '存储': {
             'type': Element,
             'root': self,
             'locator': "存储"
         },
         '返回.无线局域网': {
             'type': Element,
             'root': self,
             'locator': "无线局域网"
         },
         'Conditioner': {
             'type': Element,
             'root': self,
             'locator': "Network Link Conditioner"
         },
     })
     self.start()