def permission_allow(self): time.sleep(1) permission_id = "com.android.packageinstaller:id/permission_allow_button" if common.isElementExist("id", self.driver, "android:id/button1"): permission_id = "android:id/button1" while common.isElementExist("id", self.driver, permission_id): #更多精彩视频 self.driver.find_element_by_id(permission_id).click() time.sleep(1)
def login(self, xpath): common.delayed_get_element(self.driver, 5, ("xpath", xpath)).click() common.delayed_get_element(self.driver, 3, ("id", "dopool.player:id/phoneEdit")).send_keys(telephone) timeStamp = int(time.mktime(datetime.now().timetuple())) self.driver.find_element_by_id("dopool.player:id/smsCodeEdit").send_keys(self.encrypt_md5(timeStamp)) while common.isElementExist("id", self.driver, "dopool.player:id/loginBtn"): self.driver.find_element_by_id("dopool.player:id/loginBtn").click()
def click_play_float_button(self, float_button_id, float_button_bounds): if not common.isElementExist("id", self.driver, f"dopool.player:id/{float_button_id}"): common.click_screen_point(self.driver, 1 / 2, 1 / 8, 20) time.sleep(1) self.driver.tap(float_button_bounds, 20) # 点击全屏上的清晰度按钮 else: self.driver.find_element_by_id(float_button_id).click()
def test_02_full_screen(self): """播放视频,全屏""" homepage(self.driver).play_video(video_title, True) self.assertFalse( common.isElementExist("id", self.driver, "dopool.player:id/recommendTitle"), "点击全屏播放,猜你喜欢不应出现")
def test_12_watch_history(self): """直播的观看历史""" homepage(self.driver).clear_watch_history("直播") live_title = "CCTV1" homepage(self.driver).stream_CCTV1(live_title) common.delayed_get_element(self.driver, 3, ("id", "dopool.player:id/backImage")).click() common.delayed_get_element(self.driver, 3, ("id", "dopool.player:id/common_page_finish")).click() base(self.driver).bottom_navigation("我的") self.assertTrue(common.isElementExist("xpath", self.driver, f"//*[@text='{live_title}']"), f"观看历史中应显示{live_title}")
def close_float(self): """ 如果有浮层关闭按钮的话,点击关闭,就关掉浮层了 如果没有,就要点击浮层,进入直播、点播或H5页面, 直播和点播的退出:点系统返回,弹出退出窗再点退出按钮 H5的退出:点系统返回即可 """ time.sleep(3) if common.isElementExist("id", self.driver, self.close_float_id): self.driver.find_element_by_xpath(self.close_float_id).click() elif common.isElementExist("id", self.driver, self.float_id): self.driver.find_element_by_xpath(self.float_id).click() self.driver.keyevent(4)# 点击系统返回键 if common.isElementExist("id", self.driver, "dopool.player:id/img_history"): return else: ele_quit = common.delayed_get_element(self.driver, 5, ("id", "dopool.player:id/btn_left")) ele_quit.click() # 退出直播或点播
def test_06_lock_screen(self): """锁屏""" homepage(self.driver).play_video(video_title, True) base(self.driver).click_play_float_button("iv_screen_lock", [(177, 468)]) base(self.driver).click_play_float_button("third_tv", [(2153, 1008)]) self.assertFalse( common.isElementExist("id", self.driver, "dopool.player:id/tv_definition"), "锁屏以后无法点击清晰度按钮")
def bottom_navigation(self, button_name): xpath_mine = "//android.widget.LinearLayout[@resource-id='dopool.player:id/bottomNavigationView']/android." \ "widget.FrameLayout[5]/android.widget.FrameLayout[1]/android.widget.ImageView[1]" # button_index = {} if common.isElementExist("xpath", self.driver, xpath_mine): button_index = {"首页": 1,"直播": 2,"热点": 3,"会员": 4,"我的": 5} else: button_index = {"首页": 1, "直播": 2, "会员": 3, "我的": 4} xpath = f"//android.widget.LinearLayout[@resource-id='dopool.player:id/bottomNavigationView']/android.widget." \ f"FrameLayout[{button_index[button_name]}]/android.widget.FrameLayout[1]/android.widget.ImageView[1]" common.delayed_get_element(self.driver, 10, ("xpath", xpath)).click()
def test_09_watch_history(self): """点播的观看历史""" homepage(self.driver).clear_watch_history("点播") homepage(self.driver).play_video(video_title) common.delayed_get_element( self.driver, 3, ("id", "dopool.player:id/backImage")).click() common.delayed_get_element( self.driver, 3, ("id", "dopool.player:id/cancel_text")).click() base(self.driver).bottom_navigation("我的") self.assertTrue( common.isElementExist("xpath", self.driver, f"//*[@text='{video_title}']"), f"观看历史中应显示{video_title}")
def test_10_exit_play(self): """退出播放""" base(self.driver).sign_out() homepage(self.driver).play_video(video_title) common.delayed_get_element( self.driver, 17, ("id", "dopool.player:id/backImage")).click() common.delayed_get_element( self.driver, 3, ("id", "dopool.player:id/btn_left")).click() time.sleep(1) self.assertTrue( common.isElementExist("xpath", self.driver, "//*[@text='点播']"), "退出点播后应显示搜索页面") # if __name__ == "__main__": # Video().test_04_switching_clarity()
def test_06_reservation(self): """预约""" homepage(self.driver).stream_CCTV1() reservation_xpath = "//android.support.v7.widget.RecyclerView[@resource-id='dopool.player:id/epgListRV']/" \ "android.view.ViewGroup[6]/android.widget.TextView[3]" common.delayed_get_element(self.driver, 5, ("xpath", reservation_xpath)).click() time.sleep(3) self.assertTrue(common.isElementExist("xpath", self.driver, "//*[@text='已预约']"), "点击预约后按钮应变成已预约") item_xpath = "//*[@resource-id='dopool.player:id/epgListRV']/android.view.ViewGroup[6]/android.widget.TextView[2]" item_name = self.driver.find_element_by_xpath(item_xpath).text base(self.driver).click_play_float_button("backImage", [(79, 150)]) common.delayed_get_element(self.driver, 3, ("id", "dopool.player:id/common_page_finish")).click() base(self.driver).bottom_navigation("我的") common.delayed_get_element(self.driver, 5, ("xpath", "//*[@text='我的预约']")).click() reservation_item = common.delayed_get_element(self.driver, 5, ("id", "dopool.player:id/tv_epg_name")).text self.assertEqual(item_name, reservation_item, "我的预约中显示已预约的节目和在竖屏播放节目单中预约的节目不一致")
def sys_playPermiss(driver): isExist = common.isElementExist(1, driver, 'tv_des') return isExist #音乐类型选择 # def select_type(driver): # driver.find_element_by_xpath("//*[@text='Country']").click() # driver.find_element_by_xpath("//*[@text='Jazz']").click() # # 判断音乐类型数据是否拉取到 # def is_Type(driver): # isExist = common.isElementExist(0, driver, '//*[@text="Country"]') # return isExist #音乐类型保存按钮 # def click_save(driver): # driver.find_element_by_id('customized_btn').click() # #音乐类型界面的下一步按钮 # def click_skip(driver): # driver.find_element_by_id('customized_skip_txt').click()
def is_update(driver): isExist = common.isElementExist(id, driver, "dopool.player:id/tv_update_cancle") return isExist
def close_notice_manage(self): if common.isElementExist("id", self.driver, "dopool.player:id/textView"): self.driver.find_element_by_id("dopool.player:id/tv_score_cancle").click()
def close_upgrade(self): if common.isElementExist("id", self.driver, "dopool.player:id/tv_update_list"): self.driver.find_element_by_id("dopool.player:id/tv_update_cancle").click()
def enter_app(self): time.sleep(3) if common.isElementExist("id", self.driver, "dopool.player:id/iv_checkbox"): common.delayed_get_element(self.driver, 1, ("id", "dopool.player:id/iv_checkbox")).click() if common.isElementExist("id", self.driver, "dopool.player:id/btn_start_experience"): common.delayed_get_element(self.driver, 1, ("id", "dopool.player:id/btn_start_experience")).click()
def slide_guide_page(self): while not common.isElementExist("id", self.driver, "dopool.player:id/btn_start_experience"): common.swipeLeft(self.driver)
def is_empty(driver): isExist = common.isElementExist(1, driver, 'iv_empty') return isExist
def sys_playPermiss(driver): isExist = common.isElementExist(1, driver, 'tv_des') return isExist
def is_login(driver): isExist = common.isElementExist(1, driver, 'splash_first_btn') return isExist
def is_Type(driver): isExist = common.isElementExist(0, driver, '//*[@text="Country"]') return isExist
def close_childmode(self): # 点击知道了,即可关闭青少年模式 if common.isElementExist("id", self.driver, "dopool.player:id/i_k"): self.driver.find_element_by_id("dopool.player:id/i_k").click()
def isLogin(driver): isExist = common.isElementExist(0, driver, '//*[@id="wrapper"]/nav/ul/li[1]/a') return isExist