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: Utils().raise_Exception_info('指定《' + fm_no + '》不存在') else: Utils().raise_Exception_info('FM选择界面的listview不存在')
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('航班信息验证失败')
def step_impl(context): exists_flag = False # 获取视频名称 video_name = context.table[0]['video_name'] video_folder = context.table[0]['video_folder'] if video_folder != '.': folder_ele = d(text=video_folder) if folder_ele.wait.exists(): d(text=video_folder).click.wait() else: Utils().raise_Exception_info('指定文件夹不存在') # 查找并播放本地视频 local_video = Video().get_aqy_mine_local_video_title() if local_video.wait.exists(): for lv in local_video: if lv.text == video_name: lv.click.wait() exists_flag = True break else: Utils().raise_Exception_info('本地视频列表为空') if not exists_flag: Utils().raise_Exception_info('没有找到指定视频')
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('证券信息验证失败')
def click_audio_mine_all_by_name(self, music_name): ele = self.__get_audio_mine_all_listview_ele() if ele.wait.exists(): if ele.scroll.vert.to(text=music_name): d(text=music_name).click.wait() # 1s时间等待音乐播放界面刷新 time.sleep(1) else: uit.raise_Exception_info('指定音乐《' + music_name + '》不存在') else: uit.raise_Exception_info('音乐列表控件不存在')
def au_next(self): d(resourceId='com.qinggan.app.launcher:id/app_music').click() time.sleep(2) d(resourceId='com.qinggan.app.music:id/img_next', ).click() time.sleep(2) d.click(640,656) time.sleep(2) d.click(880, 656) time.sleep(2) d.click(880,656) time.sleep(2)
def click_audio_search_result_by_name(self, name): ele = self.__get_audio_search_listview_ele() music_search = self.__get_audio_search_name_ele() if music_search.wait.exists(timeout=ht.LONG_TIME_OUT): if ele.scroll.vert.to(text=name): d(text=name).click.wait() # 1s时间音乐播放界面刷新 time.sleep(1) else: uit.raise_Exception_info('指定音乐不存在') else: uit.raise_Exception_info('在线音乐搜索结果为空,可能是搜索时间过长')
def step_impl(context): #获取播放视频名称 video_name = context.table[0]['video_name'] # 点击播放记录控件进入播放记录界面 Video().click_video_mine_play_his_ele() # 从列表中查找指定视频并播放 ele = Video().get_video_mine_play_his_list_ele() if ele.wait.exists(): if ele.scroll.vert.to(text=video_name): d(text=video_name).click.wait() else: Utils().raise_Exception_info('没有查找到指定《' + video_name + '》视频') else: Utils().raise_Exception_info('播放记录为空')
def step_impl(context): # 获取播放视频名称 video_name = context.table[0]['video_name'] # 从列表中查找指定视频并播放 ele = Video().get_aqy_mine_his_video_title() if ele.wait.exists(): # if ele.scroll.vert.to(text=video_name): for e in ele: if e.text.strip() == video_name: d(text=video_name).click.wait() break else: Utils().raise_Exception_info('没有查找到指定《' + video_name + '》视频') else: Utils().raise_Exception_info('播放记录为空')
def click_qplay_ele(self): ele = d(text='QPlay') ele.wait.exists() if ele.exists: ele.click.wait() else: uit.raise_Exception_info('QPlay图标不存在')
def click_video_mine_local_video_by_name(self, video_name): ele = d(text=video_name, resourceId=pkg_name + ':id/local_video_item_name') if ele.wait.exists(): ele.click.wait() else: Utils().raise_Exception_info('本地视频《' + video_name + '》不存在')
def step_impl(context): # 新加步骤 # 判断是否在播放界面 view_full = Video().get_aqy_video_view_full() if view_full.exists: back_video = Video().get_aqy_playing_back() if not back_video.exists: d.click(320, 320) if back_video.wait.exists(): back_video.click.wait() # 判断是否在搜索界面,如果在搜索界面先取消搜索 cancel_ele = d(text='取消') if cancel_ele.exists: cancel_ele.click.wait() # 判断是否在本地视频列表界面,如果在,返回 back_top_menu = Video().get_back_to_top_menu() if back_top_menu.exists: back_top_menu.click.wait() # 获取左侧菜单 left_menu = Video().get_aqy_left_menu_frame() if left_menu.wait.exists(): x = left_menu.info['bounds']['right'] y = left_menu.info['bounds']['bottom'] d.swipe(x, int(y) / 2, 0, int(y) / 2, 15) top_menu = Video().get_aqy_home_top_menu() if top_menu.wait.exists(): top_menu.click.wait() else: Utils().raise_Exception_info('爱奇艺顶部菜单不存在')
def click_syssetting_bluetooth_ele(self): ele = d(textContains='蓝牙', resourceId=pkg_name + ':id/bluetooth_title') ele_scan = d(text='重新扫描', resourceId=pkg_name + ':id/btn_bluetooth_scan') # 防止有修复控件挡住控件点击 if not ele.wait.exists(timeout=5000): d.click(1150, 80) self.click_syssetting_menu_net_ele() if ele.wait.exists(timeout=5000): ele.click.wait() if not ele_scan.wait.exists(): d.click(1150, 80) time.sleep(2) ele.click() else: uit.raise_Exception_info('蓝牙菜单展开失败')
def click_navi_ele(self): if self.__get_navi_ele().exists: self.__get_navi_ele().click.wait() # 是否需要激活 serial_number = d( resourceId='com.pateonavi.naviapp:id/et_serialnum') active_number = d( resourceId='com.pateonavi.naviapp:id/et_activenum') confirm = d( resourceId='com.pateonavi.naviapp:id/tv_active_confirmorcancel' ) if serial_number.exists: time.sleep(2) if len(serial_number.text) and len(active_number.text): confirm.click.wait() self.__get_navi_ele().click.wait() else: uit.raise_Exception_info('导航激活失败') else: uit.raise_Exception_info('主界面导航控件不存在')
def ivoka_start_app(self, voice_name): ivoka_flag = False Utils().play_voice('你好语音助理.m4a') ele = d(text='你好,请说') ele1 = d(text='没听清,请再说一次') loop = 0 while (loop <= 3) and (not ivoka_flag): if ele.wait.exists(timeout=8000): Utils().play_voice(voice_name) ivoka_flag = True if ele1.wait.exists(timeout=8000): Utils().play_voice(voice_name) ivoka_flag = True else: Utils().play_voice('你好语音助理.m4a') loop += 1 if not ivoka_flag: Utils().raise_Exception_info('ivoka唤醒失败')
def connect_syssetting_special_bluetooth(self, bt_name): ele = self.__get_syssetting_bluetooth_list_ele() if ele.scroll.vert.to(text=bt_name): e = d(text=bt_name) e_btn = e.sibling(resourceId=pkg_name + ':id/bluetooth_device_btn') if e_btn.text.strip() == '连接': e_btn.click() self.back_to_launcher() return False else: self.back_to_launcher() return True
def step_impl(context): addr = context.table[0]['address'] if str(addr).startswith('o_'): addr = ht.get_context_map(addr) # 获取删除控件并点击 del_ele = Navi().get_navi_his_fav_del_ele(addr) if del_ele.wait.exists(): del_ele.click() # 点击完成控件 完成删除操作 ok_ele = d(text='完成') if ok_ele.wait.exists(): ok_ele.click()
def step_impl(context): addr = context.table[0]['address'] if str(addr).startswith('o_'): addr = ht.get_context_map(addr) list_view = Navi().get_navi_search_listview_ele() if list_view.wait.exists(): if list_view.info['scrollable']: flag = list_view.scroll.vert.to(text=addr) if flag: ele = d(text=addr) if ele.wait.exists(): ele.click.wait() else: uit.raise_Exception_info('指定收藏地址不存在') else: uit.raise_Exception_info('指定收藏地址不存在') else: ele = d(text=addr) if ele.wait.exists(): ele.click.wait() else: uit.raise_Exception_info('收藏列表不存在')
def click_radio_selector_fm_faved(self): # 进入到FM页签 self.click_radio_selector_fm_ele() self.click_radio_selector_fm_ele() # 获取listview ele_listview = self.__get_radio_selector_fm_listview_ele() if ele_listview.exists: if ele_listview.scroll.vert.to(resourceId =pkg_name + ':id/crown'): ele = d(resourceId = pkg_name + ':id/crown') ele.click.wait() # 返回收藏的台号 # return ele.sibling(resourceId=pkg_name + ':id/list_freq').text.strip() else: Utils().raise_Exception_info('没有找到收藏的电台') else: Utils().raise_Exception_info('FM选择界面的listview不存在')
def step_impl(context): # 获取参数信息 addr = context.table[0]['address'] is_faved = context.table[0]['is_faved'] if str(addr).startswith('o_'): addr = ht.get_context_map(addr) list_view = Navi().get_navi_search_listview_ele() if list_view.wait.exists(): if list_view.info['scrollable']: flag = list_view.scroll.vert.to(text=addr) else: ele = d(text=addr) flag = ele.wait.exists() if str(flag).lower() != is_faved.lower(): uit.raise_Exception_info('验证是否被收藏状态不一致,期望值为:' + is_faved + ', 实际值为:' + str(flag)) else: uit.raise_Exception_info('收藏列表不存在')
def before_all(context): print('校验设备是否连接') serialNum = Utils().get_conf_value('deviceSerial') if not Utils().check_is_connected(serialNum): Utils().raise_Exception_info('车机没有连接请检查') print('设备已经连接') phone_serialNum = Utils().get_conf_value('phoneSerial') if not Utils().get_wifi_conn_status(): Common().connect_special_wifi('WiFiTEST', '123454321') # 链接设备大于1个时候连接蓝牙 if Utils().check_is_connected(phone_serialNum): print('连接蓝牙设备') # Utils().connect_bluetooth() Common().back_to_launcher() Launcher().click_system_setting_ele() SysSetting().click_syssetting_menu_net_ele() SysSetting().click_syssetting_bluetooth_ele() flag = SysSetting().connect_syssetting_special_bluetooth( Utils().get_conf_value('phoneBluetoothName')) if not flag: Phone().click_pair_ele() print('应用初始化') print('刷新收音机列表') Common().back_to_launcher() Launcher().click_radio_ele() print('激活导航地图') Common().back_to_launcher() Launcher().click_navi_ele() Navi().active_navi() # Radio().click_radio_selector_ele() # Radio().click_radio_selector_fm_ele() # Radio().refresh_radio_selector_listview() time.sleep(3) ele = d(textContains='电台扫描中') if ele.wait.exists(timeout=30000): ele.wait.gone(timeout=60000) print('收音机列表刷新结束')
def back_to_launcher(self): #如果在删除地址界面就点击完成以便退出(如:在收藏地址删除界面) ele = d(text='完成') if ele.wait.exists(): ele.click() nearby_ele = self.__get_navi_nearby_close_ele() if nearby_ele.wait.exists(): nearby_ele.click() # 判断是否在二级界面 search_cancel = self.get_navi_search_cancel_ele() if search_cancel.wait.exists(): search_cancel.click.wait() btn_back = self.get_navi_nearby_back_ele() if btn_back.wait.exists(): btn_back.click.wait() map_back = self.__get_navi_mapback_ele() if map_back.wait.exists(): map_back.click.wait() cr = self.get_navi_current_road_name_ele() navi_home = self.__get_navi_home_ele() if cr.wait.exists(): cr.click() navi_home.click.wait() elif navi_home.wait.exists(): navi_home.click.wait() else: # 激活界面 # 取消激活 confirmorcancel_ele = self.__get_navi_active_confirmorcancel() if confirmorcancel_ele.wait.exists(): confirmorcancel_ele.click.wait()
def connect_special_wifi(self, ssid, pwd): Common().back_to_launcher() Launcher().click_system_setting_ele() SysSetting().click_syssetting_menu_net_ele() ele = d(resourceId='com.qinggan.app.setting:id/wifi_header') ele1 = ele.child(text='WIFI', resourceId='com.qinggan.app.setting:id/wifi_title') if not ele1.wait.exists(): d.click(1150, 80) SysSetting().click_syssetting_menu_net_ele() # flag_ele = ele.child(resourceId = 'com.qinggan.app.setting:id/wifi_switcher') # flag_ele.click() ele.click.wait() scan_ele = d(text='重新扫描', resourceId='com.qinggan.app.setting:id/btn_wifi_scan') while not scan_ele.wait.exists(): ele.click.wait() wifi_ssid_ele = d( resourceId='com.qinggan.app.setting:id/wifi_scanresult_name') if wifi_ssid_ele.wait.exists(timeout=Utils().LONG_TIME_OUT): ele = d(resourceId='com.qinggan.app.setting:id/wifi_device_list') if not ele.scroll.vert.to(text=ssid): scan_ele.click() wifi_ssid_ele.wait.exists(timeout=Utils().LONG_TIME_OUT) ele.scroll.vert.to(text=ssid) ele1 = d(text=ssid) con_ele = ele1.sibling(text='连接') if con_ele.wait.exists(): con_ele.click() pwd_ele = d(resourceId='com.qinggan.app.setting:id/wifi_pwd_input') if pwd_ele.wait.exists(): pwd_ele.set_text(pwd) ele1.sibling(text='连接').click() else: Utils().raise_Exception_info('刷新时间过长')
def step_impl(context): Video().click_video_search_clear_ele() if not (d(text='热门搜索').wait.exists() and d(text='搜索记录').wait.exists()): Utils().raise_Exception_info('清空搜索框返回界面不正确')
def __get_radio_no_ele(self): ele = d(resourceId = pkg_name + ':id/freq_tv', className = 'android.widget.TextView') ele.wait.exists() return ele
def check_qplay_init(self): # 等待3s time.sleep(3) if not d(text='连接QPlay').wait.exists(): uit.raise_Exception_info('当前不是QPlay初始界面')
def __get_audio_mine_usb_ele(self): ele = d(text='USB歌曲', resourceId=pkg_name + ':id/txt_title') ele.wait.exists() return ele
def chk_audio_usb_gone(self): ele = d(text='请接入U盘') time.sleep(ht.TIME_OUT) return ele.exists
def step_impl(context): txt = context.table[0]['contains_txt'] ele = d(textContains=txt) if not ele.wait.exists(timeout=ht.TIME_OUT): uit.raise_Exception_info('文本信息《' + txt + '》没有包含在界面中')
def get_radio_ide_status(self): ele = d(text = '未识别到歌曲') return not ele.wait.exists(timeout = Utils().LONG_TIME_OUT)