예제 #1
0
def step_impl(context):
    ele = music.get_music_search_ele()
    if ele.wait.exists():
        ele.long_click.topleft()
        d(text='剪切').click()
    else:
        uit.raise_Exception_info('搜索框不存在')
예제 #2
0
 def get_radio_pause_control_status(self):
     '''
     收音机暂停控件
     :return: play or pause icon
     '''
     ui_layout = list(d(resourceId='com.pateo.radio:id/ui_main_layout'))
     control = list(d(resourceId='com.pateo.radio:id/radio_control_id'))
     return len(ui_layout), len(control)
예제 #3
0
 def get_phone_hungup_ele(self):
     """
     获取挂断电话按钮
     :return:
     """
     hungup_ele1 = d(resourceId=self.__pkg_name + ':id/call_hungup_button')
     hungup_ele2 = d(resourceId=self.__pkg_name + ':id/dial_hungup_button')
     return [hungup_ele1, hungup_ele2]
예제 #4
0
 def chk_crash(self):
     '''
     检查是否crash
     :return: True: 有crash, False: 无crash
     '''
     print('开始检查应用是否crash')
     if d(resourceId='android:id/message').wait.exists():
         print('应用crash')
         d(resourceId='android:id/button1').click.wait()
         return True
     else:
         return False
예제 #5
0
 def get_music_artist_name_ele(self):
     """
     获取音乐歌手名称
         -- 先获取timeInfo控件
         -- 根据timeInfo控件获取当前播放的音乐名字
     :return:
     """
     # 获取timeInfo控件
     time_info = d(resourceId=self.__pkg_name + ':id/timeInfo')
     if time_info.wait.exists():
         return time_info.sibling(resourceId=self.__pkg_name +
                                  ':id/artistName')
     else:
         return d(resourceId=self.__pkg_name + ':id/artistName')
예제 #6
0
 def get_radio_to_home(self):
     '''
     底部控制栏,回到主界面的Home控件
     :return:
     '''
     return d(className='android.widget.Button',
              resourceId='com.pateo.radio:id/as_bar_home_id')
예제 #7
0
 def get_radio_AST_icon(self):
     '''
     获取“AST”按钮,可点击
     :return:
     '''
     return d(className='android.widget.Button',
              resourceId='com.pateo.radio:id/bar_radio_scan_id')
예제 #8
0
 def get_radio_back_icon(self):
     '''
     界面左下角back按钮控件,
     :return:
     '''
     return d(className='android.widget.Button',
              resourceId='com.pateo.radio:id/as_bar_back_id')
예제 #9
0
 def get_photo_preview_exit_fullscreen(self):
     """
     获取图片预览界面的退出全屏控件
     :return:
     """
     return d(resourceId=self.__pkg_name +
              ':id/id_toolbar_btn_fullscreen_full')
예제 #10
0
 def get_radio_lists_object(self):
     '''
     获取列表本身的对象,具有滚动属性
     :return:
     '''
     return d(className='android.widget.ListView',
              resourceId='com.pateo.radio:id/radio_info',
              scrollable=True)
예제 #11
0
 def get_radio_lists_frequency(self, text):
     '''
     在节目单中找到指定频率的节目
     :param text: eg: ‘91.5’
     :return: uiobject of 91.5’
     '''
     return d(className='android.widget.ListView', resourceId='com.pateo.radio:id/radio_info', scrollable=True).\
         child_by_text(text,className='android.widget.TextView',allow_scroll_search=True)
예제 #12
0
def step_impl(context):
    # 获取入参
    txt = context.table[0]['text']
    exists_flag = context.table[0]['exists_flag']

    ele = d(textContains=txt)

    if not str(ele.wait.exists()).lower() == exists_flag.lower():
        uit.raise_Exception_info('验证文本是否存在失败')
예제 #13
0
 def get_artist_from_artist_list_by_artist_name(self, artist_name):
     """
     获取歌手列表中指定歌手名称的元素
     :param artist_name
     :return:
     """
     # 获取收藏列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/artist_list')
     if list_view.wait.exists():
         exists_flag = list_view.scroll.vert.to(text=artist_name,
                                                resourceId=self.__pkg_name +
                                                ':id/artistName')
         if exists_flag:
             return d(text=artist_name,
                      resourceId=self.__pkg_name + ':id/artistName')
         else:
             uit.raise_Exception_info('找不到指定歌手')
     else:
         uit.raise_Exception_info('歌手列表不存在')
