09-登录校验未使用数据驱动

  • 初始化__str__.py
 1 from lib.webui import *
 2 
 3 
 4 def suite_setup():
 5     open_browser()
 6 
 7 
 8 def suite_teardown():
 9     wd = GSTORE['wd']
10     wd.quit()
  • 管理员登录.py
 1 from time import sleep
 2 from lib.webui import *
 3 
 4 
 5 class UI_0001:
 6     name = '管理员登录 UI_0001'
 7 
 8     def teststeps(self):
 9         wd = GSTORE['wd']
10 
11         wd.get('http://127.0.0.1/mgr/sign.html')
12 
13         # wd.find_element(By.ID, 'username').send_keys('byhy')
14         wd.find_element(By.ID, 'password').send_keys('88888888')
15 
16         wd.find_element(By.TAG_NAME, 'button').click()
17         # 提示不会立刻弹出来
18         sleep(1)
19         notify = wd.switch_to.alert.text
20         CHECK_POINT('不输入管理员账号、输入密码88888888弹出提示', notify == '请输入用户名')
21         wd.switch_to.alert.accept()
22 
23     def teardown(self):
24         wd = GSTORE['wd']
25         # wd.find_element(By.ID, 'username').clear()
26         wd.find_element(By.ID, 'password').clear()
27 
28 class UI_0002:
29     name = '管理员登录 UI_0001'
30 
31     def teststeps(self):
32         wd = GSTORE['wd']
33 
34         wd.get('http://127.0.0.1/mgr/sign.html')
35 
36         wd.find_element(By.ID, 'username').send_keys('byhy')
37         # wd.find_element(By.ID, 'password').send_keys('88888888')
38 
39         wd.find_element(By.TAG_NAME, 'button').click()
40         # 提示不会立刻弹出来
41         sleep(1)
42         notify = wd.switch_to.alert.text
43         CHECK_POINT('输入管理员账号byhy、不输入密码弹出提示', notify == '请输入密码')
44         wd.switch_to.alert.accept()
45 
46     def teardown(self):
47         wd = GSTORE['wd']
48         wd.find_element(By.ID, 'username').clear()
49         wd.find_element(By.ID, 'password').clear()

 

posted @ 2025-02-02 10:36  lzp123456  阅读(7)  评论(0)    收藏  举报