def clickSearchRadio(self): print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) element = pm.find_element_by_id( self, id="com.archermind.saic.radio:id/btn_radio_amfm_search") print("Click SearchRadio") pm.click_by_element(self, element=element) print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) while True: if pm.find_element_by_id( self, id= "com.archermind.saic.radio:id/btn_radio_scan_dialog_cancel" ).exists(): time.sleep(5) # 等待搜台 print("sleep 5s") else: print("Finish Serach ") break if pm._find_element_by_text(self, "No Frequency").get_text( ) == "No Frequency": # 如果界面有No Frequency显示,说明没有搜到电台 print("No Frequency") return False else: print("Success to Serach") return True
def changeTemperatureTypeToF(self): self.clickSetting() # 进入天气设置页面 element_F = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get( 'TemperatureF')) element_Back = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get('Back')) pm.click_by_element(self, element=element_F) # 设置单位F pm.click_by_element(self, element=element_Back) # 返回天气详情页面 self.compareWeather()
def clickPlayStation(self): element = pm.find_element_by_id( self, id="com.archermind.saic.radio:id/btn_radio_amfm_play") print("Click PlayStation") pm.click_by_element(self, element=element) if pm.find_element_by_id( self, id="com.archermind.saic.radio:id/btn_radio_amfm_pause").exists: print('change status to Play success') return True else: return False
def changeTemperatureTypeToC(self): self.clickSetting() # 进入天气设置页面 element_C = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get( 'TemperatureC')) element_Back = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get('Back')) pm.click_by_element(self, element=element_C) # 设置单位C pm.click_by_element(self, element=element_Back) # 返回天气详情页面 print("start Compare") self.compareWeather()
def changeToFM(self): self.changeRadio() element = pm.find_element_by_id( self, id="com.archermind.saic.radio:id/btn_fm") print("Click changeToFM") pm.click_by_element(self, element=element) time.sleep(0.5) if pm.find_element_by_id( self, id="com.archermind.saic.radio:id/tx_radio_amfm_hz_type" ).get_text() == 'MHz': print('change status to FM success') return True else: return False
def clickDockBarVehicleSetting(self): element = pm.find_element_by_id( self, id=india_D90_propertiseConfig.homePageConfig.get( 'DockBarVehicleSetting')) print("Click Dock Bar VehicleSetting") return pm.click_by_element(self, element=element)
def clickDockBarLockScreen(self): element = pm.find_element_by_id( self, id=india_D90_propertiseConfig.homePageConfig.get( 'DockBarLockScreen')) print("Click Dock Bar Lock Screen") return pm.click_by_element(self, element=element)
def GotoWeatherPage(self): if pm.Home(self): weather = pm.find_element_by_id( self, id=india_D90_propertiseConfig.homePageConfig.get('Weather')) return pm.click_by_element(self, weather) return False
def clickSearchSearch(self): element = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get( 'PositionSearch')) print("Refresh Weather") return pm.click_by_element(self, element=element)
def clickScreenHomeKey(self): pm.pressButtenByKeyevent(self, 'ScreenHomeKey') # 使用屏幕Home键返回首页 element = pm.find_element_by_id( self, id=india_D90_hardKeyPropertiseConfig.homePageConfig.get( 'Navigation')) return pm.click_by_element(self, element=element) # 检测到地图模块控件说明已返回首页
def chooseTemperatureF(self): element = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get( 'TemperatureF')) print("TemperatureF") return pm.click_by_element(self, element=element)
def clickMusicpreviousSong(self): ''' click homePage previous song button :return: ''' element = pm.find_element_by_id( self, id="launcher.n4.launcher82:id/btn_music_previous") return pm.click_by_element(self, element=element)
def closeWeatherWarning(self): if self.checkCloseWeatherWarning() == True: # 天气预警已经打开直接返回True print('already close') return True else: element = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get( 'WeatherAlarm')) print("Close Weather Warning") pm.click_by_element(self, element=element) if self.checkCloseWeatherWarning() == True: print("Close Weather Warning Success") return True else: print("Close Weather Warning Fail") return False
def clickItem(self, text): elist = pm.find_element_by_id(self, id=conf.userManualPage.get('menuContentList')) if elist: pm.swipe_forwardto_description(self, text) element = pm.find_element_by_text(self, text=text) if element: return pm.click_by_element(self, element) return False
def clickUserIcon(self): ''' click homePage UserIcon :return: ''' element = pm.find_element_by_id( self, id="launcher.n4.launcher82:id/cv_image") return pm.click_by_element(self, element=element)
def clickUserCard(self): ''' click homePage UserCard :return: ''' element = pm.find_element_by_id( self, id="launcher.n4.launcher82:id/rl_user_card") return pm.click_by_element(self, element=element)
def clickMusicNextSong(self): ''' click homePage next song button :return: ''' element = pm.find_element_by_id( self, id="launcher.n4.launcher82:id/btn_music_next") return pm.click_by_element(self, element=element)
def clickMusicPause(self): ''' click homePage music pause Button :return: ''' element = pm.find_element_by_id( self, id="launcher.n4.launcher82:id/ll_music_control_bg") return pm.click_by_element(self, element=element)
def clickMusicIcon(self): ''' click homePage music Icon :return: ''' element = pm.find_element_by_id( self, id="launcher.n4.launcher82:id/img_music_default") return pm.click_by_element(self, element=element)
def clickEV_BATTERY(self): ''' click homePage Weather button :return: ''' element = pm._find_element_by_text(self, text="EV BATTERY") print("Click EV BATTERY") return pm.click_by_element(self, element=element)
def clickSteeringWheelVolumeUp(self): pm.pressButtenByKeyevent(self, 'clickSteeringWheelVolumeUp') # 使用屏幕Home键返回首页 element = pm.find_element_by_id( self, id=india_D90_hardKeyPropertiseConfig.homePageConfig.get( 'VolumnBar')) return pm.click_by_element(self, element=element) # 检测到地图模块控件说明已返回首页
def clickNav(self): ''' click home page Navi button :return: ''' element = pm.find_element_by_id( self, id="com.archermind.saic.launcher:id/iv_navi_image") print("Click Nav") return pm.click_by_element(self, element=element)
def clickWeather(self): ''' click homePage Weather button :return: ''' element = pm.find_element_by_id( self, id="com.archermind.saic.launcher:id/iv_weather_big") print("Click Weather") return pm.click_by_element(self, element=element)
def clickCollectAMFMHeartIcon(self): element = pm.find_element_by_id( self, id="com.archermind.saic.radio:id/btn_radio_amfm_non_heart" ) # 获取未收藏图标进行判断当前是否需要收藏 if element.exists(): print("Click Collect") pm.click_by_element(self, element=element) elementAfterClick = pm.find_element_by_id( self, id="com.archermind.saic.radio:id/btn_radio_amfm_heart" ) # 获取已收藏图标进行判断是否已被收藏 if elementAfterClick.exists(): print("Collected Success") return True else: return False else: print("Already Collected") return True
def clickMG(self): print('start find ' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) element = pm._find_element_by_text(self, "MG iSMART") print("Click MG iSMART") print('end find ' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) return pm.click_by_element(self, element=element)
def clickSaicAccount(self): elements = [] # 再此休眠1秒确保该指令之前的动作完成 time.sleep(1) elements = BasePage.find_element_by_Xpath( self, Xpath= '//*[@resource-id="com.archermind.saic.launcher:id/rv_menu_list"]/android.view.ViewGroup[1]' ) return pm.click_by_element(self, element=elements)
def clickInbox(self): # 获取主页右侧RecyclerView并上拉 BasePage._find_element_by_ClassName( self, className="android.support.v7.widget.RecyclerView").swipe('up', steps=1) print("swipe test") element = pm._find_element_by_text(self, text="Inbox") print("swipe Inbox") return pm.click_by_element(self, element=element)
def checkDefaultCityWeather(self, cityName): defaultCityName = pm._find_element_by_text(self, text=cityName) if defaultCityName.exists(): print('cityName is exist!') pm.click_by_element(self, element=defaultCityName) locationCityName = pm.find_element_by_id( self, id=india_D90_propertiseConfig.weatherPageConfig.get( 'LocationCityName')).get_text() # 获取城市名称优先比较 print('cityName: ' + cityName) print('LocationCityName: ' + locationCityName) if cityName == locationCityName: # 获取城市名称优先比较,若城市名称错误,无需进行详细信息比较 print('CityName is correct!') return self.compareWeather() else: print('CityName is not correct!') return False else: print('cityName is not exist!') return False
def clickUserManual(self): pm.stopApp(conf.userManualPage.get('packageName')) pm.openApp(conf.userManualPage.get('packageName')) time.sleep(2) for i in range(5): elist = pm.find_element_by_id(self, id=conf.userManualPage.get('menuList')) Manual = pm.find_element_by_text(self, text=conf.userManualPage.get('titleText')) if Manual: return pm.click_by_element(self, Manual) time.sleep(1) pm.swipe_up_by_element(self, elist) return False
def clickEnterAllPage(self): if pm.find_element_by_id( self, id="com.archermind.saic.radio:id/img_radio_amfm_all_selector" ).exists(): print("Already in AllPage") return True else: element = pm.find_element_by_id( self, id="com.archermind.saic.radio:id/tx_radio_amfm_all") print("Click EnterAllPage") pm.click_by_element(self, element=element) if pm.find_element_by_id( self, id="com.archermind.saic.radio:id/img_radio_amfm_all_selector" ).exists(): print("Enter AllPage") return True else: print("Fail to Enter AllPage") return False