예제 #14
0
 def get_music_from_collect_list_by_music_name(self, music_name):
     """
     获取收藏列表中指定音乐名称的元素
     :param music_name:
     :return:
     """
     # 获取收藏列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/collect_list')
     if list_view.wait.exists():
         exists_flag = list_view.scroll.vert.to(text=music_name,
                                                resourceId=self.__pkg_name +
                                                ':id/musicName')
         if exists_flag:
             return d(text=music_name,
                      resourceId=self.__pkg_name + ':id/musicName')
         else:
             uit.raise_Exception_info('找不到指定音乐')
     else:
         uit.raise_Exception_info('收藏列表不存在')
예제 #15
0
def step_impl(context):
    screen_num = int(context.table[0]['number'])
    # 判断是否在第一屏
    while not d(text='媒体').wait.exists():
        d.swipe(0, d_height / 2, d_width, d_height / 2, 20)

    for i in range(screen_num - 1):
        d.swipe(d_width / 6 * 5, d_height / 2, 0, d_height / 2, 20)

    time.sleep(2)
예제 #16
0
 def get_music_play_pause_coordinate(self):
     """
     获取音乐播放或者暂停坐标
     :return:
     """
     if d(resourceId=self.__pkg_name + ':id/musicCoverFlow').wait.exists():
         return uit.get_clickcoord_from_bounds(resourceId=self.__pkg_name +
                                               ':id/musicCoverFlow')
     else:
         return uit.get_clickcoord_from_bounds(resourceId=self.__pkg_name +
                                               ':id/musicName')
예제 #17
0
 def get_radio_station_name(self):
     '''
     分析界面,获取当前收音机播放的电台
     :return: eg:’91.5‘
     '''
     try:
         dic = d(resourceId='com.pateo.radio:id/new_frequency_iv').info
     except:
         uit.raise_Exception_info('未找到当前页面上节目控件')
         return ''
     return dic['text']
예제 #18
0
    def back_to_launcher(self):
        '''
        回到主界面
        :desription: 根据当前报名判断回到主界面的方法,然后调用相应方法回到主界面
        :return:
        '''

        d.press.home()
        # 判断是否在第一屏
        while not d(text='媒体').wait.exists():
            d.swipe(0, d_height / 2, d_width, d_height / 2, 20)
예제 #19
0
def step_impl(context):
    """
    点击全部关闭按钮
    :param context:
    :return:
    """
    close_all = d(text='全部关闭')
    if close_all.wait.exists():
        close_all.click()
    else:
        uit.raise_Exception_info('全部关闭按钮不存在')
예제 #20
0
 def get_music_collect_btn_by_album(self, album_name):
     """
     根据专辑信息返回相应收藏控件
     :param album_name: 专辑
     :return:
     """
     # 获取专辑列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/album_list')
     if list_view.exists:
         exists_flag = list_view.scroll.vert.to(text=album_name,
                                                resourceId=self.__pkg_name +
                                                ':id/albumName')
         if exists_flag:
             artist_ele = d(text=album_name,
                            resourceId=self.__pkg_name + ':id/albumName')
             return artist_ele.sibling(resourceId=self.__pkg_name +
                                       ':id/collectBtn')
         else:
             uit.raise_Exception_info('找不到指定专辑')
     else:
         uit.raise_Exception_info('专辑列表不存在')
예제 #21
0
 def get_music_play_status_from_collect_list_by_name(self, music_name):
     """
     从收藏列表中获取音乐的播放状态
     :param music_name:
     :return: True: 播放中 , False: 暂停或者没有播放
     """
     # 获取收藏列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/collect_list')
     if list_view.exists:
         exists_flag = list_view.scroll.vert.to(text=music_name,
                                                resourceId=self.__pkg_name +
                                                ':id/musicName')
         if exists_flag:
             ele = d(text=music_name,
                     resourceId=self.__pkg_name + ':id/musicName')
             return ele.sibling(resourceId=self.__pkg_name +
                                ':id/playStateIcon').exists
         else:
             uit.raise_Exception_info('指定音乐在收藏列表中不存在')
     else:
         uit.raise_Exception_info('收藏列表不存在')
예제 #22
0
 def get_music_collect_btn_by_artist(self, artist_name):
     """
     根据歌手信息返回相应收藏控件
     :param artist_name: 歌手
     :return:
     """
     # 获取歌手列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/artist_list')
     if list_view.exists:
         exists_flag = list_view.scroll.vert.to(text=artist_name,
                                                resourceId=self.__pkg_name +
                                                ':id/artistName')
         if exists_flag:
             artist_ele = d(text=artist_name,
                            resourceId=self.__pkg_name + ':id/artistName')
             return artist_ele.sibling(resourceId=self.__pkg_name +
                                       ':id/collectBtn')
         else:
             uit.raise_Exception_info('找不到指定歌手')
     else:
         uit.raise_Exception_info('歌手列表不存在')
