class TestLanqiaoSystem(unittest.TestCase):
@classmethod
def setUpClass(cls):
gecko_path="C:\LanQiaoTest\project\PythonLanqiaoTest\driver\geckodriver.exe"
service=Service(gecko_path)
options=webdriver.FirefoxOptions()
options.set_preference('security.fileuri.strict_origin_policy', False)
options.set_preference('security.fileuri.origin_policy', '*')
cls.driver=webdriver.Firefox(service=service,options=options)
cls.driver.implicitly_wait(5)
cls.driver.maximize_window()
cls.driver.get("https://66546ef7debba6d0473e7e85.hz-iframe-svc.simplelab.cn/login")

@classmethod
def tearDownClass(cls):
cls.driver.quit()

def test_login_user(self):
login_page=LoginPage(self.driver)
login_page.input_username("admin")
login_page.input_password("admin123")
login_page.input_code("666")
login_page.click_auto_login()
login_page.click_login()
duanyan1=login_page.get_username_text()
self.assertEqual(duanyan1,"蓝桥超管")
sleep(2)

def test_person_center(self):
manage_page=UserManagePage(self.driver)
manage_page.click_person_center()
self.driver.switch_to.frame(1)
manage_page.click_modify_photo()
self.driver.switch_to.default_content()
self.driver.switch_to.frame(2)
manage_page.click_upload_photo("D:\photopc\2.jpg")
self.driver.switch_to.default_content()
manage_page.click_upload_okk()
sleep(4)

def test_add_user(self):
manage_page=UserManagePage(self.driver)
add_page=AddPage(self.driver)
manage_page.click_system_menu()
manage_page.click_user_menu()
self.driver.switch_to.frame("iframe2")
add_page.click_add_button()
self.driver.switch_to.default_content()
self.driver.switch_to.frame(2)
add_page.input_username("测试程序员")
add_page.input_telephone("13788888888")
add_page.input_email("123456@qq.com")
add_page.input_logincount("test")
add_page.input_loginpwd("admin123")
add_page.click_user_sex()
add_page.click_user_state()
add_page.click_job()
add_page.click_add_okk()
self.driver.switch_to.default_content()
self.driver.switch_to.frame("iframe2")
sleep(2)
duanyan2=manage_page.get_page_num()
self.assertEqual(duanyan2,"显示第 1 到第 3 条记录,总共 3 条记录")
sleep(2)

def test_manage_user(self):
manage_page=UserManagePage(self.driver)
manage_page.input_search_name("test")
manage_page.click_user_state("停用")
manage_page.click_starttime()
manage_page.click_endtime()
manage_page.click_search()
sleep(2)
duanyan3=manage_page.get_page_num()
self.assertEqual(duanyan3,"显示第 1 到第 1 条记录,总共 1 条记录")
manage_page.click_reset()
manage_page.click_ceshibumen()
sleep(1)
duanyan4=manage_page.get_kong_text()
self.assertEqual(duanyan4,"没有找到匹配的记录")
manage_page.click_reset()
manage_page.click_box()
manage_page.click_delete_button()
manage_page.click_delete_okk()
self.driver.switch_to.default_content()
sleep(2)
duanyan5=manage_page.get_page_num()
self.assertEqual(duanyan5,'显示第 1 到第 2 条记录,总共 2 条记录 ')
sleep(2)

if name=='main':
suit=unittest.TestSuite()
suit.addTest(TestLanqiaoSystem('test_login_user'))
suit.addTest(TestLanqiaoSystem('test_person_center'))
suit.addTest(TestLanqiaoSystem('test_add_user'))
suit.addTest(TestLanqiaoSystem('test_manage_user'))
runner=unittest.TextTestRunner()
runner.run(suit)


↙↙↙阅读原文可查看相关链接,并与作者交流