10-登录校验使用数据驱动-para为列表

  • __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_000x:
 6     ddt_cases = [
 7         {
 8             'name': '登录_UI_0001',
 9             'para': [None, '88888888', '请输入用户名']
10         },
11         {
12             'name': '登录_UI_0002',
13             'para': ['byhy', None, '请输入密码']
14         },
15         {
16             'name': '登录_UI_0003',
17             'para': ['byh', '88888888', '登录失败 : 用户名或者密码错误']
18         },
19         {
20             'name': '登录_UI_0004',
21             'para': ['byhy', '8888888', '登录失败 : 用户名或者密码错误']
22         },
23         {
24             'name': '登录_UI_0005',
25             'para': ['byhy', '888888888', '登录失败 : 用户名或者密码错误']
26         }
27     ]
28 
29     def teststeps(self):
30         wd = GSTORE['wd']
31 
32         wd.get('http://127.0.0.1/mgr/sign.html')
33 
34         username, password, info = self.para
35         if username is not None:
36             wd.find_element(By.ID, 'username').send_keys(username)
37         if password is not None:
38             wd.find_element(By.ID, 'password').send_keys(password)
39 
40         wd.find_element(By.TAG_NAME, 'button').click()
41         # 提示不会立刻弹出来
42         sleep(1)
43         notify = wd.switch_to.alert.text
44         CHECK_POINT('弹出提示', notify == info)
45         wd.switch_to.alert.accept()
46 
47     def teardown(self):
48         wd = GSTORE['wd']
49         wd.find_element(By.ID, 'username').clear()
50         wd.find_element(By.ID, 'password').clear()

 

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