class Test_Itinerary_Test(unittest.TestCase): '''添加机票行程''' def setUp(self): self.k, self.user = acquire_user('TestData/user.txt') self.driver = SeleniumBase().get_web_driver() def tearDown(self): release_user(self.k) self.driver.quit() @ddt.unpack @ddt.data(*read_txt('TestData/itinerary.txt')) def test_add_itinerary(self, itinerary_name, routes, itinerary_day, remark1): try: username, password = self.user se = SeleniumBase(self.driver) se.get(url_index) login(self.driver, username, password) index = Index_Page(self.driver) index.click_business() Business = BusinessPage(self.driver) Business.click_air_ticket() Flight = Flight_Mana_Page(self.driver) Flight.air_mana() self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) Flight.click_itinerary() Flight.add_itnerary(itinerary_name, routes, itinerary_day, remark1) except Exception: raise ("测试出现异常")
def test_add_itinerary(self, itinerary_name, routes, itinerary_day, remark1): try: username, password = self.user se = SeleniumBase(self.driver) se.get(url_index) login(self.driver, username, password) index = Index_Page(self.driver) index.click_business() Business = BusinessPage(self.driver) Business.click_air_ticket() Flight = Flight_Mana_Page(self.driver) Flight.air_mana() self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) Flight.click_itinerary() Flight.add_itnerary(itinerary_name, routes, itinerary_day, remark1) except Exception: raise ("测试出现异常")
def test_login(self, username, password, assert_type): se = SeleniumBase(self.driver) se.get(url_index) login(self.driver, username, password) se.add_page_screen_shot() if assert_type == '1': logger().info("断言登陆成功") text = Index_Page(self.driver).login_success() self.assertIn("张维序", text, '登陆成功断言') elif assert_type == "2": text = self.driver.find_element_by_id("submit").text self.assertIn("立即登录", text, '登陆失败断言') elif assert_type == "3": text = self.driver.find_element_by_id("submit").text self.assertIn("立即登录", text, '登陆失败断言') elif assert_type == "4": text = self.driver.find_element_by_id("submit").text self.assertIn("立即登录", text, '登陆失败断言') else: logger().info(f"未知断言类型{assert_type}") self.assertTrue(False, "未知断言类型")
class Test_login(unittest.TestCase): def setUp(self): self.driver = SeleniumBase().get_web_driver() def tearDown(self): SeleniumBase(self.driver).quit() @ddt.unpack @ddt.data(*read_txt('TestData/login_user_password.txt')) def test_login(self, username, password, assert_type): se = SeleniumBase(self.driver) se.get(url_index) login(self.driver, username, password) se.add_page_screen_shot() if assert_type == '1': logger().info("断言登陆成功") text = Index_Page(self.driver).login_success() self.assertIn("张维序", text, '登陆成功断言') elif assert_type == "2": text = self.driver.find_element_by_id("submit").text self.assertIn("立即登录", text, '登陆失败断言') elif assert_type == "3": text = self.driver.find_element_by_id("submit").text self.assertIn("立即登录", text, '登陆失败断言') elif assert_type == "4": text = self.driver.find_element_by_id("submit").text self.assertIn("立即登录", text, '登陆失败断言') else: logger().info(f"未知断言类型{assert_type}") self.assertTrue(False, "未知断言类型")
def test_add_trip(self, trip, dinner, hotel, traffic, travel): '''添加线路行程''' try: username, password = self.user se = SeleniumBase(self.driver) se.get(url) login(self.driver, username, password) index = Index_Page(self.driver) index.click_business() Business = BusinessPage(self.driver) Business.click_lines() Journey = Journey_Page(self.driver) Journey.click_journey() se.add_page_screen_shot() self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) Journey.add_journey(trip, dinner, hotel, traffic, travel) se.add_page_screen_shot() except Exception: raise ('添加线路行程异常')
def test_add_line_type(self, name, ename, tag_name): '''添加线路类别''' try: username, password = self.user se = SeleniumBase(self.driver) se.get(url) login(self.driver, username, password) index = Index_Page(self.driver) index.click_business() Business = BusinessPage(self.driver) Business.click_lines() line_type = Lines_Type(self.driver) line_type.click_line_type() self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) line_type.click_add_lines() se.add_page_screen_shot() line_type.add_lines_type_msg(name, ename, tag_name) se.add_page_screen_shot() except Exception: raise ("添加线路类别异常")
def tearDown(self): release_user(self.k) SeleniumBase(self.driver).quit()
def setUp(self): self.k, self.user = acquire_user("TestData/user.txt") self.driver = SeleniumBase().get_web_driver()
def tearDown(self): SeleniumBase(self.driver).quit()
def setUp(self): self.driver = SeleniumBase().get_web_driver()