예제 #1
0
def step_impl(context):

    ele = radio.get_radio_frequency_id()
    if ele.wait.exists():
        ele.swipe.left()
    else:
        uit.raise_Exception_info("收音机向左滑动异常")
예제 #2
0
def step_impl(context):

    ele = radio.get_radio_frequency_id()
    if ele.wait.exists():
        ele.click()
    else:
        uit.raise_Exception_info("点击收音机播放或暂停失败")
예제 #3
0
def step_impl(context):
    value = context.table[0]['radio_station']
    ele = radio.get_radio_lists_frequency(value.strip())
    if ele.wait.exists():
        ele.click()
    else:
        uit.raise_Exception_info("电台列表实体获取或者滚动失败")
예제 #4
0
def step_impl(context):
    #获取收藏控件
    fav_ele = Video().get_aqy_player_fav()
    if fav_ele.wait.exists():
        fav_ele.click()
    else:
        uit.raise_Exception_info('视频收藏控件不存在')
예제 #5
0
def step_impl(context):
    ele = radio.get_radio_AST_icon()
    if ele.wait.exists():
        ele.click()
        time.sleep(0.5)
    else:
        uit.raise_Exception_info("电台自动扫描AST按钮未找到")
예제 #6
0
def step_impl(context):
    #获取两个对象和一个比较字符
    param1 = context.table[0]['param1']
    param2 = context.table[0]['param2']
    opt = context.table[0]['option']

    if param1.startswith('o_'):
        param1 = ht.get_context_map(param1)

    if param2.startswith('o_'):
        param2 = ht.get_context_map(param2)

    if opt == '==':
        flag = param1.lower() == param2.lower()
    elif opt == '!=':
        flag = param1.lower() != param2.lower()
    elif opt == '%':
        flag = param1.lower().__contains__(param2.lower())
    elif opt == ">":
        flag = int(param1.lower()) > int(param2.lower())
    elif opt == "<":
        flag = int(param1.lower()) < int(param2.lower())
    else:
        raise ('暂时不支持改操作符,请联系脚本维护人员')

    if not flag:
        uit.raise_Exception_info('比较失败《' + param1 + ' ' + opt + ' ' + param2 +
                                 '》')
예제 #7
0
def step_impl(context):
    """
    验证图片文件夹数量一致
    :param context:
    :return:
    """
    # 获取文件夹名称和期望数量
    folder_name = context.table[0]['folder_name']
    photo_number = context.table[0]['number']
    if photo_number.startswith('o_'):
        if '-' in photo_number:
            var_number_list = photo_number.split('-')
            photo_number = str(
                int(MAP_VAR[var_number_list[0]]) - int(var_number_list[1]))
        elif '+' in photo_number:
            var_number_list = photo_number.split('+')
            photo_number = str(
                int(MAP_VAR[var_number_list[0]]) + int(var_number_list[1]))
        else:
            photo_number = MAP_VAR[photo_number]

    # 获取指定文件夹控件
    folder_ele = photo.get_photo_folder_by_name(folder_name)
    if folder_ele.wait.exists():
        # 获取数量
        number = re.findall(r"\((\d+)\)$", folder_ele.text.strip())[0]
        if not photo_number == number:
            uit.raise_Exception_info('图片数量比对不一致,期望值为%s, 实际值为%s' %
                                     (photo_number, number))
    else:
        uit.raise_Exception_info('指定图片文件夹不存在')
예제 #8
0
    def click_radio_selector_fm_by_no_ele(self, fm_no):
        flag = True
        #先滑到顶部
        self.scroll_radio_selector_listview_to_beginning()
        # 获取listview
        ele = self.__get_radio_selector_fm_listview_ele()
        if ele.wait.exists():
            # 查找是否存在该fm_no  ele.scroll.vert.forward
            ele_fm = d(text=fm_no)

            if ele_fm.wait.exists():
                flag = False
                ele_fm.click.wait()
            else:
                while ele.scroll.vert.forward(steps=5) and flag:
                    ele_fm = d(text=fm_no)
                    if ele_fm.wait.exists():
                        flag = False
                        ele_fm.click.wait()
                        break

            if flag:
                uit.raise_Exception_info('指定《' + fm_no + '》不存在')
        else:
            uit.raise_Exception_info('FM选择界面的listview不存在')
예제 #9
0
    def dial_phone_number(self, phone_number):
        """
        输入要拨打的号码
        :param phone_number:
        :return:
        """
        time.sleep(2)

        for c in phone_number:
            if c == '1':
                d(resourceId=self.__pkg_name_contact + ':id/one').click()
            elif c == '2':
                d(resourceId=self.__pkg_name_contact + ':id/two').click()
            elif c == '3':
                d(resourceId=self.__pkg_name_contact + ':id/three').click()
            elif c == '4':
                d(resourceId=self.__pkg_name_contact + ':id/four').click()
            elif c == '5':
                d(resourceId=self.__pkg_name_contact + ':id/five').click()
            elif c == '6':
                d(resourceId=self.__pkg_name_contact + ':id/six').click()
            elif c == '7':
                d(resourceId=self.__pkg_name_contact + ':id/seven').click()
            elif c == '8':
                d(resourceId=self.__pkg_name_contact + ':id/eight').click()
            elif c == '9':
                d(resourceId=self.__pkg_name_contact + ':id/nine').click()
            elif c == '0':
                d(resourceId=self.__pkg_name_contact + ':id/zero').click()
            elif c == '*':
                d(resourceId=self.__pkg_name_contact + ':id/star').click()
            elif c == '#':
                d(resourceId=self.__pkg_name_contact + ':id/pound').click()
            else:
                uit.raise_Exception_info('电话号码格式不正确')
