summaryrefslogtreecommitdiff
path: root/common/ui_common/profiles/insert_scripts.py
blob: 1b67abcfa61745435ef60c2cf9194056d2a87df5 (plain)
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
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
# -*- coding: UTF-8 -*-
import time
from selenium.common.exceptions import NoSuchElementException
from common.driver_common.mywebdriver import MyWebDriver
from selenium.webdriver.common.by import By
from config.workpath import workdir
from page_element.policies_element_position import *
from page_element.profiles_element_position import *
from common.driver_common.screenshot import screenshot_on_failure
from common.driver_common.random_name import RandomName
from common.ui_common.profiles.profiles_public_operations import ProfilesPublicOperations
import pytest_check
import inspect
import configparser
import os
from common.ui_common.login_logout.loginout import LogInOut


from selenium import webdriver
import copy
from selenium.webdriver.common.keys import Keys

class InsertScripts:
    def __init__(self, demo_fixture: MyWebDriver):
        self.workdir = workdir
        self.my_random = RandomName()
        self.driver = demo_fixture
        # 调用profiles公共方法操作、删除、查询,
        self.profiles_po = ProfilesPublicOperations(self.driver)
        try:
            if self.driver.element_isExist(By.XPATH, '//*[@class="iconfont icon-Delete_X"]'):
                element = self.driver.find_element(By.XPATH, '//*[@class="iconfont icon-Delete_X"]')
                element.click()
        except NoSuchElementException:
            pass

    def insertScripts_case(self, data: {}):
        self._create(data)      #创建
        time.sleep(3)
        self._query(data, require_assertion=1, Name=self.random_name)     #创建后查询
        if data["model"].strip().lower() == "modify":   #修改测试时,执行修改方法
            self._modify(data)
            time.sleep(2)
            self._query(data, require_assertion=2, ID=self.first_row_ID_content)
        self._del()

    @screenshot_on_failure
    def _goto_subProfilePage(self, vsys_name_2=""):
        # 菜单操作,定位到ssl_decryption_keyrings列表页
        # self.driver.find_element(By.CSS_SELECTOR, mainPage_navigationBar_logo_posCss).click()
        self.profiles_po.change_vsys(vsys_name=vsys_name_2)
        self.driver.find_element(By.ID, mainPage_firstLevelMenu_profiles_posId).click()
        element = self.driver.find_element(By.ID, mainPage_secondLevelMenu_insertScripts_posId)
        self.driver.execute_script("arguments[0].click()", element)  # 强制点击
        
    def _goto_vsysPage(self, vsys_name_2=""):
        # 菜单操作,定位到不同的vsys
        self.profiles_po.change_vsys(vsys_name=vsys_name_2)

    @screenshot_on_failure
    def _create(self, data: {}, *source_name):
        #页面跳转
        self._goto_subProfilePage()
        #创建
        #点击create
        self.driver.find_element(By.ID, listPage_profile_insertScripts_createButton_posId).click()
        #在打开页面操作:输入name
        # Name
        if source_name:
            self.random_name = source_name[0]
            self.driver.find_element(By.ID, insertScripts_input_Name_posId).send_keys(self.random_name)
        else:
            self.random_name = self.my_random.random_name()
            self.driver.find_element(By.ID, insertScripts_input_Name_posId).send_keys(self.random_name)
        self.driver.find_element(By.XPATH, "//label[text()='Name']").click()
        #页面其它选项操作
        result_code = self._operate_page(data, operation_type="create")
        if result_code == 999:
            return 999
        #点击OK
        self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_oK_posCss).click()
        if len(self.random_name) < 4:  # name不符合要求
            if self.driver.element_isExist(By.XPATH,
                                           "//label[text()='Name']/parent::div//div[@class='el-form-item__error']"):
                print("The length of the name is at most 128 characters and cannot be less than 4 characters")
                pytest_check.equal(
                    self.driver.find_element(By.XPATH, "//div[@class='el-form-item__error']").text.strip(),
                    "The length of the name is at most 128 characters and cannot be less than 4 characters",
                    msg="所在行数{}".format(inspect.currentframe().f_lineno))
            else:
                print("name less than 4,no error message")
            # 点击取消
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
            if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
                self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()
        elif data["script"].split("->")[0].strip() == "":  # 未上传文件
            error_content = self.driver.find_element(By.XPATH, "//p[@class='el-message__content']").text.strip()
            pytest_check.equal(error_content, "Please choose to upload files",
                                   msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 点击取消
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
            if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
                self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()
        elif data["script_type"].split("->")[0].strip() == "":  # 未选择文件类型
            error_content = self.driver.find_element(By.XPATH, "//div[@class='el-form-item__error']").text.strip()
            pytest_check.equal(error_content, "Please enter the content",
                                   msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 点击取消
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
            if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
                self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()
        elif data["script"].split("->")[0].split(".")[-1] != data["script_type"].split("->")[0]:  # script和script_type不匹配
            error_content = self.driver.find_element(By.XPATH, "//p[@class='el-message__content']").text.strip()
            pytest_check.equal(error_content, "Type and file are not matched.",
                               msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 点击取消
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
            if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
                self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()
        elif data["script"].split("->")[0].strip() == "error_type.txt":  # 未上传文件
            error_content = self.driver.find_element(By.XPATH, "//p[@class='el-message__content']").text.strip()
            pytest_check.equal(error_content, "\"js\" and \"css\" only!",
                                   msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 点击取消
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
            if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
                self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()
        elif self.driver.element_isExist(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss):
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()
        return self.random_name

    def _operate_page(self, data: {}, operation_type="create"):
        """
        除name的其它选项操作,共创建、修改逻辑调用
        :param data:
        :param operation_type: create modify。创建 修改时调用
        :return:
        """
        if operation_type == "create":
            data_index = 0   #新增数据索引
        else:
            data_index = -1   #编辑数据索引
        no_modify = "不修改"
        #script type脚本类型操作 --先操作文件类型

        self._operate_scriptType(data, data_index=data_index)
        #File文件上传操作
        file = self._get_value_from_data(data, key="script", data_index=data_index)   #解析file文件名称
        if file != no_modify:      #判断修改时不修改时跳过操作。
            if file != "":
                file_abspath = self._abs_path(file)
                #上传文件
                self.driver.find_element(By.XPATH, insertScripts_input_scriptUpLoad_posXpath).send_keys(file_abspath)
                # 大于20M上限判断
                if "Exceed20MFile".lower() in file:
                    info_except = "File size upload limit is 20MB"
                    info_actual = self.driver.find_element(By.XPATH, insertScripts_alert_topInfo_Xpath).text.strip()
                    print("超出20M测试用例执行...")
                    pytest_check.equal(info_except, info_actual, msg="所在行数{}".format(inspect.currentframe().f_lineno))
                    return 999


    def _abs_path(self, file_name):
        # 以下是要读取数据的名称
        conf = configparser.ConfigParser()
        loginout_parse_dir = os.path.join(self.workdir, "config", "importfile.ini")
        conf.read(loginout_parse_dir, encoding="utf-8")
        testdata = conf.get("profiles", "testdata")
        ui_file = conf.get("profiles", "ui_file")
        profiles = conf.get("profiles", "profiles")
        insert_scripts = conf.get("profiles", "insert_scripts")
        import_file_abs = os.path.join(self.workdir, testdata, ui_file, profiles, insert_scripts, file_name)
        import_file_abs = os.path.abspath(import_file_abs)
        return import_file_abs

    def _get_value_from_data(self, data: {}, key="", data_index=0):
        """
        从data数据中,根据key提取值
        :param data:
        :param key:
        :param data_index: 0 -1
        :return:
        """
        try:
            switch_value: str = data[key].split("->")[data_index].strip().lower()    #用例数据
        except Exception as e:
            print(e)
        return switch_value

    def _operate_scriptType(self, data: {}, data_index=0, no_modify="不修改"):
        """
        脚本类型操作,。
        :param data:
        :param data_index: 0 -1来自上层
        :param no_modify:"不修改" 来自上次调用
        :param operation_type: create modify两个状态,
        :return:
        """
        #解析输入data数据的数据,脚本类型
        script_type = self._get_value_from_data(data, key="script_type", data_index=data_index)
        if script_type != no_modify:     #编辑不修改时执行
            if script_type != "":
                self.driver.find_element(By.XPATH, insertScripts_input_scriptType_posXpath).click()   #点击输入列表框
                if "js" == script_type:   #js类型点击
                    self.driver.find_element(By.XPATH, insertScripts_dropdown_jsItem_posXpath).click()
                    #insert position操作
                    insert_position = self._get_value_from_data(data, key="insert_position", data_index=data_index)     #获取insert position等操作After Page Load
                    if insert_position != no_modify:
                        self.driver.find_element(By.XPATH, insertScripts_input_insertPosition_posXpath).click()
                        if ("after" in insert_position) and ("page" in insert_position) and ("load" in insert_position):      #点击 after Page Load选项
                            #点击下拉列表选项
                            self.driver.find_element(By.XPATH, insertScripts_dropdown_afterPageLoadItem_posXpath).click()
                        else:                    #点击 before Page Load选项
                            self.driver.find_element(By.XPATH, insertScripts_dropdown_beforePageLoadItem_posXpath).click()
                else:          #css类型点击列表
                    self.driver.find_element(By.XPATH, insertScripts_dropdown_cssItem_posXpath).click()

    @screenshot_on_failure
    def _query(self, data: {}, vsys_name_2="", require_assertion=0, **kwargs):
        """
        查询函数,根据输入的类型查询
        :param require_assertion: =0默认情况不需要断言,=1为创建后使用的断言预期,=2为编辑修改后使用的断言预期
        :param kwargs: 例如 :可以查询使用的关键字,ID=None,Name=None,
        :return:
        """
        #打开该列表
        self._goto_subProfilePage(vsys_name_2=vsys_name_2)
        #first_row查询到的第一行内容。map_header_className为需要使用的到字典,用来提取第一行的结果。
        result = self.profiles_po.query(listPage_profileSearch_insertScripts_selectLabel_posId, listPage_profileSearch_insertScripts_dropDown_item_posXpath,
                                listPage_profileSearch_insertScripts_input_itemContent_posXpath, listPage_profileSearch_insertScripts_buttonSearch_posId,
                                listPage_profilTable_insertScripts_tableTbody_posXpath, listPage_profilTable_insertScripts_tableHeader_posXpath, **kwargs)
        if result == [0, 0]:
            return 0
        else:
            first_row, map_header_className = result
        #第一行的勾选定位,给修改、删除使用
        self.first_row_checkBox_element = first_row.find_element(By.XPATH, "//span[@class='el-checkbox__input']")
        self.first_row_ID_content = first_row.find_element(By.XPATH, "//div[@class='table-status-item-id']/span").text.strip()
        #print(map_header_className)
        # 需要提取ID Name、Type 信息
        first_row_id_content = first_row.find_element(By.XPATH, "//div[@class='table-status-item-id']//span").text.strip()
        #irst_row_VsysID_class = map_header_className["Vsys ID"]
        #first_row_VsysID_content = first_row.find_element(By.XPATH, f"//td[contains(@class, '{first_row_VsysID_class}')]//div").text.strip()
        first_row_Name_class = map_header_className["Name"]
        first_row_Name_content = first_row.find_element(By.XPATH, f"//td[contains(@class, '{first_row_Name_class}')]//span").text.strip()
        first_row_Type_class = map_header_className["Type"]
        first_row_Type_content = first_row.find_element(By.XPATH, f"//td[contains(@class, '{first_row_Type_class}')]//span").text

        # print(first_row_id_content, first_row_Name_content, first_row_Type_content)
        search_dict = {"ID": first_row_id_content, "Name": first_row_Name_content,
                       "Type": first_row_Type_content}
        print("first_row=", search_dict)
        #不同操作后的断言,创建后、修改后、无断言
        if require_assertion == 1:  #直接创建后,使用的断言
            pytest_check.equal(first_row_Name_content, self.random_name, msg="所在行数{}".format(inspect.currentframe().f_lineno))
            #断言文件类型
            script_type = self._get_value_from_data(data, key="script_type", data_index=0)
            pytest_check.equal(first_row_Type_content, script_type, msg="所在行数{}".format(inspect.currentframe().f_lineno))
        elif require_assertion == 2 and data["model"].strip().lower() == "modify":   #修改数据后,使用的断言
            pytest_check.equal(first_row_Name_content, self.random_name, msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 断言文件类型
            script_type = self._get_value_from_data(data, key="script_type", data_index=-1)
            if script_type != "不修改":
                pytest_check.equal(first_row_Type_content, script_type, msg="所在行数{}".format(inspect.currentframe().f_lineno))
        else:  #不适用断言
            pass
        #强制点击清空查询按钮
        element_clear = self.driver.find_element(By.ID, listPage_profileSearch_insertScripts_buttonClear_posId)
        self.driver.execute_script("arguments[0].click()", element_clear)  # 强制点击
        return search_dict

    @screenshot_on_failure
    def _modify(self, data: {}):
        """
        修改数据,使用方法
        :param data:
        :return:
        """
        if data["model"].strip().lower() == "create":    #如果是create参数用例,则不用执行修改方法
            return 0
        #点击勾选第一行选择框
        self.first_row_checkBox_element.click()     #变量来自查询函数
        self.driver.find_element(By.ID, listPage_profile_insertScripts_editButton_posId).click()
        #解析修改数据
        self._operate_page(data, operation_type="edit")
        # 修改name
        new_Name = "(修改后)"
        self.driver.find_element(By.ID, insertScripts_input_Name_posId).send_keys(new_Name)
        self.random_name = self.random_name + new_Name
        #点击ok
        self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_oK_posCss).click()
        if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()

    @screenshot_on_failure
    def _del(self, del_model=0):
        """
        默认删除查询到的第一个结果
        :return:
        """
        #点击勾选第一行选择框
        if del_model == 0:
            #点击勾选第一行选择框
            self.first_row_checkBox_element.click()     #变量来自查询函数
        elif del_model == 1:  # 勾选可以删除的选项,并删除;没有锁、没有被引用的对象
            rows = self.driver.find_element(By.XPATH, listPage_profilTable_dnsRecords_tableTbody_posXpath).find_elements(By.XPATH, "./tr")
            if len(rows) == 0:   # 没有数据,直接返回
                return
            else:
                del_result = self.profiles_po.select_lock_and_referenceCount(rows)
                if del_result == 1:   # 1表示没有删除对象,直接返回
                    return 0
        #调用profiles的功能删除方法
        self.profiles_po.delete(listPage_profile_insertScripts_delButton_posId, listPage_dialogTips_insertScripts_button_yes_posCss,
                                listPage_dialogTips_insertScripts_button_no_posCss)
        
    def _column_setting(self, column: (), column_flags=0):
        """
        列设置函数,
        column_flags: 0---保持当前状态   1---仅显示默认列   2---显示所有列   3---显示自定义列
        :param column_flags:
        :param kwargs:
        :return:
        """
        # 打开该列表
        self._goto_subProfilePage()
        profiles = "Profile_Insert"
        column_click = column[2:]
        current_column = self.profiles_po.column_setting(mainPage_profileColumn_columnSetting_posId,
                                                         listPage_profileColumn_insertScripts_button_columnAll_posXpath,
                                                         listPage_profileColumn_insertScripts_button_cancel_posId,
                                                         listPage_profileColumn_insertScripts_button_ok_posId,
                                                         profiles,
                                                         column_flags, column_click)
        pytest_check.equal(current_column, column, msg="所在行数{}".format(inspect.currentframe().f_lineno))

    def _turn_pages(self, pages):
        """
                翻页
                pages:当前模块页数;如果页数>8,则有快速翻页功能(页面翻至第5页,显示左快速翻页按钮;当前页为左/右第4页时,不显示快速翻页按钮)
                :param profiles:
                :param pages:
                :return:
                """
        self._goto_subProfilePage()
        self.profiles_po.turn_pages("Profile_Insert", pages)

    def _language_change(self, language):
        """
        语言切换函数
        language: 0---english; 1---chinese; 2---russian
        :param language:
        :return:
        """
        self._goto_subProfilePage()
        header_content = self.profiles_po.language_change(mainPage_language_change_posXpath,
                                                          mainPage_language_chinese_posXpath,
                                                          mainPage_language_russian_posXpath,
                                                          mainPage_language_english_posXpath, language)
        # 断言
        time.sleep(2)
        if language == 0:
            header_english = ["ID", "Vsys ID", "Name", "Type", "File", "Reference Count", "Modified Time", "Last Modified By"]
            assert set(header_content).issubset(set(header_english))
        if language == 1:
            header_chinese = ["ID", "虚拟系统 ID", "名称", "类型", "文件", "引用计数", "操作时间", "最后一次修改者"]
            assert set(header_content).issubset(set(header_chinese))
        if language == 2:
            header_russian = ["ID", "Vsys ID", "Имя", "Тип", "Файл", "Подсчет Ссылок", "Время Изменения", "Последний Раз Редактирован"]
            assert set(header_content).issubset(set(header_russian))

    def _file_download(self, **kwargs):
        """
        文件下载
        :param kwargs:
        :return:
        """
        self._goto_subProfilePage()
        first_row, map_header_className = \
            self.profiles_po.query(listPage_profileSearch_insertScripts_selectLabel_posId,
                                   listPage_profileSearch_insertScripts_dropDown_item_posXpath,
                                   listPage_profileSearch_insertScripts_input_itemContent_posXpath,
                                   listPage_profileSearch_insertScripts_buttonSearch_posId,
                                   listPage_profilTable_insertScripts_tableTbody_posXpath,
                                   listPage_profilTable_insertScripts_tableHeader_posXpath, **kwargs)
        first_row_file_class = map_header_className["File"]
        print("first_row_File_class=", first_row_file_class)
        first_row.find_element(By.XPATH, f"//td[contains(@class, '{first_row_file_class}')]//i").click()
        
    def _vsys_case(self, data, c_vsys, c_type, c_supervisor, f_vsys, f_type, f_supervisor="None"):
        name = self._create(data, f_vsys)
        time.sleep(3)
        self._query(data, f_vsys, require_assertion=1, Name=name)  # 本vsys下查询
        time.sleep(1)
        result = self._query(data, c_vsys, require_assertion=1, Name=name)  # 到其他vsys下查询
        time.sleep(1)
        self._vsys_check(result, c_vsys, c_type, c_supervisor, f_vsys, f_type, f_supervisor)
        # 删除创建的数据
        time.sleep(1)
        self._query(data, f_vsys, require_assertion=1, Name=name)
        self._del()
        time.sleep(2)

    def _vsys_check(self, result, c_vsys, c_type, c_supervisor, f_vsys, f_type, f_supervisor):
        if c_type == f_type:  # 平级vsys不可见 T1 T2 或M1 M2(M1 M2无隶属关系)
            pytest_check.equal(result, 0, msg="所在行数{}".format(inspect.currentframe().f_lineno))
        else:
            if c_type == "Mvsys" and f_type == "Tvsys":  # Mvsys查看下级Tvsys数据
                if c_supervisor == "open":  # Mvsys开启监督模式,可查看下级Tvsys数据
                    self.first_row_checkBox_element.click()  # 变量来自查询函数
                    self.profiles_po.data_limit(listPage_profile_insertScripts_editButton_posId,
                                                listPage_profile_insertScripts_delButton_posId)
                elif c_supervisor == "close":  # Mvsys关闭监督模式,不可查看下级Tvsys数据
                    pytest_check.equal(result, 0, msg="所在行数{}".format(inspect.currentframe().f_lineno))
            elif c_type == "Tvsys" and f_type == "Mvsys":  # Tvsys查看Mvsys数据,不可查
                pytest_check.equal(result, 0, msg="所在行数{}".format(inspect.currentframe().f_lineno))

    @screenshot_on_failure
    def _audit_log(self, operation):
        """
        operation: Add---create; Update---modify
        :param operation:
        :return:
        """
        self.first_row_checkBox_element.click()
        self.driver.find_element(By.ID, listPage_profile_insertScripts_editButton_posId).click()
        time.sleep(2)
        self.driver.find_element(By.XPATH, "//div[@class='audit_log']/span").click()
        # 第一条记录勾选框
        self.driver.find_element(By.XPATH, "//tr[1]/td/div/label/span").click()
        # 点击Compare
        btn_compare = self.driver.find_element(By.ID, "test-compare-_AuditLogs_InfoRightProfile_VPanel_VEditPanel_insertadd_Home_App_anonymousComponent")
        self.driver.execute_script("arguments[0].click()", btn_compare)  # 强制点击
        time.sleep(0.5)
        # 获取 operation content
        current_operation = self.driver.find_element(By.XPATH, "//div[@class='compare-code-title']//div[3]/div[2]").text.strip()
        pytest_check.equal(current_operation, operation, msg="所在行数{}".format(inspect.currentframe().f_lineno))
        self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
        if self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).is_displayed():
            self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_warningSaveYes_posCss).click()

    def _policy_create(self, profile_name):
        # 进入Intercept列表页
        self._goto_vsysPage()
        self.driver.find_element(By.ID, mainPage_firstLevelMenu_Policy_posId).click()
        self.driver.find_element(By.ID, mainPage_secondLevelMenu_Proxy_Manipulation_posId).click()
        # 创建 rule
        policy_name = self.profiles_po.policy_create("Manipulation_Insert", profile_name, listPage_manipulation_create_button_posId, manipulation_input_Name_posXpath,
                                manipulation_action_label_Insert_posId, manipulation_source_add_posXpath, manipulation_button_oK_posId, manipulation_button_cancel_posId,
                                manipulation_button_warningSaveYes_posCss, "http", "", "",
                                manipulation_add_condition_button_posXpath, manipulation_http_filter_URL_select_posXpath, manipulation_http_filter_URL_add_posXpath, insert_file_dropDown_item_posCss, insert_file_profile_search_posXpath)
        return policy_name

    def _policy_query(self, **kwargs):
        # 打开该列表
        self._goto_vsysPage()
        self.driver.find_element(By.ID, mainPage_firstLevelMenu_Policy_posId).click()
        self.driver.find_element(By.ID, mainPage_secondLevelMenu_Proxy_Manipulation_posId).click()
        # first_row查询到的第一行内容。map_header_className为需要使用的到字典,用来提取第一行的结果。
        result = self.profiles_po.query(listPage_manipulationSearch_selectLabel_posId, listPage_manipulationSearch_dropDown_item_posXpath,
                                        listPage_manipulationSearch_input_itemContent_posXpath, listPage_manipulationSearch_buttonSearch_posId,
                                        listPage_manipulationTable_tableTbody_posXpath,  listPage_manipulationTable_tableHeader_posXpath, **kwargs)
        if result == 0:
            print("no data")
        else:
            first_row, map_header_className = result
            # 第一行的勾选定位,给修改、删除使用
            self.first_row_checkBox_element = first_row.find_element(By.XPATH, "//span[@class='el-checkbox__input']")

    def _policy_del(self):
        """
        默认删除查询到的第一个结果
        :return:
        """
        # 点击勾选第一行选择框
        self.first_row_checkBox_element.click()  # 变量来自查询函数
        # 调用profiles的功能删除方法
        self.profiles_po.delete(listPage_manipulation_delete_button_posId,
                                listPage_dialogTips_manipulation_button_yes_posCss,
                                listPage_dialogTips_manipulation_button_no_posCss)

    def _referenceCount_view(self, **kwargs):
        self._goto_subProfilePage()
        first_row, map_header_className = \
            self.profiles_po.query(listPage_profileSearch_insertScripts_selectLabel_posId,
                                   listPage_profileSearch_insertScripts_dropDown_item_posXpath,
                                   listPage_profileSearch_insertScripts_input_itemContent_posXpath,
                                   listPage_profileSearch_insertScripts_buttonSearch_posId,
                                   listPage_profilTable_insertScripts_tableTbody_posXpath,
                                   listPage_profilTable_insertScripts_tableHeader_posXpath, **kwargs)
        first_row_checkBox_element = first_row.find_element(By.XPATH, "//span[@class='el-checkbox__input']")
        first_row_referenceCount_class = map_header_className["Reference Count"]
        # print("first_row_referenceCount_class=", first_row_referenceCount_class)
        first_row_checkBox_element.click()
        if first_row.find_element(By.XPATH,
                                  f"//td[contains(@class, '{first_row_referenceCount_class}')]/div").get_attribute("value") != "0":
            print("数据被引用")
            # 校验该条数据是否可删除
            text_del = self.driver.find_element(By.ID, listPage_profile_insertScripts_delButton_posId).get_attribute("class")
            disabled_class = text_del.split(" ")[-1].strip()
            pytest_check.equal(disabled_class, "is-disabled", msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 校验是否弹出侧滑框
            first_row.find_element(By.ID, "ReferenceData-_Profile_Insert_Home_App_anonymousComponent").click()   #点击引用计数
            pytest_check.equal(self.driver.element_isExist(By.XPATH, "//div[@class='LocalationDraswer lstsub policy-right-show-edit']"),
                               True, msg="所在行数{}".format(inspect.currentframe().f_lineno))
            self.driver.find_element(By.XPATH, "//div[@class='box-content']/div/div[1]").click()

    @screenshot_on_failure
    def listPageBottom_allSelect(self):
        # 跳转到列表页
        self._goto_subProfilePage()    #跳转页面
        self.profiles_po.check_checkBoxClass_by_buttonAll()

    @screenshot_on_failure
    def check_createAndEditPageElement(self, data):
        # 检验create 页面元素
        self._goto_subProfilePage()    #跳转页面
        #点击create
        self.driver.find_element(By.ID, listPage_profile_insertScripts_createButton_posId).click()
        #在create 页面校验元素
        create_page_header_except = "Create Insert Script"
        create_page_headr_actual = self.driver.find_element(By.XPATH, insertScripts_headerTitle_posXpath).text.strip()
        print("开始校验create页面元素...")
        pytest_check.equal(create_page_header_except, create_page_headr_actual, msg="所在行数{}".format(inspect.currentframe().f_lineno))
        # 点击 cancel 按钮
        self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
        # 检验edit 页面元素
        tmp_name = self._create(data)
        time.sleep(3)
        self._query(data, require_assertion=0, Name=tmp_name)    #创建后查询
        if data["model"].strip().lower() == "create":    #如果是create参数用例,则不用执行修改方法
            return 0
        #点击勾选第一行选择框
        self.first_row_checkBox_element.click()     #变量来自查询函数
        self.driver.find_element(By.ID, listPage_profile_insertScripts_editButton_posId).click()   #打开edit页面
        print("开始校验edit页面元素...")
        edit_page_header_except = "Edit Insert Script"
        edit_page_headr_actual = self.driver.find_element(By.XPATH, insertScripts_headerTitle_posXpath).text.strip()
        pytest_check.equal(edit_page_header_except, edit_page_headr_actual, msg="所在行数{}".format(inspect.currentframe().f_lineno))
        # 点击 cancel 按钮
        self.driver.find_element(By.CSS_SELECTOR, insertScripts_button_cancel_posCss).click()
        self._query(data, require_assertion=0, Name=tmp_name)
        self._del()    #删除数据

    @screenshot_on_failure
    def check_link_case(self, data, link_list_dict):
        # link简单link校验测试
        """
        :param data: link_list_dict=[{"link_dst_cluster": "42.49-User4Link", "link_dst_vsys":"Vsys2test", "url": "http://192.168.42.49/#/login","username": "admin","passwd": "admin"}])
        :param link_list_dict:
        :return:
        """
        self._goto_subProfilePage()
        tmp_name = self._create(data)
        time.sleep(3)
        self._query(data, require_assertion=0, Name=tmp_name)
        # 勾选第一行
        self.first_row_checkBox_element.click()
        # 调用公共的link创建逻辑
        self.profiles_po.linkdata(link_list_dict, listPage_profile_insertScripts_linkButton_posId, listPage_linkTips_insertScripts_button_save_posXpath,
                                  listPage_linkTips_insertScripts_button_add_posXpath, listPage_linkTips_insertScripts_button_OK_posXpath)
        # 删除数据
        self._query(data, require_assertion=0, Name=tmp_name)
        self._del(del_model=1)    #删除数据
        time.sleep(3)
        # 删除其它目标link数据逻辑
        self._del_linkDstData(data, tmp_name, link_list_dict)

    def _del_linkDstData(self, data, tmp_name, link_list_dict):
        """
        删除目标link数据
        :param data:
        :param tmp_name:
        :param link_list_dict:
        :return:
        """
        loginout = LogInOut(self.driver)
        loginout.logout()
        time.sleep(1)
        for link_index in range(len(link_list_dict)):
            loginout.login_other(url=link_list_dict[link_index]["url"], username=link_list_dict[link_index]["username"],
                                 passwd=link_list_dict[link_index]["passwd"])
            self._query(data, vsys_name_2=link_list_dict[link_index]["link_dst_vsys"], require_assertion=0, Name=tmp_name)
            self._del(del_model=1)    #删除数据
            time.sleep(3)
            # 退出账号
            loginout.logout()
            time.sleep(1)
        # 再次登录源tsg,测试退出使用
        loginout.login()

    @screenshot_on_failure
    def chk_lnk_mod_case(self, data, link_list_dict):
        # link 源数据修改测试
        """
        :param data: link_list_dict=[{"link_dst_cluster": "42.49-User4Link", "link_dst_vsys":"Vsys2test", "url": "http://192.168.42.49/#/login","username": "admin","passwd": "admin"}])
        :param link_list_dict:
        :return:
        """
        try:
            tmp_name = self._create(data)
            time.sleep(3)
            search_dict = self._query(data, require_assertion=0, Name=tmp_name)
            # 勾选第一行
            self.first_row_checkBox_element.click()
            # 调用公共的link创建逻辑
            Des_ID_list, Request_ID, Sou_ID_list = self.profiles_po.linkdata(link_list_dict,
                                                                             listPage_profile_insertScripts_linkButton_posId,
                                                                             listPage_linkTips_insertScripts_button_save_posXpath,
                                                                             listPage_linkTips_insertScripts_button_add_posXpath,
                                                                             listPage_linkTips_insertScripts_button_OK_posXpath)
            # save data
            self._query(data, require_assertion=1, ID=search_dict["ID"])
            chk_lnk_name, chk_lnk_type = [], []
            sou_value_name = self.driver.find_element(By.XPATH,
                                                      "//div[@class='cell']//span[contains(@class,'el-tooltip white-space')]").text
            chk_lnk_name.append(sou_value_name)
            sou_value_type = self.driver.find_element(By.XPATH, "//span[@class='table-hide']").text
            chk_lnk_type.append(sou_value_type)
            self.driver.find_element(By.XPATH, f"//i[contains(@id, 'dowmloadi{search_dict['ID']}')]").click()

            # 切换源
            loginout = LogInOut(self.driver)
            loginout.logout()
            time.sleep(2)
            for link_index in range(len(link_list_dict)):
                loginout.login_other(url=link_list_dict[link_index]["url"], username=link_list_dict[link_index]["username"],
                                     passwd=link_list_dict[link_index]["passwd"])
                profile_public = ProfilesPublicOperations(self.driver)
                profile_public.change_vsys(vsys_name=link_list_dict[link_index]["link_dst_vsys"])
                # 获取Link后的值
                self._query(data, vsys_name_2=link_list_dict[link_index]["link_dst_vsys"], require_assertion=0, ID=Des_ID_list[0])
                # 点击文件下载
                self.driver.find_element(By.XPATH, f"//i[contains(@id, 'dowmloadi{Des_ID_list[0]}')]").click()
                time.sleep(2)
                # 获取Link后的值
                des_value_Name = self.driver.find_element(By.XPATH,
                                                          "//div[@class='cell']//span[contains(@class,'el-tooltip white-space')]").text
                chk_lnk_name.append(des_value_Name)
                self.profiles_po.lst_are_same(chk_lnk_name)
                des_value_type = self.driver.find_element(By.XPATH,
                                                          "//span[@class='table-hide']").text
                chk_lnk_type.append(des_value_type)
                self.profiles_po.lst_are_same(chk_lnk_type)

            self.profiles_po.change_sou_vsys()
            # update data
            self._query(data, require_assertion=1, ID=search_dict["ID"])
            self._modify(data)
            self._query(data, require_assertion=2, ID=search_dict["ID"])

            # save data
            sou_value_name = self.driver.find_element(By.XPATH,"//div[@class='cell']//span[contains(@class,'el-tooltip white-space')]").text
            sou_value_type = self.driver.find_element(By.XPATH,"//span[@class='table-hide']").text
            self.driver.find_element(By.XPATH, f"//i[contains(@id, 'dowmloadi{search_dict['ID']}')]").click()
            time.sleep(1)
            # click sync
            Request_ID = self.profiles_po.click_pol_lnk_sync(Request_ID)
            time.sleep(3)
            # self.driver.find_element(By.XPATH, hijackFiles_button_Sync_pos).click()
            #
            Request_ID, compare_list_name, compare_list_type = self._mod_des_chk_syc(Des_ID_list, Request_ID,
                                                                                    link_list_dict, data)
            # 列表去重
            compare_list_name.append(sou_value_name)
            print(compare_list_name)
            self.profiles_po.lst_are_same(compare_list_name)
            compare_list_type.append(sou_value_type)
            print(compare_list_type)
            self.profiles_po.lst_are_same(compare_list_type)
        except Exception as e:
            assert e
        finally:
            self._just_goto_insert_page()
            self._delete_des(Des_ID_list, data)  # 删除数据
            time.sleep(3)
            # 删除policy links记录
            self.profiles_po._del_policy_links(Request_ID)
            # 删除源vsys数据
            self._delete_sou(Sou_ID_list, data)


    @screenshot_on_failure
    def _mod_des_chk_syc(self, Des_ID_list, Request_ID, link_list_dict, data):
        loginout = LogInOut(self.driver)
        loginout.logout()
        time.sleep(2)
        compare_list_name = []
        compare_list_type = []
        for link_index in range(len(link_list_dict)):
            loginout.login_other(url=link_list_dict[link_index]["url"], username=link_list_dict[link_index]["username"],
                                 passwd=link_list_dict[link_index]["passwd"])
            profile_public = ProfilesPublicOperations(self.driver)
            profile_public.change_vsys(vsys_name=link_list_dict[link_index]["link_dst_vsys"])
            self._query(data, vsys_name_2=link_list_dict[link_index]["link_dst_vsys"], require_assertion=0, ID=Des_ID_list[0])
            self.driver.find_element(By.XPATH, f"//i[contains(@id, 'dowmloadi{Des_ID_list[0]}')]").click()
            time.sleep(2)
            # 获取sync后的值
            des_value_Name = self.driver.find_element(By.XPATH,"//div[@class='cell']//span[contains(@class,'el-tooltip white-space')]").text
            compare_list_name.append(des_value_Name)
            des_value_type = self.driver.find_element(By.XPATH,"//span[@class='table-hide']").text
            compare_list_type.append(des_value_type)
            # modify des data
            self._query(data, vsys_name_2=link_list_dict[link_index]["link_dst_vsys"], require_assertion=0, ID=Des_ID_list[0])
            self._modify(data={
                "ids": "创建js类型insert_files数据再修改css类型数据",
                "model": "modify",
                "script": "test_css_1.css->test_js_1.js",
                "script_type": "css->js",
                "insert_position": "Before Page Load->不修改",
            })
            # 调用公用的sync点击逻辑
            Request_ID = self.profiles_po.click_pol_lnk_sync(Request_ID)

            loginout.login_other(url=link_list_dict[link_index]["url"],
                                 username=link_list_dict[link_index]["username"],
                                 passwd=link_list_dict[link_index]["passwd"])
            profile_public = ProfilesPublicOperations(self.driver)
            profile_public.change_vsys(vsys_name=link_list_dict[link_index]["link_dst_vsys"])
            self._query(data, vsys_name_2=link_list_dict[link_index]["link_dst_vsys"], require_assertion=0, ID=Des_ID_list[0])
            self.driver.find_element(By.XPATH, f"//i[contains(@id, 'dowmloadi{Des_ID_list[0]}')]").click()
            time.sleep(2)
            # 获取sync后的值
            second_des_value_Name = self.driver.find_element(By.XPATH,
                                                      "//div[@class='cell']//span[contains(@class,'el-tooltip white-space')]").text
            compare_list_name.append(second_des_value_Name)
            second_des_value_type = self.driver.find_element(By.XPATH,"//span[@class='table-hide']").text
            compare_list_type.append(second_des_value_type)

        return Request_ID, compare_list_name, compare_list_type

    def _delete_sou(self, Sou_ID_list, data):
        loginout = LogInOut(self.driver)
        loginout.logout()
        time.sleep(1)
        loginout.login_other(url="http://192.168.44.72/#/login",
                             username="AUTO_UI_TEST_KG", passwd="kongweibin1")
        # 删除数据
        profile_public = ProfilesPublicOperations(self.driver)
        profile_public.change_vsys(vsys_name="UIAutoTestVsys")
        self._just_goto_insert_page()
        self._delete_source(Sou_ID_list, data)  # 删除数据

    def _delete_des(self, Des_ID_list, data):
        self.driver.find_element(By.ID, 'select-label').click()
        self.driver.find_element(By.XPATH,
                                 "//li[starts-with(@id, '1-_FilteredSearch_ElRow_Profile')]//span[normalize-space(text())='ID']").click()
        self.driver.find_element(By.XPATH, '//input[contains(@placeholder, "Support")]').send_keys(Des_ID_list[0])
        self.driver.find_element(By.ID, mainPage_profileSearch_buttonSearch_posId).click()
        time.sleep(1)
        self.driver.find_element(By.XPATH, "//div[@class='el-checkbox-group']//span[@class='el-checkbox__input']/span[@class='el-checkbox__inner']").click()
        # 确认删除
        self.driver.find_element(By.XPATH, "//p[normalize-space(text())='Delete']").click()
        self.driver.find_element(By.CSS_SELECTOR, listPage_dialogTips_insertScripts_button_yes_posCss).click()

    def _delete_source(self, Sou_ID_list, data):
        self.driver.find_element(By.ID, 'select-label').click()
        self.driver.find_element(By.XPATH,
                                 "//li[starts-with(@id, '1-_FilteredSearch_ElRow_Profile')]//span[normalize-space(text())='ID']").click()
        self.driver.find_element(By.XPATH, '//input[contains(@placeholder, "Support")]').send_keys(Sou_ID_list[0])
        self.driver.find_element(By.ID, mainPage_profileSearch_buttonSearch_posId).click()
        time.sleep(1)
        self.driver.find_element(By.XPATH,
                                 "//div[@class='el-checkbox-group']//span[@class='el-checkbox__input']/span[@class='el-checkbox__inner']").click()
        # 确认删除
        self.driver.find_element(By.XPATH, "//p[normalize-space(text())='Delete']").click()
        self.driver.find_element(By.CSS_SELECTOR, listPage_dialogTips_insertScripts_button_yes_posCss).click()

    @screenshot_on_failure
    def _just_goto_insert_page(self, vsys_name_2=""):
        # 菜单操作,定位到ssl_decryption_keyrings列表页
        # self.driver.find_element(By.CSS_SELECTOR, mainPage_navigationBar_logo_posCss).click()
        self.driver.find_element(By.ID, mainPage_firstLevelMenu_profiles_posId).click()
        element = self.driver.find_element(By.ID, mainPage_secondLevelMenu_insertScripts_posId)
        self.driver.execute_script("arguments[0].click()", element)  # 强制点击

    def chk_query_spec_chr(self, data):
        # 跳转到 hijack_page
        self._goto_subProfilePage()

        # 点击search查询框
        self.driver.find_element(By.ID, mainPage_profileSearch_selectLabel_posId).click()
        # 循环输入查询内容
        for key, value in data.items():

            if "_" in key:
                key = key.replace("_", " ")  # 将下划线替换为空格 listPage_profileSearch_hijackFiles_dropDown_item_posXpath
            dropdown_item_posXpath = listPage_profileSearch_insertScripts_dropDown_item_posXpath.format(replaceName=key)
            self.driver.find_element(By.XPATH, dropdown_item_posXpath).click()  # 点击下拉item
            input_item_posXpath = listPage_profileSearch_insertScripts_input_itemContent_posXpath.format(
                replaceName=key)
            self.driver.find_element(By.XPATH, input_item_posXpath).send_keys(value.strip())  # 输入查询值
            self.driver.find_element(By.XPATH, input_item_posXpath).send_keys(Keys.ENTER)  # 模拟回车按键
            # 点击查询按钮
            element_search = self.driver.find_element(By.ID, mainPage_profileSearch_buttonSearch_posId)
            self.driver.execute_script("arguments[0].click()", element_search)  # 强制点击
            if key == "ID":
                content = self.driver.find_element(By.XPATH, "//p[text()=\"ID only supports numbers and English characters\',\'\"]").text
                pytest_check.equal(content,
                    "ID only supports numbers and English characters','",msg="所在行数{}".format(inspect.currentframe().f_lineno))

            if key == "Name":
                val = self.driver.find_element(By.XPATH, input_item_posXpath).text
                pytest_check.equal(len(val) < 256,
                                   True, msg="所在行数{}".format(inspect.currentframe().f_lineno))
            # 强制点击清空查询按钮
            element_clear = self.driver.find_element(By.ID, listPage_profileSearch_insertScripts_buttonClear_posId)
            self.driver.execute_script("arguments[0].click()", element_clear)  # 强制点击

    def _audit_log_all_operation(self, data):
        ran_name = self._create(data)
        try:
            time.sleep(0.5)
            search_dict = self._query(data, Name=ran_name)
            self._modify(data)
            time.sleep(0.5)
        except Exception as e:
            raise e
        finally:
            self._query(data, Name=ran_name)
            self._del()
        self.profiles_po.audit_log_view("Insert Script", search_dict["ID"])


    create = _create
    query = _query
    modify = _modify
    delete = _del
    column_setting = _column_setting
    turn_pages = _turn_pages
    language_change = _language_change
    file_download = _file_download
    vsys_case = _vsys_case
    vsys_check = _vsys_check
    audit_log = _audit_log
    policy_create = _policy_create
    policy_query = _policy_query
    policy_delete = _policy_del
    referenceCount_view = _referenceCount_view

if __name__ == '__main__':
    chrome_option = webdriver.ChromeOptions()
    a = MyWebDriver(
        command_executor="http://192.168.64.23:4444",
        options=chrome_option
    )
    a.get("http://192.168.44.72")
    a.maximize_window()
    a.find_element(By.XPATH,"//*[@id='app']/div/div[1]/div[2]/div[2]/div[1]/div/input").send_keys("AUTO_UI_TEST_KG")
    a.find_element(By.XPATH,"//*[@id='app']/div/div[1]/div[2]/div[2]/div[2]/div/input").send_keys("kongweibin1")
    a.find_element(By.ID,"login").click()
    time.sleep(2)
    # 测试修改数据
    r = InsertScripts(a)
    # profile_pub = ProfilesPublicOperations(r)
    # profile_pub.change_vsys(vsys_name='UIAutoTestVsys')
    # model=0/1 ====0:单个   1group
    # type =IMSI/Phone_Number/IMEI
    data= {
        "ids": "创建js类型insert_files数据再修改css类型数据",
        "model": "modify",
        "script": "test_js_1.js->test_css_1.css",
        "script_type": "js->css",
        "insert_position": "Before Page Load->不修改",
    }
    # 测试link
    link_parse = configparser.ConfigParser()
    link_parse_dir = os.path.join(workdir, "config", "linkcluster.ini")
    link_parse.read(link_parse_dir, encoding="utf-8")
    link_list_dict = []
    link_list = [1]  # 可取值 1、2、 3、4、5   #这些取值来自linkcluster.ini配置文件
    for i in link_list:
        tmp_dict = {}
        link_index = "link_{}".format(i)
        tmp_dict["link_dst_cluster"] = link_parse.get(link_index, "link_dst_cluster")
        tmp_dict["link_dst_vsys"] = link_parse.get(link_index, "link_dst_vsys")
        tmp_dict["url"] = link_parse.get(link_index, "url")
        tmp_dict["username"] = link_parse.get(link_index, "username")
        tmp_dict["passwd"] = link_parse.get(link_index, "passwd")
        link_list_dict.append(copy.deepcopy(tmp_dict))
    print(link_list_dict)
    """   传参查考
    link_list_dict = [
        {
            "link_dst_cluster": "42.49-User4Link",
            "link_dst_vsys": "Vsys2test",
            "url": "http://192.168.42.49/#/login",
            "username": "admin",
            "passwd": "admin"
         },
    ]
    """

    r.chk_lnk_mod_case(data, link_list_dict=link_list_dict)