1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
# -*- coding: UTF-8 -*-
import configparser
import copy
import os
import time
import uuid
import pytest
from common.read_data.read_data import ReadData
from common.ui_common.objects.urls import URLs
from common.ui_common.objects.objects_public_operations import ObjectsPublicOperations, download_files
from common.ui_common.profiles.profiles_public_operations import ProfilesPublicOperations
from config.workpath import workdir
data = ReadData()
class TestURLs:
# @pytest.mark.parametrize("data", data.read_data_object(r"URLs\\urls.json"), ids=data.generate_id)
@pytest.mark.parametrize("data", data.read_data_object(r"URLs\\urls.json"), ids=data.generate_id)
def test_urls(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls.urls_case(data)
@pytest.mark.parametrize("data", data.read_data_object(r"URLs\\nested_urlgroup.json"), ids=data.generate_id)
# test case 008
def test_nested_urlgroup(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls.create_5layer_nested_urlGroup(data)
search_value = data["Name"][0][:int((len(data["Name"][0])) / 3)]
# print("search_value:{}".format(search_value))
# 清理测试数据
# urls._old_query(data, search_value=search_value)
urls.delete(data, search_value=search_value, del_flag=1)
@pytest.mark.parametrize("data", data.read_data_object(r"URLs\\del_quoted_objects.json"), ids=data.generate_id)
# "data", [
# {
# "ids": "创建urlObjectGroup并试图删除被引用的对象010&011",
# "model": "create",
# "type": 1,
# "Name": "",
# "Items": [],
# "Description": "",
# "Subordinate Objects": [
# "[random]->"
# ]
# }
# ])
# test case 010&011
def test_del_quoted_objects(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls.del_quoted_objects(data)
# 清理测试数据
urls.driver.refresh() # 刷新页面
# urls._query(data) # 刷新后查询
urls.delete(data) # 删除数据
# test case 012
def test_operate_columns(self, demo_fixture):
urls = URLs(demo_fixture)
urls.operate_columns()
@pytest.mark.parametrize("data", data.read_data_object(r"URLs\\pages_turning.json"), ids=data.generate_id)
def test_pages_turning(self, demo_fixture, data):
urls = URLs(demo_fixture)
# profile_pub = ProfilesPublicOperations(demo_fixture)
# profile_pub.change_vsys(vsys_name='PerformanceTestVsys')
urls.goto_subObjectsPage()
urls.objects_po.pages_turning(data)
@pytest.mark.parametrize("data",
[
{
"ids": "创建urlObject并导出验证013",
"Search type": "",
"Model": "create",
"Type": 0,
"Name": "",
"Items": [
"[random]->"
],
"Description": "",
"Subordinate Objects": [
]
},
])
def test_export_objects_and_verify(self, data):
driver = download_files()
urls = URLs(driver)
urls.export_objects_and_verify(data)
driver.quit()
# @pytest.mark.parametrize("data",
# [
# {
# "ids": "创建urlObject并查看验证审计日志-T017/创建并修改urlObject查看验证审计日志-T076",
# "Model": "create",
# "Type": 0,
# "Name": "",
# "Search type": "",
# "Items": [
# "[random]->asdbva.cc"
# ],
# "Description": "",
# "Subordinate Objects": [
# ]
# },
# ])
# def test_verify_audit_logs(self, demo_fixture, data):
# urls = URLs(demo_fixture)
# urls.goto_subObjectsPage()
# urls._verify_audit_logs(data)
@pytest.mark.parametrize("data",
[
{
"ids": "创建urlObject并查看验证Total018",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
".example.com$",
"^www.baidu.com$"
],
"Description": "",
"Subordinate Objects": [
]
},
])
def test_verify_items_total(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls.goto_subObjectsPage()
urls._verify_items_total(data)
@pytest.mark.parametrize("data", [
{
"ids": "创建urlObject——Name022-1",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"[random]"
],
"Description": "",
"Subordinate Objects": ""
}, {
"ids": "创建urlObject——Name022-2",
"Model": "create",
"Type": 0,
"Name": "123",
"Search type": "",
"Items": [
"[random]"
],
"Description": "",
"Subordinate Objects": ""
},
{
"ids": "创建accObject——Name-T022-3",
"Model": "create",
"Type": 0,
"Name": "test_url_ObjectDetailPage_nameLenthNumber_posXpath--url_ObjectDetailPage_nameLenthNumber_posXpath-url_ObjectDetailPage_nameLenthNumber_posXpathurl_ObjectDetailPage_nameLenthNumber_posXpath",
"Search type": "",
"Items": [
"[random]"
],
"Description": "",
"Subordinate Objects": ""
},
])
def test_verify_object_name_input(self, demo_fixture, data):
urls = URLs(demo_fixture)
# urls.goto_subObjectsPage()
urls._verify_url_name_input(data)
@pytest.mark.parametrize("data", [{
"ids": "创建urlObject——Name023",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
""
],
"Description": "",
"Subordinate Objects": ""
},
])
def test_verify_item_value_input(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls.goto_subObjectsPage()
urls._verify_item_value_input(data)
@pytest.mark.parametrize("data", [{
"ids": "创建urlObject——Name024",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"urls_item导入错误文件.txt[ImportFromFile]->"
],
"Description": "",
"Subordinate Objects": ""
},
])
def test_verify_item_value_from_file(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls.goto_subObjectsPage()
urls._verify_item_value_from_file(data)
# @pytest.mark.parametrize("data", data.read_data_object(r"URLs\\select_and_export.json"), ids=data.generate_id)
# def test_export_and_verify_checkbox(self, data):
# driver = download_files()
# urls = URLs(driver)
# # urls._create(data)
# urls._export_and_verify_checkbox(data)
# driver.quit()
@pytest.mark.parametrize("data", data.read_data_object(r"URLs\\switch_page_after_selected.json"),
ids=data.generate_id)
def test_switch_page_after_selected(self, demo_fixture, data):
urls = URLs(demo_fixture)
# profile_pub = ProfilesPublicOperations(demo_fixture)
# profile_pub.change_vsys(vsys_name='PerformanceTestVsys')
urls._switch_page_after_selected(data)
@pytest.mark.parametrize("data", [
{
"ids": "Item在编辑状态下,上传文件按钮置灰-T056",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"abcd"
],
"Description": "",
"Subordinate Objects": [
"*abcd->"
]
},
]
)
def test_importFromFile_whenItemEditing(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._importFromFile_whenItemEditing(data)
@pytest.mark.parametrize("data", [
{
"ids": "未删除上传的文件时,无法在Item框中手动添加数据-T057",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"urls_item导入文件.txt[ImportFromFile]"
],
"Description": "",
"Subordinate Objects": [
"*abcd->"
]
}
])
def test_addItem_before_uploadFileDeleted(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._addItem_before_uploadFileDeleted(data)
@pytest.mark.parametrize("data", [
{
"ids": "用户上传、验证、修改成功的文件展示文件名,鼠标悬浮在文件名上可以下载和删除-T058",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"urls_item导入文件.txt[ImportFromFile]"
]
}
])
def test_itemFile_downloadAndDelete(self, data):
driver = download_files()
urls = URLs(driver)
urls._itemFile_downloadAndDelete(data)
driver.quit()
@pytest.mark.parametrize("data", [
{
"ids": "创建或修改时,点击Cancel按钮,代表此数据未创建或修改成功,Audit Logs中无相关操作日志-T059 ",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"urls_item导入文件.txt[ImportFromFile]"
]
}
])
def test_dataNotSaved_afterCancel(self, data):
pass
@pytest.mark.parametrize("data", [
{
"ids": "一个对象至少包含一个子对象,即必须有一个是Include类型-T066 ",
"Model": "create",
"Type": 1,
"Name": "",
"Search type": "",
}
])
def test_onlyExcludeItem(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._onlyExcludeItem(data)
@pytest.mark.parametrize("data", data.read_data_object(r"URLs\\pages_turning.json"), ids=data.generate_id)
def test_turnPagesInSubObjectsDrawer(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._turnPagesInSubObjectsDrawer(data)
# @pytest.mark.repeat(10)
@pytest.mark.parametrize("data", data.read_data_object(r"Accounts\\clear_counter.json"), ids=data.generate_id)
def test_clear_counter(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._clear_counter(data)
# @pytest.mark.parametrize("data", [
# {
# "ids": "创建urlObject再修改-T001",
# "Model": "create",
# "Type": 0,
# "Name": "",
# "Search type": "",
# "Object Statistics": "Elaborate",
# "Items": [
# "[random]->"
# ],
# "Description": "",
# "Subordinate Objects": ""
# },
# {
# "ids": "创建urlGroupObject-T002",
# "Model": "create",
# "Type": 1,
# "Name": "",
# "Search type": "",
# "Items": [
# "^abcd->"
# ],
# "Description": "",
# "Subordinate Objects": [
# "*abcd->"
# ]
# },
# ])
# def test_view_statistics_case(self, demo_fixture, data):
# urls = URLs(demo_fixture)
# urls._view_statistics_case(data)
def pass_test_onlyViewPermission(self, demo_fixture):
urls = URLs(demo_fixture)
urls._onlyViewPermission()
@pytest.mark.parametrize("data", [
{
"ids": "test_ui_itemDuplicateCheck--Create时校验",
"Model": "create",
"Type": 0,
"Name": "test_ui_itemDuplicateCheck",
"Search type": "",
"Items": [
"itemDuplicateCheck->"
],
"Description": "",
"Subordinate Objects": ""
},
{
"ids": "test_ui_itemDuplicateCheck--仅在本Object中重复",
"Model": "create",
"Type": 0,
"Name": "test_ui_itemDuplicateCheck",
"Search type": "",
"Items": [
"[random]->",
"[random]->"
],
"Description": "",
"Subordinate Objects": "",
"repetition_type": "1"
},
{
"ids": "test_ui_itemDuplicateCheck--Edit时校验",
"Model": "modify",
"Type": 0,
"Name": "test_ui_itemDuplicateCheck",
"Search type": "",
"Items": [
"itemDuplicateCheck->",
"->itemDuplicateCheck"
],
"Description": "",
"Subordinate Objects": ""
}
])
def test_item_duplicate_check(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._item_duplicate_check(data)
@pytest.mark.parametrize("data",
[{
"ids": "组合查询",
"Model": "create",
"Type": 0,
"Name": "",
"Search type": "Name&UUID",
"Items": [
"abcd->"
],
"Description": "",
"Subordinate Objects": ""
}])
def test_multiple_search(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._multiple_search(data)
# @pytest.mark.repeat(10)
def test_edit_built_in_objects(self, demo_fixture):
pytest.skip("目前内置数据配置为不可见,暂时略过") # todo
urls = URLs(demo_fixture)
urls._edit_built_in_objects()
# @pytest.mark.parametrize("data", [
# {
# "ids": "test_list_page_item_search--Object",
# "Model": "create",
# "Type": 0,
# "Search type": "Name",
# "Name": "",
# "Items": [
# "[random]->",
# "^askjdjkj"
# ],
# "Description": ""
# },
# {
# "ids": "test_list_page_item_search--Object Group",
# "Model": "create",
# "Type": 1,
# "Name": "",
# "Search type": "Name",
# "Items": [
# "^abcd->"
# ],
# "Description": "",
# "Subordinate Objects": [
# "^abcd->"
# ]
# }
# ])
# def test_list_page_item_search(self, demo_fixture, data):
# urls = URLs(demo_fixture)
# urls._list_page_item_search(data)
# @pytest.mark.parametrize("data", [
# {
# "ids": "test_sub_objects_drawer_search",
# "Model": "create",
# "Type": 1,
# "Name": "",
# "Search type": "Name",
# "Items": [
# "*abcd->"
# ],
# "Description": "",
# "Subordinate Objects": [
# "*abcd->"
# ]
# }
# ])
# def test_sub_objects_drawer_search(self, demo_fixture, data):
# urls = URLs(demo_fixture)
# urls._sub_objects_drawer_search(data)
@pytest.mark.parametrize("data", [
{
"ids": "test_list_page_item_search--Object",
"Model": "create",
"Type": 0,
"Search type": "Name",
"Name": "",
"Items": [
"[random]->",
],
"Description": ""
}
])
def test_different_vsys_check(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._different_vsys_check(data)
@pytest.mark.parametrize("data", [
{
"ids": "修改时导入Items from file-T019",
"Model": "modify",
"Type": 0,
"Name": "",
"Search type": "",
"Items": [
"[random]->urls_item导入文件.txt[ImportFromFile]"
],
"Description": "",
"Subordinate Objects": [
]
}
])
def test_audit_log_all_operation(self, demo_fixture, data):
urls = URLs(demo_fixture)
urls._audit_log_all_operation(data)
if __name__ == '__main__':
a = time.time()
print(111111111111)
pytest.main(['-sv', 'test_urls.py::TestURLs::test_clear_counter', '--check-max-tb=60000'])
b = time.time()
c = b - a
print("用时:::", c)
print(3333333333333)
"""
# 在测试文件的当前路径执行如下命令执行测试用例:
pytest –cache-clear -v pytest_json.py --alluredir ./allure
# 执行如下命令生成测试报告(自动打开浏览器):
allure serve allure
"""
|