예제 #10
0
def before_all(context):
    # 发送消息到客户端
    cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        cli.connect(('localhost', 8899))
        cli.send('start'.encode('utf-8'))
        time.sleep(2)
    except:
        pass
    finally:
        cli.close()

    print('校验设备是否连接')
    serialNum = ht.get_conf_value('deviceSerial')
    if not ht.check_is_connected(serialNum):
        uit.raise_Exception_info('车机没有连接请检查')

    print('设备已经连接')
    # 安装utf7ime输入法并设置为默认输入法
    print('开始设置输入法')
    try:
        utf7apk_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    'support', 'Utf7Ime.apk')
        subprocess.call('adb -s ' + serialNum + ' install -r ' + utf7apk_path,
                        shell=True)
        # 设置输入法
        subprocess.call(
            'adb -s ' + serialNum +
            ' shell settings put secure default_input_method jp.jun_nama.test.utf7ime/.Utf7ImeService',
            shell=True)
        print('输入法设置完成')
    except Exception as e:
        print(e)
예제 #11
0
def step_impl(context):
    ele = home.get_music_prev_btn()

    if ele.wait.exists():
        ele.click()
    else:
        uit.raise_Exception_info('主页音乐播放上一首按钮不存在')
예제 #12
0
def step_impl(context):
    # 获取音乐名称
    music_name = context.table[0]['music_name']
    # 获取usb歌曲列表
    usb_music_tuple = ht.get_usb_music()
    if music_name not in usb_music_tuple:
        uit.raise_Exception_info('指定音乐名称《' + music_name + '》不是U盘音乐')
예제 #13
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('搜索框不存在')
예제 #14
0
def step_impl(context):
    chk_tinymix = context.table[0]['chk_tinymix']
    # 获取当前的放音通道
    cur_tinymix = ht.get_cur_tinymix()
    if chk_tinymix != cur_tinymix:
        uit.raise_Exception_info('放音通道不一致,期望值为《' + chk_tinymix + '》,实际值为《' +
                                 cur_tinymix + '》')
예제 #15
0
def step_impl(context):
    ele = music.get_music_mylove_btn()
    if ele.wait.exists():
        x_coordinate, y_coordinate = uit.get_clickcoord_by_ele(ele)
        d.click(x_coordinate, y_coordinate)
    else:
        uit.raise_Exception_info('最爱音乐按钮不存在')
예제 #16
0
def before_all(context):
    print('校验设备是否连接')
    serialNum = ht.get_conf_value('deviceSerial')
    if not ht.check_is_connected(serialNum):
        uit.raise_Exception_info('车机没有连接请检查')

    print('设备已经连接')
    #安装utf7ime输入法并设置为默认输入法
    print('开始设置输入法')
    try:
        utf7apk_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'support', 'Utf7Ime.apk')
        subprocess.call('adb -s ' + serialNum + 'install -r ' + utf7apk_path, shell=True)
        # 设置输入法
        subprocess.call('adb -s ' + serialNum + ' shell settings put secure default_input_method jp.jun_nama.test.utf7ime/.Utf7ImeService', shell=True)
        print('输入法设置完成')
    except Exception as e:
        print(e)



    # 清空logcat日志记录
    log_path = ht.get_conf_value('logPath')

    if sys.platform == 'linux':
        subprocess.call('rm -rf ' + log_path, shell=True)
    else:
        subprocess.call('rd /q/s ' + log_path, shell=True)
예제 #17
0
def step_impl(context):
    # 获取视频搜索控件
    search = Video().get_aqy_search()
    if search.wait.exists():
        search.click.wait()
    else:
        uit.raise_Exception_info('视频搜索控件不存在')
예제 #18
0
def step_impl(context):
    ele1 = d(textContains = '航空')
    ele2 = d(textContains='-->')
    ele3 = d(textContains=':')

    if not (ele1.wait.exists(timeout = ht.LONG_TIME_OUT) and ele2.wait.exists(timeout = ht.LONG_TIME_OUT) and ele3.wait.exists(timeout = ht.LONG_TIME_OUT)):
        uit.raise_Exception_info('航班信息验证失败')
