def test_discuz_send(self): """用户默认板块下发帖""" home_page_send = HomePage(self.driver) # home_page_send.open_url("http://127.0.0.1/forum.php") time.sleep(5) home_page_send.login("username", "username") time.sleep(5) home_page_send.posting("haotest", "好乱好乱好乱好乱好难定位啊啊啊啊啊!!!!") time.sleep(3) home_page_send.reply("真的是好难!!!!!啊!!!啊") time.sleep(3) home_page_send.logout() time.sleep(3)
def test_discuz_login(self): home_page = HomePage(self.driver) home_page.login("admin", "bin19961013") home_page.search_text("haotest") # home_page.find_haotest() t = home_page.find_haotest() self.assertEqual(t, "haotest", msg=t) time.sleep(1) home_page.quit_loginer() time.sleep(5)
def test_discuz_search(self): """断言haotest与期望是否一致""" search_page = HomePage(self.driver) # search_page.open_url("http://127.0.0.1/forum.php") # window_list = self.driver.current_window_handle # self.driver.switch_to.window(window_list) search_page.login("username", "username") time.sleep(2) search_page.search("haotest") time.sleep(3) self.driver.refresh() #验证贴子标题和期望是否一致 try: assert "haotest" in self.driver.title print("Assertion test pass") except Exception as e: print("Assertion test failed") search_page.close() time.sleep(3) self.driver.switch_to_window(self.driver.window_handles[0]) search_page.logout() time.sleep(5)
def test_Discuz_search(self): homePage = HomePage(self.driver) discuzBase = DiscuzBase(self.driver) discuzBase.search("hemei", "hemeihua") indexAssert = self.driver.find_element_by_css_selector(".vwmy a") assert "hemei" in indexAssert.text homePage.fatiesearch("hhhhhh", "mmmmhhhhhhhhhhhhhhmm") indexAssert = self.driver.find_element_by_css_selector( ".vwthd h1 span") assert "hhhhhh" in indexAssert.text homePage.huitiesearch("ii这是个好办法iii") discuzBase.tuichu()
def test_discuz_login(self): home_page = HomePage(self.driver) home_page.login("admin", "bin19961013") t = home_page.find_user() # print(t) # home_page.assert_Equal_login(t,"admin") self.assertEqual(t, "admin", msg=t) home_page.send_new("haotest", "这是一个测试帖") time.sleep(5) home_page.reply_new("回复测试帖") home_page.quit_loginer() self.assertTrue(home_page.home_page_button_login_loc)
def test_discuz_vote(self): """发起投票并获得结果""" vote_page = HomePage(self.driver) # vote_page.open_url("http://127.0.0.1/forum.php") vote_page.login("username", "username") time.sleep(3) vote_page.send_vote("周末除了学习能干嘛", "学习", "睡觉", "出去玩") time.sleep(5) vote_page.send_vote_submit() time.sleep(5) vote_page.get_vote() time.sleep(5) vote_page.logout() time.sleep(3)
def test_admin_user(self): """用户新版块下发帖""" center_page = HomePage(self.driver) #管理员登录 center_page.login("admin", "admin") #进入默认板块 删除帖子 center_page.delete_msg() time.sleep(3) #创建新版块 center_page.add_new_section("admin", "discuz实战3") time.sleep(3) center_page.close() #管理员退出 time.sleep(5) self.driver.switch_to.window(self.driver.window_handles[0]) center_page.logout() time.sleep(5) #普通用户登录 self.driver.refresh() center_page.login("username", "username") #在新模块发帖 进入新版块 time.sleep(5) center_page.newposting("退不出去", "我怎么进啊啊啊啊啊啊啊!!!") time.sleep(5) center_page.reply("我要睡觉!!!!") center_page.logout() time.sleep(5)
def test_discuz_login(self): home_page = HomePage(self.driver) home_page.login("admin", "bin19961013") t = home_page.find_user() self.assertEqual(t, "admin", msg=t) home_page.new_toupiao("测试投票", "选项1", "选项2", "选项3") home_page.toupiao() home_page.persent()
def test_discuz_login(self): home_page=HomePage(self.driver) home_page.login("admin", "bin19961013") t = home_page.find_user() self.assertEqual(t, "admin", msg=t) home_page.delete_new() home_page.glmk_add(3,"版块_3") home_page.quit_managerlogin() home_page.login("bin1192029250", "bin19961013") t1 = home_page.find_user() self.assertEqual(t1, "bin1192029250", msg=t1) home_page.newbk_send("普通用户发帖","普通用户的发帖内容") time.sleep(15) home_page.newbk_reply("普通用户回帖")