def test_view_views(self): # 初始化百度首页,点击新闻链接 baiduhome = HomePage(self.driver) # baiduhome.click_news() self.driver.find_element_by_xpath("//*[@id='s-top-left']/a[1]").click() baiduhome.get_windows_img() windows = self.driver.window_handles self.driver.switch_to_window(windows[-1]) time.sleep(2) # 初始化一个百度新闻主页对象,点击国内 newhome = NewsHomePage(self.driver) self.driver.find_element_by_xpath( "//*[@id='channel-all']/div/ul/li[2]/a").click() newhome.get_windows_img() time.sleep(2) # 初始化一个国内新闻主页,点击轮播图 localhome = LocalNewsHomePage(self.driver) self.driver.find_element_by_xpath( "// *[ @ id = 'imgplayer-next']").click() localhome.get_windows_img() time.sleep(2)
def test_view_nba_views(self): homepage = HomePage(self.driver) homepage.click_news() newspage = NewsHomePage(self.driver) newspage.click_sports() sportnewhome = SportNewsHomePage(self.driver) sportnewhome.click_nba_link() sportnewhome.get_windows_img()
def testViewNbaNews(self): baiduhome = HomePage(self.driver) baiduhome.click_news() newshome = NewsHomePage(self.driver) newshome.click_sport() sportnewhome = SportNewsHomePage(self.driver) sportnewhome.click_nba_link()
def test_nba_news(self): #运行失败,这是一个BUG baiduhome = HomePage(self.driver) baiduhome.click_news() newshome = NewsHomePage(self.driver) newshome.click_sports() sporthome = SportsNewsPage(self.driver) sporthome.click_nba_link()
def test_view_nba_views(self): # 初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) baiduhome.a_click_news() # 初始化一个百度新闻主页对象,点击体育 newshome = NewsHomePage(self.driver) newshome.click_sports() # 初始化一个体育新闻主页,点击NBA sportnewhome = SportNewsHomePage(self.driver) sportnewhome.click_nba_link()
def test_car_news(self): #初始化百度页面,并点击新闻链接 baiduhome = HomePage(self.driver) baiduhome.click_news() #初始化新闻主页对象,并点击体育 newshome = NewsHomePage(self.driver) newshome.click_sports() #初始化体育主页对象,并点击汽车 sportnewhome = SprotsHomePage(self.driver) sportnewhome.click_car() sportnewhome.get_windows_img()
def test_view_video(self): # 初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) baiduhome.click_news() # 在百度新闻页,再点击体育链接 newshome = NewsHomePage(self.driver) newshome.click_sports() # 跳转到体育页后,再点击sports video链接 sportsvideo = SportsNewsHomePage(self.driver) sportsvideo.click_video() sportsvideo.take_window_img()
def test_view_nba_views(self): logger.info("test_view_nba_views is starting...") # 初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) # baiduhome.ClickNews() news_link = "//*[@id='u1']/a[1]" self.driver.find_element_by_xpath(news_link).click() # 初始化一个百度新闻主页对象,点击体育 newshome = NewsHomePage(self.driver) # newshome.ClickSports() sport_link = "//*[@id='channel-all']/div/ul/li[8]/a" self.driver.find_element_by_xpath(sport_link).click() # 初始化一个体育新闻主页,点击NBA sportnewhome = SportNewsHomePage(self.driver) # sportnewhome.ClickNBALink() nba_link = "//*[@id='col_nba']/div[1]/div[2]/ul[1]/li[1]/a" self.driver.find_element_by_xpath(nba_link).click() sportnewhome.GetWindowImg() logger.info("test_view_nba_views is end.") # if __name__ == '__main__': # unittest.main()
def test_view_nba_views(self): #初始化百度首页,并点开新闻链接 baiduhome = HomePage(self.driver) self.driver.find_element_by_xpath("//*[@id='u1']/a[1]").click() #初始化百度新闻主页对象,点击体育 newhome = NewsHomePage(self.driver) self.driver.find_element_by_xpath( "//*[@id='channel-all']/div/ul/li[9]/a").click() #初始化一个体育新闻主页,点击NBA sportnewhome = SportNewsHomePage(self.driver) self.driver.find_element_by_xpath( "//*[@id='channel-submenu']/div/span[2]/a[1]").click() sportnewhome.get_window_img()
def test_view_nba_views(self): # 初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) # baiduhome.click_news() self.driver.find_element_by_xpath("//*[@id='u1']/a[@name='tj_trnews']").click() # 初始化一个百度新闻主页对象,点击体育 newshome = NewsHomePage(self.driver) # newshome.click_sports() self.driver.find_element_by_xpath("//*[@id='channel-all']/div/ul/li[7]/a").click() # 初始化一个体育新闻主页,点击NBA sportnewhome = SportNewsHomePage(self.driver) # sportnewhome.click_nba_link() self.driver.find_element_by_xpath("//*[@id='col_focus']/div[1]/div[2]/div/div[2]/div/ul/li[1]/a").click() time.sleep(5) sportnewhome.get_windows_img()
def test_view_nba_views(self): # 初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) # baiduhome.click_news() self.driver.find_element_by_xpath( "//*[@id='u1']/a[@name='tj_trnews']").click() # 初始化一个百度新闻主页对象,点击体育 newshome = NewsHomePage(self.driver) # newshome.click_sports() self.driver.find_element_by_xpath( "/html[1]/body[1]/div[2]/div[2]/div[2]/div[1]/ul[1]/li[7]/a[1]" ).click() # 初始化一个体育新闻主页,点击NBA sportnewhome = SportNewsHomePage(self.driver) # sportnewhome.click_nba_link() self.driver.find_element_by_xpath( "//span[@class='subtitle'][contains(text(),'NBA')]").click() sportnewhome.get_windows_img()
def test_view_nab_views(self): baiduhome = HomePage(self.driver) #baiduhome.click_news() #初始化百度新闻对象,点击体育 self.driver.find_element_by_xpath("//*[@id='u1']/a[1]").click() newshome = NewsHomePage(self.driver) #newshome.click_sports() self.driver.find_element_by_xpath( "//*[@id='channel-all']/div/ul/li[7]/a").click() time.sleep(2) #初始化一个体育新闻主页,点击NBA sportnewhome = SportNewHomepage(self.driver) #sportnewhome.click_nba_lick() self.driver.find_element_by_xpath( "//*[@id='col_focus']/div[1]/div[2]/div/div[2]/div/ul/li[1]/a" ).click() time.sleep(2) sportnewhome.get_windows_img()
def test_view_nba_news(self): #初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) #baiduhome.click_news() self.driver.find_element_by_link_text("新闻").click() time.sleep(2) #初始化一个百度新闻主页对象,点击体育 newshome = NewsHomePage(self.driver) #newshome.click_sports() self.driver.find_element_by_link_text("体育").click() time.sleep(2) #初始化一个体育新闻主页,点击NBA sportnewhome = SportsNewsHomePage(self.driver) #sportnewhome.click_nba_link() self.driver.find_element_by_link_text("体育视频").click() time.sleep(2) sportnewhome.take_screenshot()
def test_view_nba_views(self): #初始化百度页面,并点击新闻链接 baiduhome = HomePage(self.driver) #baiduhome.click_news() self.driver.find_element_by_xpath( "//*[@id='u1']/a[@name='tj_trnews']").click() #初始化一个百度页面主页对象,点击体育 newshome = NewsHomePage(self.driver) #newshome.click_sports() self.driver.find_element_by_xpath( "//*[@id='channel-all']/div/ul/li[5]/a").click() #初始化一个新闻主页,点击NBA sportnewhome = SportNewsHomePage(self.driver) #sportnewhome.click_nba_link() #报错找不到元素 self.driver.find_element_by_xpath( "//*[@id='channel-submenu']/div/span[2]/a[1]").click() sportnewhome.get_windows_img()
def test_view_nba_views(self): # 初始化百度首页,并点击新闻链接 baiduhome = HomePage(self.driver) # baiduhome.click_news() self.driver.find_element_by_xpath( "//*[@id='u1']/a[@name='tj_trnews']").click() # 初始化一个百度新闻主页,点击体育 newshome = NewsHomePage(self.driver) # newshome.click_sports() self.driver.find_element_by_xpath( "//*[@id='channel-all']/div/ul/li[7]/a").click() # 初始化一个体育新闻主页,点击NBA sportsnewhome = SportNewsHomePage(self.driver) # sportsnewhome.click_nba_link() self.driver.find_element_by_xpath("//*[@class='hd']//h3//a").click() time.sleep(3) windows = self.driver.window_handles new_windows = VideoPage(self.driver) self.driver.switch_to.window(windows[-1]) new_windows.sleep_video() new_windows.get_windows_img()
def test_baidu_news(self): newspage = NewsHomePage(self.driver) newspage.click_sports() time.sleep(2) newspage.get_windows_imgs() # 调用基类截图方法 print('Test Pass.')