예제 #19
0
 def click_audio_kuwo_name_random_ele(self):
     ele = self.__get_audio_kuwo_name_ele()
     if ele.wait.exists():
         ele.click()
     else:
         uit.raise_Exception_info('酷我专辑不存在')
     '''
예제 #20
0
 def click_qplay_ele(self):
     ele = d(text='QPlay')
     ele.wait.exists()
     if ele.exists:
         ele.click.wait()
     else:
         uit.raise_Exception_info('QPlay图标不存在')
예제 #21
0
def step_impl(context):
    ele = music.get_music_prev_btn()
    cur_time = music.get_music_cur_time_ele()
    cur_music_name = music.get_music_name_ele()
    if ele.wait.exists():
        # 获取当前时间秒数
        before_time = cur_time.text.strip().split(':')
        before_seconds = int(before_time[0]) * 60 + int(before_time[1])

        before_music_name = cur_music_name.text.strip()

        bounds = ele.info['bounds']
        x = (bounds['left'] + bounds['right']) / 2
        y = (bounds['bottom'] + bounds['top']) / 2
        # 长按上一首按钮
        d.swipe(x, y, x, y, 50)

        #获取快进后的时间
        time_ele = music.get_music_cur_time_ele()
        music_name_ele = music.get_music_name_ele()
        after_time = time_ele.text.strip().split(':')
        after_seconds = int(after_time[0]) * 60 + int(after_time[1])

        after_music_name = music_name_ele.text.strip()

        if before_seconds - after_seconds > 5 and before_music_name == after_music_name:
            pass
        else:
            uit.raise_Exception_info('快退异常')

    else:
        uit.raise_Exception_info('快退按钮不存在')
예제 #22
0
def step_impl(context):
    # 获取专辑名称和期望收藏状态
    album_name = context.table[0]['album_name']
    collected_status = context.table[0]['collected_status']

    flag = music.get_album_collect_status_from_album_list_by_name(album_name)
    if collected_status.lower() != str(flag).lower():
        uit.raise_Exception_info('指定专辑《' + album_name + '》收藏状态不一致')
예제 #23
0
def step_impl(context):
    # 获取音乐名称和期望收藏状态
    music_name = context.table[0]['music_name']
    collected_status = context.table[0]['collected_status']

    flag = music.get_music_collect_status_from_collect_list_by_name(music_name)
    if collected_status.lower() != str(flag).lower():
        uit.raise_Exception_info('指定音乐《' + music_name + '》收藏状态不一致')
예제 #24
0
 def __get_audio_mine_usb_play_ele(self):
     ele = self.__get_audio_mine_usb_ele()
     if ele.wait.exists():
         ele1 = ele.sibling(resourceId=pkg_name + ':id/mltImage')
         ele1.wait.exists()
         return ele1
     else:
         uit.raise_Exception_info('USB音乐控件不存在')
예제 #25
0
def step_impl(context):
    # 校验最高温度控件 最低温度控件  天气提示文本是否存在
    ele_high = Ivoka().get_weather_temperature_high_ele()
    ele_low = Ivoka().get_weather_temperature_low_ele()
    ele_tip = Ivoka().get_weather_tip_ele()

    if not  (ele_high.wait.exists() and ele_low.wait.exists() and ele_tip.wait.exists()):
        uit.raise_Exception_info('天气信息验证失败')
예제 #26
0
 def back_from_kuwo(self):
     # package_name = d.info['currentPackageName']
     back = uit.get_ele_by_resourceId(
         'cn.kuwo.kwmusiccar:id/layoutPlayControlPanel')
     if back.wait.exists():
         back.click.wait()
     else:
         uit.raise_Exception_info('从酷我返回到音乐控件不存在')
예제 #27
0
def step_impl(context):
    # 获取参数
    chk_is_playing = context.table[0]['chk_is_playing']
    # 获取当前播放状态
    time.sleep(2)
    is_playing = Radio().get_radio_is_playing()
    if not str(chk_is_playing).lower().__eq__(str(is_playing).lower()):
        uit.raise_Exception_info('电台播放状态不一致')
예제 #28
0
 def click_radio_qt_collected_title_ele(self):
     ele = self.__get_radio_qt_collected_title_ele()
     size = len(ele)
     if size > 0:
         ele[0].click.wait()
         return ele[0].text.strip()
     else:
         uit.raise_Exception_info('收藏的蜻蜓FM列表为空')
예제 #29
0
def step_impl(context):
    ele1 = d(textContains='%')
    ele2 = d(textContains='指数')
    ele3 = d(textContains='当前')
    ele4 = d(textContains='点')

    if not (ele1.wait.exists(timeout = ht.LONG_TIME_OUT) and ele2.wait.exists(timeout = ht.LONG_TIME_OUT) and ele3.wait.exists(timeout = ht.LONG_TIME_OUT) and ele4.wait.exists(timeout = ht.LONG_TIME_OUT)):
        uit.raise_Exception_info('证券信息验证失败')
예제 #30
0
def step_impl(context):
    # 获取目的地地址出参
    param = context.table[0]['o_result']
    ele = Navi().get_navi_ready_dest_ele()
    if ele.wait.exists():
        ht.set_context_map(param, ele.text.strip())
    else:
        uit.raise_Exception_info('导航目的地控件不存在')