예제 #23
0
 def get_phone_contact_detail_number_ele(self):
     """
     获取联系人详情页面的名字
     :return:
     """
     title_ele = d(resourceId=self.__pkg_name_contact + ':id/title',
                   text='手机号码')
     if title_ele.wait.exists():
         return title_ele.sibling(resourceId=self.__pkg_name_contact +
                                  ':id/content')
     else:
         uit.raise_Exception_info('联系人号码内容不存在')
예제 #24
0
 def get_music_collect_btn_by_collect(self, collect_name):
     """
     根据收藏列表标题信息返回相应收藏控件
     :param collect_name: 收藏列表标题
     :return:
     """
     # 获取收藏列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/collect_list')
     if list_view.exists:
         exists_flag = list_view.scroll.vert.to(text=collect_name,
                                                resourceId=self.__pkg_name +
                                                ':id/musicName')
         if exists_flag:
             artist_ele = d(text=collect_name,
                            resourceId=self.__pkg_name + ':id/musicName')
             return artist_ele.sibling(resourceId=self.__pkg_name +
                                       ':id/collectBtn')
         else:
             uit.raise_Exception_info('找不到指定收藏标题')
     else:
         uit.raise_Exception_info('收藏列表不存在')
예제 #25
0
def step_impl(context):
    # 获取入参确定选项
    yes_or_no = context.table[0]['option']
    ele = music.get_music_collect_btn()
    if ele.wait.exists():
        ele.click()
        if yes_or_no.lower() == 'yes':
            choice = d(text='是')
            if choice.wait.exists():
                choice.click()
            else:
                uit.raise_Exception_info('收藏弹出框不存在')
        elif yes_or_no.lower() == 'no':
            choice = d(text='否')
            if choice.wait.exists():
                choice.click()
            else:
                uit.raise_Exception_info('收藏弹出框不存在')
        else:
            pass
    else:
        uit.raise_Exception_info('收藏按钮不存在')
예제 #26
0
def step_impl(context):
    # 获取要收藏或者取消收藏的专辑名字
    album_name = context.table[0]['album_name']
    yes_or_no = context.table[0]['option']
    ele = music.get_music_collect_btn_by_album(album_name)
    if ele.wait.exists():
        ele.click()
        if yes_or_no.lower() == 'yes':
            choice = d(text='是')
            if choice.wait.exists():
                choice.click()
            else:
                uit.raise_Exception_info('收藏弹出框不存在')
        elif yes_or_no.lower() == 'no':
            choice = d(text='否')
            if choice.wait.exists():
                choice.click()
            else:
                uit.raise_Exception_info('收藏弹出框不存在')
        else:
            pass
    else:
        uit.raise_Exception_info('收藏按钮不存在')
예제 #27
0
 def get_clickcoord_from_bounds(self, **kwargs):
     """
     获取指定元素的中心坐标
     :param kwargs:
     :return:
     """
     ele = d(**kwargs)
     if ele.wait.exists():
         bounds = ele.info['bounds']
         x = (bounds['left'] + bounds['right']) / 2
         y = (bounds['bottom'] + bounds['top']) / 2
         return (x, y)
     else:
         self.raise_Exception_info('指定元素不存在')
예제 #28
0
 def get_phone_contact_by_name(self, name):
     """
     根据提供的通讯录名字获取联系人
     :param name:
     :return:
     """
     contact_list = self.get_phone_contacts_listView_ele()
     if contact_list.wait.exists():
         flag = contact_list.scroll.vert.to(text=name)
         if flag:
             return d(text=name)
         else:
             uit.raise_Exception_info('指定联系人在通讯录中不存在')
     else:
         uit.raise_Exception_info('通讯录列表不存在')
예제 #29
0
 def get_radio_list_first_name(self):
     '''
     在list中找第一个子元素,获取第一个节目频道
     :return: 列表第一个电台的名字,eg:91.5
     '''
     ele = d(className='android.widget.ListView',
             resourceId='com.pateo.radio:id/radio_info').child(index=0)
     try:
         dic = ele.child(
             resourceId='com.pateo.radio:id/radio_list_frequency_name',
             className='android.widget.TextView').info
     except:
         uit.raise_Exception_info('未找到列表第一列元素')
         return ''
     return dic['text']
예제 #30
0
 def get_music_collect_status_from_collect_list_by_name(self, music_name):
     """
     获取指定音乐名称是否在收藏列表中
     :param music_name:
     :return: True: 已收藏, False: 未收藏
     """
     # 获取收藏列表listview
     list_view = d(resourceId=self.__pkg_name + ':id/collect_list')
     if list_view.exists:
         exists_flag = list_view.scroll.vert.to(text=music_name,
                                                resourceId=self.__pkg_name +
                                                ':id/musicName')
         return exists_flag
     else:
         uit.raise_Exception_info('收藏列表不存在')