def test_knowledge(self): """ 验证Knowledge是否能正常跳转; 1、打开News; 2、点击Knowledge; 3、断言跳转的url是否包含{/news/5/} """ try: driver = NewsElement(self.driver) driver.get(self.url) driver.news_table_click(location=4) driver.full_windows_screen(self.screenshots_path, 1920, 980) self.first = driver.is_url_contain( url=self.data[0]) # 此项为必填,第一个断言值 self.assertEqual(self.first, self.second) except Exception: self.error = str(traceback.format_exc())
def test_company_news_info(self): """ 验证CompanyNews图片新闻是否能进入详情并跳转; 1、打开CompanyNews; 2、点击第{1}张新闻图片; 3、断言跳转的url是否包含{/news/48.html} """ try: driver = NewsElement(self.driver) driver.get(self.url) driver.company_img_info(location=self.data[0]) driver.full_windows_screen(self.screenshots_path, 1920, 980) self.first = driver.is_url_contain( url=self.data[1]) # 此项为必填,第一个断言值 self.assertEqual(self.first, self.second) except Exception: self.error = str(traceback.format_exc())
def test_technology(self): """ 验证Technology是否正常跳转; 1、打开CompanyNews; 2、点击Technology; 3、断言跳转的url是否包含{/news/10/} """ try: driver = NewsElement(self.driver) driver.get(self.url) driver.news_table_click(location=3) driver.full_windows_screen(self.screenshots_path, 1920, 980) self.first = driver.is_url_contain( url=self.data[0]) # 此项为必填,第一个断言值 self.assertEqual(self.first, self.second) except Exception: self.error = str(traceback.format_exc())
def test_news_center_next_page(self): """ 验证NewsCenter点击下一页是否正常跳转; 1、打开News; 2、点击NewsCenter; 3、点击下一页; 4、断言跳转的url是否包含{/nav/10.html#c_news_list-15487307331178472} """ try: driver = NewsElement(self.driver) driver.get(self.url) driver.next_page_click() driver.full_windows_screen(self.screenshots_path, 1920, 980) self.first = driver.is_url_contain( url=self.data[0]) # 此项为必填,第一个断言值 self.assertEqual(self.first, self.second) except Exception: self.error = str(traceback.format_exc())
def test_news_center(self): """ 验证NewsCenter是否能正常跳转; 1、打开News; 2、点击NewsCenter中的第{1}条数据; 3、断言跳转的url是否包含{/news/} """ try: driver = NewsElement(self.driver) driver.get(self.url) driver.news_info_click(location=self.data[0]) driver.switch_windows(name=-1) driver.full_windows_screen(self.screenshots_path, 1920, 980) self.first = driver.is_url_contain( url=self.data[1]) # 此项为必填,第一个断言值 self.assertEqual(self.first, self.second) except Exception: self.error = str(traceback.format_exc())