diff options
34 files changed, 1829 insertions, 1 deletions
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..9d3df88 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1
+encoding//01-TestCase/zjj/DLL-DeviceID-Test.robot=UTF-8
+encoding//02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot=UTF-8
+encoding//customlib/common_Run.py=utf-8
+encoding/<project>=UTF-8
diff --git a/__init__.robot b/__init__.robot index 858fd96..f7baeb7 100644 --- a/__init__.robot +++ b/__init__.robot @@ -4,4 +4,4 @@ #Resource keyword/common/login_logout_switch.robot Suite Setup LoginAndAddLocalIP Suite Teardown LogoutAndDelLocalIP -Resource keyword/common/login_logout_switch.robot +Resource keyword/common/login_logout_switch.robot
\ No newline at end of file diff --git a/case/profiles/insert_script.robot b/case/profiles/insert_script.robot new file mode 100644 index 0000000..0d229bb --- /dev/null +++ b/case/profiles/insert_script.robot @@ -0,0 +1,30 @@ +****** Settings ***
+Library yaml
+Library OperatingSystem
+Library Selenium2Library
+Resource ../../variable/common_variable.txt
+Resource ../../keyword/common/page.robot
+
+*** Variables ***
+
+*** Test Cases ***
+insert_script
+ log ${TEST NAME}
+ # 读取模板文件内容
+ ${yamltemplate} YamlLoad ${path}/data/template/page_template.yaml
+ ${objtemplate} Get From Dictionary ${yamltemplate} ${TEST NAME}_page
+ # 读取数据文件内容
+ ${yamlData} YamlLoad ${path}/data/profiles/insert_script_data.yaml
+ ${objDataList} Get From Dictionary ${yamlData} ${TEST NAME}_data
+ # 读取模板文件中OpenCreateOrEditPageIds中的数据(打开页面)
+ ${openCreateOrEditPageIds} Get From Dictionary ${objtemplate} OpenCreateOrEditPage
+ # 读取模板文件中PageData中的数据(打开页面)
+ ${tempData} Get From Dictionary ${objtemplate} PageData
+ ${OkOrCance} Get From Dictionary ${objtemplate} OkOrCancel
+ FOR ${objData} IN @{objDataList}
+ ${pageData} CreateOrEditPage ${tempData} ${objData} ${openCreateOrEditPageIds} ${OkOrCance}
+
+ END
+
+
+
\ No newline at end of file diff --git a/case/profiles/response_page.robot b/case/profiles/response_page.robot new file mode 100644 index 0000000..9e05387 --- /dev/null +++ b/case/profiles/response_page.robot @@ -0,0 +1,48 @@ +****** Settings ***
+Library yaml
+Library OperatingSystem
+Library Selenium2Library
+Resource ../../variable/common_variable.txt
+Resource ../../keyword/common/page.robot
+
+*** Variables ***
+
+*** Test Cases ***
+
+response_page
+ log ${TEST NAME}
+ # 读取模板文件内容
+ ${yamltemplate} YamlLoad ${path}/data/template/page_template.yaml
+ ${objtemplate} Get From Dictionary ${yamltemplate} ${TEST NAME}_page
+ # 读取数据文件内容
+ ${yamlData} YamlLoad ${path}/data/profiles/response_page_data.yaml
+ ${objDataList} Get From Dictionary ${yamlData} ${TEST NAME}_data
+ # 读取模板文件中OpenCreateOrEditPageIds中的数据(打开页面)
+ ${openCreateOrEditPageIds} Get From Dictionary ${objtemplate} OpenCreateOrEditPage
+ # 读取模板文件中PageData中的数据(打开页面)
+ ${tempData} Get From Dictionary ${objtemplate} PageData
+ ${OkOrCance} Get From Dictionary ${objtemplate} OkOrCancel
+ FOR ${objData} IN @{objDataList}
+ ${pageData} CreateOrEditPage ${tempData} ${objData} ${openCreateOrEditPageIds} ${OkOrCance}
+
+ END
+
+
+
+
+# response_page
+ # log ${TEST NAME}
+ # ${yamlData}= Get File ${path}/data/profiles/response_page_template.yaml
+ # ${loadedData}= yaml.Safe Load ${yamlData}
+ # ${list} Get From Dictionary ${loadedData} ${TEST NAME}_page
+
+ # ${listType} = Evaluate type(${list})
+ # FOR ${objData} IN @{list}
+ # ${tempData} Get From Dictionary ${objData} OpenCreateOrEditPageIds
+ # ${openCreateOrEditPageIds} OpenCreateOREdit ${tempData}
+ # ${tempData} Get From Dictionary ${objData} PageData
+ # ${pageData} OperatPage ${tempData}
+ # ${tempData} Get From Dictionary ${objData} OkOrCancel
+ # ${okOrCancel} OkOrCancel ${tempData}
+ # END
+
\ No newline at end of file diff --git a/customlib/common/__pycache__/common.cpython-36.pyc b/customlib/common/__pycache__/common.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..365d645 --- /dev/null +++ b/customlib/common/__pycache__/common.cpython-36.pyc diff --git a/customlib/common/__pycache__/common.cpython-37.pyc b/customlib/common/__pycache__/common.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..a3dbf44 --- /dev/null +++ b/customlib/common/__pycache__/common.cpython-37.pyc diff --git a/customlib/common/__pycache__/type_judgment.cpython-36.pyc b/customlib/common/__pycache__/type_judgment.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..8262ea4 --- /dev/null +++ b/customlib/common/__pycache__/type_judgment.cpython-36.pyc diff --git a/customlib/common/__pycache__/type_judgment.cpython-37.pyc b/customlib/common/__pycache__/type_judgment.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..badeef8 --- /dev/null +++ b/customlib/common/__pycache__/type_judgment.cpython-37.pyc diff --git a/customlib/common/__pycache__/util.cpython-36.pyc b/customlib/common/__pycache__/util.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..f849b62 --- /dev/null +++ b/customlib/common/__pycache__/util.cpython-36.pyc diff --git a/customlib/common/common.py b/customlib/common/common.py new file mode 100644 index 0000000..2d282ed --- /dev/null +++ b/customlib/common/common.py @@ -0,0 +1,51 @@ +import json
+import random
+import hashlib
+import os
+
+#判断一个字符或字符串是否包含于另一个字符串:a是否再b中,是否则返回True,否则返回Falsle
+def aisincludeb(a,b):
+ result = a in b
+ print(result)
+ return result
+
+#删除字符串当前前几个,或后几个:sourcestr源串,a[2:-2] 表示去掉前面两个和后面两个,如果光去掉后面的a[:-2]
+def removeBeforOrAfter(sourcestr,a):
+ #a = "16541616584984"
+ #a = a[2:-2]
+ sourcestr = sourcestr[a]
+ return result
+
+#分离字符串
+def string2list(str,split):
+ return str.split(split)
+
+#用于生成一个指定范围内的整数
+def randomint(a,b):
+ return random.randint(a,b)
+
+#较小文件处理方法:
+def get_md5_01(file_path):
+ md5 = None
+ if os.path.isfile(file_path):
+ f = open(file_path,'rb')
+ md5_obj = hashlib.md5()
+ md5_obj.update(f.read())
+ hash_code = md5_obj.hexdigest()
+ f.close()
+ md5 = str(hash_code).lower()
+ return md5
+
+#较大文件处理方法:
+def get_md5_02(file_path):
+ f = open(file_path,'rb')
+ md5_obj = hashlib.md5()
+ while True:
+ d = f.read(8096)
+ if not d:
+ break
+ md5_obj.update(d)
+ hash_code = md5_obj.hexdigest()
+ f.close()
+ md5 = str(hash_code).lower()
+ return md5
\ No newline at end of file diff --git a/customlib/common/type_judgment.py b/customlib/common/type_judgment.py new file mode 100644 index 0000000..f3765ce --- /dev/null +++ b/customlib/common/type_judgment.py @@ -0,0 +1,4 @@ +
+def dataType(data):
+ type1=type(data)
+ return type1
diff --git a/customlib/common/util.py b/customlib/common/util.py new file mode 100644 index 0000000..98befec --- /dev/null +++ b/customlib/common/util.py @@ -0,0 +1,17 @@ +import socket
+import fcntl
+import struct
+import string
+
+def get_ip_address(ifname):
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ return socket.inet_ntoa(fcntl.ioctl(
+ s.fileno(),
+ 0x8915, # SIOCGIFADDR
+ struct.pack('256s', ifname[:15])
+ )[20:24])
+
+#get_ip_address('eth0') # '192.168.0.110'
+
+def source_str_is_cotain_destion_str(sourcestr,destionstr):
+ return string.find(sourcestr,destionstr)!=-1
\ No newline at end of file diff --git a/customlib/common_Run.py b/customlib/common_Run.py new file mode 100644 index 0000000..5aa4350 --- /dev/null +++ b/customlib/common_Run.py @@ -0,0 +1,228 @@ +# coding: utf-8
+
+import os,sys
+import time
+from config import BASE_PATH,Config
+from global_model.log import logger
+from global_model.format_change import formatChange
+from email_model.run_sendEmail import sendEailMock
+
+
+def batch_Call(basePath, product_item, testCase_tag):
+ '''
+ 首次执行测试:
+ param robot_testSuite: robot testSuite路径;
+ param product_item: 执行的待测产品项目;
+ param testCase_tag: 执行的测试用例标签;
+ param testCaseReportPath: 测试报告路径;
+ '''
+ try:
+ logger.info(u'=======================首次测试执行开始!正在初始化数据库!=============================')
+ pybot_result_list = []
+ output_dir = "-d " + basePath + "/Report/primo_report"
+ output_xml = "-o output.xml"
+ output_log = "-l log.html"
+ output_report = "-r report.html"
+ productItem = "-s " + product_item
+ caseTag = "-i " + testCase_tag
+ pybot_cmd = "pybot " + output_dir + " " + output_xml + " " + output_log + " " + output_report + " " + productItem + " " + caseTag + " " + basePath
+ pybot_result=os.system(pybot_cmd)
+ return pybot_result
+
+ except Exception as e:
+ logger.exception(u'首次执行测试失败. %s', e)
+
+ finally:
+ logger.info(u'测试项目根目录为:{0}'.format(basePath))
+ logger.debug(u'首次执行测试报告输出目录:{0}'.format(output_dir))
+ logger.info(u'首次执行测试的pybot命令:{0}'.format(pybot_cmd))
+ logger.info(u'======================首次执行测试已完成!用例失败数为:{0} 个!========================'.format(pybot_result))
+
+
+def mergeReport(basePath, report_title, match_report, copy_source_match, copy_target_match, merge_report_output):
+ '''
+ 合并报告:
+ param testCaseReportPath: 测试报告路径;
+ param report_title: 合并报告的标题;
+ return:
+ '''
+ try:
+ logger.info(u'==========================合并测试报告开始!==================================')
+ output_dir = "-d " + basePath + "/Report/{0}".format(merge_report_output) # 输出合并报告目录
+ output_xml = "-o output.xml"
+ output_log = "-l log.html"
+ output_report = "-r report.html"
+
+ # 被合并的报告
+ merge_report = "--merge " + basePath + "/Report/{0}".format(match_report) + "/output.xml"
+ title = "--ReportTitle " + report_title
+ rebot_cmd = r"rebot " + output_dir + " " + output_xml + " " + output_log + " " + output_report + " " + title + " " + merge_report
+ mergeReport_result = os.system(rebot_cmd)
+ logger.debug(u'合并报告的结果为:{0}'.format(mergeReport_result))
+
+ # 复制截图
+ testCaseReportPath = basePath + "/Report"
+ source_files = testCaseReportPath + "/{0}/*.png".format(copy_source_match)
+ target_dir = testCaseReportPath + "/{0}".format(copy_target_match)
+ cp_cmd = r"copy " + source_files + " " + target_dir
+ cp_cmd = cp_cmd.replace("/", "\\")
+ cope_result = os.system(cp_cmd)
+ logger.debug(u'复制截图的结果为:{0}'.format(cope_result))
+ return mergeReport_result
+
+ except Exception as e:
+ logger.exception(u'合并报告异常. %s', e)
+
+ finally:
+ logger.debug(u'输出合并报告目录为:{0}'.format(output_dir))
+ logger.info(u'合并报告rebot命令:{0}'.format(rebot_cmd))
+ if mergeReport_result != 0:
+ logger.info(u'======================合并报告中有失败用例!========================')
+ else:
+ logger.info(u'======================没有失败重试的报告需合并,或者合并报告中的用例已全通过!========================')
+ logger.info(u'复制截图命令为:{0}'.format(cp_cmd))
+ if cope_result == 0:
+ logger.info(u'======================截图已成功复制到合并报告中!========================')
+ else:
+ logger.info(u'======================报告中没有需要复制的截图!========================')
+
+
+def cleanLogs(basePath):
+ '''
+ 删除硬盘中合并前的测试报告:
+ param testCaseReportPath: 测试报告路径;
+ return:
+ '''
+ try:
+ logger.info(u'==========================清理磁盘报告开始!==================================')
+ testCaseReportPath = basePath + "/Report"
+ primo_report_files = testCaseReportPath + "/primo_report/*"
+ retry_report_files = testCaseReportPath + "/retry_report/*"
+ merge_files = testCaseReportPath + "/merge/*"
+ zip_merges_files = testCaseReportPath + "/zip_merges/*"
+ retry_times_files = testCaseReportPath + "/retry_times/*"
+ del_cmd = "del " + primo_report_files + " " + retry_report_files + " " + merge_files + " " + zip_merges_files + " " + retry_times_files
+ del_cmd = del_cmd.replace("/", "\\")
+ del_cmd = del_cmd + " " + "/s /q /f"
+ clean_result = os.system(del_cmd)
+
+ except Exception as e:
+ logger.exception(u'清理磁盘报告异常. %s', e)
+
+ finally:
+ logger.info(u'清理磁盘报告命令为:{0}'.format(del_cmd))
+ logger.debug(u'清理磁盘报告结果为:{0}'.format(clean_result))
+ if clean_result == 0:
+ logger.info(u'======================测试报告清理成功!========================')
+ else:
+ logger.info(u'======================测试报告清理失败!========================')
+
+
+def run_test(basePath, product_item, testCase_tag, report_title, email_switch, smtp_server, server_username, server_pwd, msg_to, msg_subject, retry_switch, retry_time):
+ '''
+ 失败自动重试:
+ param robot_testSuite: robot testSuite路径;
+ param testCase_tag: 执行的测试用例标签;
+ param testCaseReportPath: 测试报告路径;
+ param report_title: 合并报告的标题;
+ '''
+ #清理环境
+ cleanLogs(basePath)
+
+ #首次执行
+ run_result = batch_Call(basePath, product_item, testCase_tag)
+
+ #失败重试
+ retryFunction = retry_switch
+ if retryFunction == 1:
+ try:
+ if run_result != 0:
+ logger.info(u'======================失败用例重试第 1 次!========================')
+ output_dir = "-d " + basePath + "/Report/retry_report"
+ retry_xml = "-R " + basePath + "/Report/primo_report/output.xml"
+ pybot_cmd = "pybot " + retry_xml + " " + output_dir + " " + basePath
+ logger.info(u'第 1 次失败重试命令为:{0}'.format(pybot_cmd))
+ retry_result=os.system(pybot_cmd)
+ logger.info(u'======================失败用例重试第 1 次已完成!用例失败数为:{0} 个!========================'.format(retry_result))
+
+ retryTimes = retry_time
+ n = 2
+ while (retryTimes >=2 and retry_result != 0):
+ logger.info(u'======================失败用例重试第 {0} 次!========================'.format(n))
+ output_dir = "-d " + basePath + "/Report/retry_times"
+ retry_xml = "-R " + basePath + "/Report/retry_report/output.xml"
+ pybot_cmd = "pybot " + retry_xml + " " + output_dir + " " + basePath
+ logger.info(u'第 {0} 次失败重试命令为:{1}'.format(n, pybot_cmd))
+ retry_result=os.system(pybot_cmd)
+ logger.info(u'======================失败用例重试第 {0} 次已完成!用例失败数为:{1} 个!========================'.format(n, retry_result))
+
+ logger.info(u'======================正在合并重试报告!========================')
+ merge_report_output = 'retry_report'
+ match_report = 'retry_*'
+ copy_source_match = 'retry_times'
+ copy_target_match = 'retry_report'
+ mergeReport(basePath, report_title, match_report, copy_source_match, copy_target_match, merge_report_output)
+ logger.info(u'======================失败用例重试第 {0} 次合并报告已完成!========================'.format(n))
+ n = n + 1
+ retryTimes = retryTimes-1
+
+ except Exception as e:
+ logger.exception(u'失败重试异常. %s', e)
+
+ else:
+ logger.info(u'======================本次测试的失败重试功能已关闭!========================')
+
+ #合并报告
+ merge_report_output = 'merge'
+ match_report = '*_report'
+ copy_source_match = 'retry_report'
+ copy_target_match = 'merge'
+ report_result = mergeReport(basePath, report_title, match_report, copy_source_match, copy_target_match, merge_report_output)
+ logger.debug(u'======================最终测试结果为: {0} !========================'.format(report_result))
+ if report_result == 0:
+ ReportResult = u'测试通过!'
+ else:
+ ReportResult = u'测试不通过!失败用例数为:{0} 个'.format(report_result)
+
+ #发送report到邮件
+ emailFunction = email_switch
+ if emailFunction == 1:
+
+ #将字符中的反斜杠转成正斜杠
+ fileUrl_PATH = basePath.replace('\\','/')
+ logger.debug(u'基础路径的反斜杠转成正斜杠为:{0}'.format(fileUrl_PATH))
+
+ fileUrl='file:///{0}/Report/merge/report.html'.format(fileUrl_PATH)
+ logger.info(u'html测试报告的url为:{0}'.format(fileUrl))
+ save_fn=r'{0}\Report\zip_merges\report.png'.format(basePath)
+ logger.debug(u'转成图片报告后保存的目标路径为:{0}'.format(save_fn))
+ formatChange_obj = formatChange()
+ formatChange_obj.html_to_image(fileUrl, save_fn)
+
+ email_folder_dir = basePath + "/Report/merge" #待压缩文件夹
+ logger.debug(u'待压缩文件夹为:{0}'.format(email_folder_dir))
+ email_target_dir = basePath + "/Report/zip_merges" #压缩文件保存路径
+ sendEailMock_obj = sendEailMock()
+ sendEailMock_obj.send_email(email_folder_dir, email_target_dir, smtp_server, server_username, server_pwd, msg_to, msg_subject, ReportResult, save_fn)
+ else:
+ logger.info(u'======================本次测试的邮件功能已关闭!========================')
+
+
+if __name__ == '__main__':
+
+ c = Config()
+ ProductItem = c.get('ProductItem')
+ testSuite = c.get('testSuite')
+ testReportTitle = c.get('testReportTitle')
+
+ emailSwitch = c.get('emailSwitch')
+ smtp_server = c.get('smtp_server')
+ server_username = c.get('server_username')
+ server_pwd = c.get('server_pwd')
+ msg_to = c.get('msg_to')
+ msg_subject = c.get('msg_subject')
+
+ retrySwitch = c.get('retry_switch')
+ retryTime = c.get('retryTime')
+
+ run_test(BASE_PATH, ProductItem, testSuite, testReportTitle, emailSwitch, smtp_server, server_username, server_pwd, msg_to, msg_subject, retrySwitch, retryTime)
\ No newline at end of file diff --git a/keyword/common/login_logout.robot b/keyword/common/login_logout.robot new file mode 100644 index 0000000..8b309e5 --- /dev/null +++ b/keyword/common/login_logout.robot @@ -0,0 +1,82 @@ +*** Settings ***
+Library Selenium2Library
+Resource ../../variable/common_variable.txt
+
+*** Keywords ***
+
+Login
+ Open Browser http://${host}/#/login ${browserType}
+ Maximize Browser Window
+ ClearCache
+ input text xpath=//*[@id="app"]/div/div[2]/div/div[2]/div/input ${username}
+ input text xpath=//*[@id="app"]/div/div[2]/div/div[3]/div/input ${password}
+ Click button id=login
+ PasswordPrompt #判断是否有密码过期的提示
+
+ClearCache
+ ${status} Run Keyword And Return Status Page Should Contain After update the version, you need to clear the cache and log in again, otherwise some functions will not be available. #判断页面是否包含该文本
+ run keyword if "${status}"=="True" click element xpath=/html/body/div[2]/div/div[3]/button[2]
+ run keyword if "${status}"=="False" log 不用进行清除缓存
+
+PasswordPrompt
+ [Arguments] ${passwd}=null ${day}=100 ${editpasswd}=no
+ ${status} Run Keyword And Return Status Page Should Contain Does the password need to be changed when the password expires? #判断页面是否包含该文本
+ run keyword if "${status}"=="True" run keywords PasswordPromptTrue ${passwd} ${day} ${editpasswd}
+ run keyword if "${status}"=="False" log 密码未过期
+ Wait Until Element Is Visible id=dashboard 20
+
+PasswordPromptTrue
+ [Arguments] ${passwd} ${day} ${editpasswd}
+ run keyword if "${editpasswd}"=="yes" run keywords sleep 1
+ ... AND click element xpath=/html/body/div[2]/div/div[3]/button[2]
+ ... AND sleep 1
+ ... AND ChangePassword ${passwd} ${day}
+ ... ELSE IF "${editpasswd}"=="no" run keywords sleep 1
+ ... AND click element xpath=/html/body/div[2]/div/div[3]/button[1]
+ ... AND sleep 1
+
+ChangePassword
+ [Arguments] ${passwd} ${day} ${Required-Password-Change}=close
+ #判断是否修改密码
+ run keyword if "${passwd}"!="null" Run Keywords sleep 1
+ ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[3]/div/div/input ${passwd}
+ ... AND sleep 1
+ ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[4]/div/div/input ${passwd}
+ ... AND sleep 1
+ ${class}= Get Element Attribute xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[5]/div/div class #获取Required-Password-Change按钮的class元素的值
+ #通过元素的值判断按钮是开启状态还是关闭状态
+ run keyword if "${Required-Password-Change}"=="open" and "${class}"=="el-switch is-checked" Run Keywords log 按钮为开启状态,不进行操作
+ ... AND sleep 1
+ ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[6]/div/div/input ${day}
+ ... AND sleep 1
+ run keyword if "${Required-Password-Change}"=="open" and "${class}"=="el-switch" Run Keywords log 按钮为关闭状态,需要点击开启
+ ... AND sleep 1
+ ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[6]/div/div/input ${day}
+ ... AND sleep 1
+ run keyword if "${Required-Password-Change}"=="close" and "${class}"=="el-switch is-checked" Run Keywords log 按钮为开启状态,需要点击关闭
+ ... AND sleep 1
+ ... AND click element xpath=xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[5]/div/div
+ run keyword if "${Required-Password-Change}"=="close" and "${class}"=="el-switch" log 按钮为关闭状态,不进行操作
+ sleep 1
+ click element xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[2]/button[1]
+
+Logout
+ #Mouse Hover xpath=//*[@id="app"]/div/div[1]/div[2]/div/span/div/span
+ #/html/body/div[1]/div/div[1]/div[2]/div/span[2]/div/span
+ Mouse Hover xpath=//*[@id="user_avator"]/span
+ sleep 0.5
+ click element xpath=//div[@id='SignOut']
+ sleep 2
+ Close All Browsers
+
+UiLoginAndAddLocalIP
+ log UiLoginAndAddLocalIP
+ Login
+ # Run Keyword If ${addTestClentIPFlag}==1 AddLocalIp
+ log UiLoginAndAddLocalIP:${LocahIPName}
+
+
+UiLogoutAndDelLocalIP
+ log UiLogoutAndDelLocalIP
+ # Run Keyword If ${addTestClentIPFlag}==1 DeletePage ${LocahIPName}
+ Logout
\ No newline at end of file diff --git a/keyword/common/login_logout_switch.robot b/keyword/common/login_logout_switch.robot new file mode 100644 index 0000000..646ac5e --- /dev/null +++ b/keyword/common/login_logout_switch.robot @@ -0,0 +1,22 @@ +*** Settings *** +Resource ../../variable/common_variable.txt +Library Collections +Resource login_logout.robot +#Resource logout.robot +#Resource login.robot + + +*** Keywords *** +LoginAndAddLocalIP + [Tags] tsg_adc tsg_bf_api tsg_device tsg_adc_wp adc_api adc_verify adc_log + #[Tags] 分步骤之外的全流程 毕方接口 设备相关 分步骤全部 分步骤策略 分步骤功能端验证 分步骤日志验证 + # 获取主机IP + #${ip} Get Host IP + #Run Keyword If '${ip}' != '${EMPTY}' Set Global Variable ${testClentIP} ${ip} + + Run Keyword If '${loginType}' == 'ui' UiLoginAndAddLocalIP + + +LogoutAndDelLocalIP + [Tags] tsg_adc tsg_bf_api tsg_device tsg_adc_wp adc_api adc_verify adc_log + Run Keyword If '${loginType}' == 'ui' UiLogoutAndDelLocalIP diff --git a/keyword/common/page.robot b/keyword/common/page.robot new file mode 100644 index 0000000..1888a9e --- /dev/null +++ b/keyword/common/page.robot @@ -0,0 +1,242 @@ +*** Settings ***
+Library yaml
+Library OperatingSystem
+Library Selenium2Library
+Library Collections
+Resource ../../variable/common_variable.txt
+Library ../../customlib/common/type_judgment.py
+
+*** Keywords ***
+YamlLoad
+ [Arguments] ${filepath}
+ [Documentation] 读取yaml文件
+ ... ${filepath}:文件路径
+ ${Yaml}= Get File ${filepath}
+ ${Loaded}= yaml.Safe Load ${Yaml}
+ [Return] ${Loaded}
+
+CreateOrEditPage
+ [Arguments] ${elementList} ${dataList} ${OpenCreateOrEditPage} ${OkOrCance}
+ [Documentation] 完整的打开创建或者修改数据页面,并进行操作(创建数据、修改数据)
+ ... ${elementList}:模板的PageData数据,格式:[{id=responsepages_profileName1,value=testname}]
+ ... ${dataList}:数据文件中的数据,格式[[id=responsepages_profileName1,value=testname]]
+ ... ${OpenCreateOrEditPage}:模板文件中OpenCreateOrEditPage数据
+ ... ${OkOrCance}:模板文件中OkOrCancel的数据
+
+ FOR ${data} IN @{dataList}
+ OperatPage ${elementList} ${data} ${OpenCreateOrEditPage}
+ OkOrCancel ${OkOrCance} ${data}[profileName]
+ END
+ ${deletePosition} Get From Dictionary ${OkOrCance} delete
+ DeleteData ${deletePosition}
+
+OperatPage
+ [Arguments] ${elementList} ${pData} ${OpenCreateOrEditPage}
+ [Documentation] 打开创建或者修改数据页面,输入数据
+ ... ${elementList}:模板的PageData数据,格式:[{id=responsepages_profileName1,value=testname}]
+ ... ${pData}:数据文件中的数据,格式[id=responsepages_profileName1,value=testname]
+ ... ${OpenCreateOrEditPage}:模板文件中OpenCreateOrEditPage数据
+
+ ${openType} Get From Dictionary ${pData} operatingType
+ OpenCreateOREdit ${OpenCreateOrEditPage}[${openType}]
+ FOR ${element} IN @{elementList}
+ ${type} Get From Dictionary ${element} type
+ ${elementId} Get From Dictionary ${element} position
+ ${value} Get From Dictionary ${element} value
+ ${elementValue} Get From Dictionary ${pData} ${value}
+ ${return} ${elementData} Run Keyword And Ignore Error Get From Dictionary ${element} data
+ ${elementData} Run Keyword If "${return}"=="FAIL" or "${elementData}"=="${EMPTY}" set variable null
+ ... ELSE set variable ${elementData}
+ ${return} ${default} Run Keyword And Ignore Error Get From Dictionary ${element} default
+ ${default} Run Keyword If "${return}"=="FAIL" or "${default}"=="${EMPTY}" set variable null
+ ... ELSE set variable ${default}
+ Operation ${type} ${elementId} ${elementValue} ${elementData} ${default}
+ END
+
+OpenCreateOREdit
+ [Arguments] ${menuIdList}
+ [Documentation] 点击新增或修改按钮
+ ... ${menuIdList}:打开目标界面需要点击的所有按钮,顺序输入
+
+ FOR ${menuId} IN @{menuIdList}
+ sleep ${sleep}
+ #Wait Until Element Is Enabled id=${menuId} ${sleep_Wait}
+ click element ${menuId}
+ END
+ sleep ${sleep}
+
+Operation
+ [Arguments] ${type} ${positioning} ${dataValue}=null ${elementData}=null ${default}=null
+ [Documentation] 根据type进行操作
+ ... ${type}:操作类型
+ ... ${positioning}:操作的元素定位信息
+ ... ${dataValue}:输入、或者上传的数据信息
+ ... ${elementData} : 模板中的PageData中的data数据,当数据为嵌套数据时有该字段
+
+ Run Keyword If "${type}" == "input" input text ${positioning} ${dataValue}
+ ... ELSE IF "${type}" == "upload" Choose File ${positioning} ${path}data/scriptfile/${dataValue}
+ ... ELSE IF "${type}" == "combination" run keywords log 嵌套操作
+ ... AND OperatCombinationData ${dataValue} ${elementData} ${positioning}
+ ... ELSE IF "${type}" == "click" click element ${positioning}
+ ... ELSE IF "${type}" == "switch" run keywords log 开关按钮
+ ... AND SwitchButton ${positioning} ${dataValue} ${default}
+ ... ELSE IF "${type}" == "switchCombination" run keywords log 开关按钮,关闭或打开时进行操作
+ ... AND SwitchCombination ${positioning} ${dataValue} ${default} ${elementData}
+ ... ELSE IF "${type}" == "radioButton" log 单选按钮
+ ... AND RadioButton ${dataValue} ${elementData}
+ ... ELSE log 无法识别的类型
+ sleep ${sleep}
+
+OperatCombinationData
+ [Arguments] ${elementValue} ${templateData} ${positioning}
+ [Documentation] 多步骤嵌套动作方法,循环取出数据
+ ... ${elementValue}:数据文件中嵌套操作数据
+ ... ${templateData}:模板文件中嵌套数据data数据
+
+ FOR ${element} IN @{elementValue}
+ click element ${positioning}
+ sleep ${sleep}
+ ${elementList} create list ${element}
+ OperatCombination ${elementList} ${templateData}
+ END
+
+
+OperatCombination
+ [Arguments] ${elementValue} ${templateData}
+ [Documentation] 多步骤嵌套动作方法,递归执行该方法
+ ... ${elementValue}:数据文件中嵌套操作数据
+ ... ${templateData}:模板文件中嵌套数据data数据
+ ${dataValue} Set variable
+ ${dataValueKey} Set variable
+ FOR ${element} IN @{elementValue}
+ log ${element}
+ ${dataType} dataType ${element}
+ ${dataValue} Run keyword if "${dataType}" == "<class 'dict'>" get dictionary keys ${element}
+ log ${dataValue}
+ ${dataValueKey} Run keyword if "${dataType}" == "<class 'dict'>" Set variable ${dataValue}[0]
+ ... ELSE Set Variable ${element}
+ log ${dataValueKey}
+ ${re} CombinationLate ${templateData} ${dataValueKey}
+ ${type} Get From Dictionary ${re} type
+ ${elementId} Get From Dictionary ${re} position
+ ${data} Get From Dictionary ${re} data
+ log ${dataType}
+ ${value} Run keyword if "${dataType}" == "<class 'dict'>" Get From Dictionary ${element} ${dataValueKey}
+ ... ELSE IF "${dataType}" == "<class 'str'>" Set Variable null
+ ... ELSE log 非类型
+ log ${dataType}
+ # ${value} Get From Dictionary ${element} ${dataValueKey}
+ Operation ${type} ${elementId} ${value} ${data}
+ ${listType} dataType ${value}
+ log ${listType}
+ Run keyword if "${listType}" != "<class 'str'>" OperatCombination ${value} ${data}
+ END
+
+CombinationLate
+ [Arguments] ${elementData} ${dataValue}
+ [Documentation] 多步骤嵌套动作对比循环取出模板文件的value同数据文件中的值进行对比,并返回对比成功的key值
+
+ ${re} Set variable
+ FOR ${i} IN @{elementData}
+ ${re} Run keyword if "${i}[value]" == "${dataValue}" Set variable ${i}
+ END
+ [Return] ${re}
+
+SwitchButton
+ [Arguments] ${positioning} ${dataStatus} ${default}
+ [Documentation] 单选按钮操作
+ ... ${positioning}:单选按钮定位信息
+ ... ${dataStatus}:数据中按钮的状态
+ ... ${default}:模板中按钮的默认状态
+ Run Keyword If "${dataStatus}" == "${default}" log 状态相同不进行操作
+ ... ELSE click element ${positioning}
+
+SwitchCombination
+ [Arguments] ${positioning} ${datalist} ${default} ${elementData}
+ [Documentation] 开关按钮组合操作,关闭或打开时进行下一步操作
+ ... ${positioning}: 开关按钮定位信息
+ ... ${datalist}:数据中按钮的状态
+ ... ${default}:模板中按钮的默认状态
+ ... ${elementData}:模板中的PageData中的data数据,按钮状态改变进行下一步操作
+ FOR ${dataStatus} IN @{datalist}
+ ${dataType} dataType ${dataStatus}
+ ${dataValue} Run keyword if "${dataType}" == "<class 'dict'>" get dictionary keys ${dataStatus}
+ log ${dataValue}
+ ${dataValueKey} Run keyword if "${dataType}" == "<class 'dict'>" Set variable ${dataValue}[0]
+ ... ELSE IF Set Variable ${element}
+ ${data} Run keyword if "${dataType}" == "<class 'dict'>" Set variable ${dataStatus}[dataValueKey]
+ Run Keyword If "${dataValueKey}" == "${default}" log 状态相同不进行操作
+ ... ELSE SwitchCombinationOperation ${positioning} ${elementData} ${data}
+ END
+
+SwitchCombinationOperation
+ [Arguments] ${positioning} ${elementData} ${dataValue}
+ [Documentation] 根据开关状态进行下一步操作
+ ... ${positioning}:开关按钮定位信息
+ ... ${elementData}:模板中的PageData中的data数据,按钮状态改变进行下一步操作
+ ... ${dataValue} :数据文件中的操作数据
+ click element ${positioning}
+ sleep ${sleep}
+ ${type} Get From Dictionary ${elementData} type
+ ${elementId} Get From Dictionary ${elementData} position
+ ${data} Get From Dictionary ${elementData} data
+ ${value} Get From Dictionary ${elementData} value
+ Operation ${type} ${elementId} ${dataValue} ${data}
+
+RadioButton
+ [Arguments] ${dataValue} ${elementData}
+ [Documentation] 单选按钮操作
+ ... ${dataValue}:数据文件中单选按钮的名称
+ ... ${elementData}:模板中所有单选按钮的数据
+ FOR ${button} IN @{elementData}
+ ${type} Get From Dictionary ${button} type
+ ${position} Get From Dictionary ${button} position
+ ${value} Get From Dictionary ${button} value
+ Run Keyword If "${dataValue}" == "${value}" run keywords log 点击${value}按钮
+ ... AND Operation ${type} ${position}
+ END
+
+OkOrCancel
+ [Arguments] ${elementList} ${assertName}
+ [Documentation] 提交数据后校验
+ ... ${elementList}: 模板文件中OkOrCancel数据,用于点击ok按钮及创建成功校验
+ ... ${assertName}:断言数据
+ ... ${elementList}格式:[{id=responsepages_profileName1,value=testname}]
+
+ ${okBUutton} Get From Dictionary ${elementList} position
+ ${alerm} Get From Dictionary ${elementList} alerm
+ ${assertPosition} Get From Dictionary ${elementList} assertPosition
+ click element ${okBUutton} #点击OK缇交
+ Wait Until Element Is Enabled ${alerm} ${sleep_Wait}
+ Search ${assertName} name #搜索框的关键字
+ sleep ${sleep}
+ click element ${assertPosition}
+ ${text1} Get Text ${assertPosition} #获取点击后页面文本信息
+ Should Be Equal As Strings ${text1} ${assertName}
+
+Search
+ [Arguments] ${value} ${search}
+ [Documentation]
+ ... ${value}:传入查询的数据
+ ... ${search}:传入搜索框查询的类型
+
+ sleep ${sleep}
+ click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[1]/span/div/div/div[2]/div/div/div/input #点击搜索框
+ sleep ${sleep_min}
+ run keyword if "${search}"=="name" run keywords sleep ${sleep_min}
+ ... AND click element xpath=/html/body/div/div[1]/div[1]/ul/li[3]
+ ... AND input text xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[1]/span/div/div/div[2]/div/div[1]/div[3]/div/input ${value}
+ sleep ${sleep}
+ click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[1]/span/div/i #点击搜索按钮
+ sleep ${sleep}
+
+DeleteData
+ [Arguments] ${position}
+ [Documentation] 删除测试数据
+ ... ${position}:删除按钮元素定位
+ sleep ${sleep}
+ click element ${position}
+ sleep ${sleep}
+ click element xpath=/html/body/div/div/div[3]/button[2]
+ sleep ${sleep}
+
diff --git a/keyword/profiles/profiles.robot b/keyword/profiles/profiles.robot new file mode 100644 index 0000000..3953d9f --- /dev/null +++ b/keyword/profiles/profiles.robot @@ -0,0 +1,69 @@ +*** Settings ***
+Library Selenium2Library
+Library Collections
+Resource ../../variable/common_variable.txt
+
+*** Keywords ***
+ResponsePage
+ [Arguments] ${createOrEdit} ${name} ${filePath}
+ [Documentation]
+ ... ${createOrEdit}: 传入 “Create” 或者 “Edit” 来判断新建或者修改
+ ... ${name}:新建页面name输入框里的内容
+ ... ${filePath}:上传文件所在本地的路径
+
+ Run Keyword If "${createOrEdit}" == "Create" Run Keywords sleep 1
+ ... AND click element id=children6 #点击一级目录Settings
+ ... AND sleep ${sleep}
+ ... AND click element id=sidebarProxy_Profiles #点击二级目录Proxy Profiles
+ ... AND Wait Until Element Is Enabled id=responseAdd ${sleep_Wait}
+ ... AND click element id=responseAdd
+ Run Keyword If "${createOrEdit}" == "Edit" Run keywords sleep 1
+ ... AND click element xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1]
+ ... AND sleep ${sleep}
+ ... AND click element id=resinseEdit
+ sleep ${sleep}
+ input text id=responsepages_profileName1 ${name} #输入name
+ Choose File xpath=//*[@id="policy_Manipulation_create6"]/div[2]/form/div/div/div/div/input ${filePath} #上传文件
+ sleep ${sleep}
+ click element id=responseAddOk1 #点击OK缇交
+ Wait Until Element Is Enabled id=responseAdd ${sleep_Wait}
+ Search ${name} name #搜索框的关键字
+ sleep ${sleep}
+ ${text1} Get Text xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr/td[2]/div/div/span #获取点击后页面文本信息
+ Should Be Equal As Strings ${text1} ${name}
+
+
+Search
+ [Arguments] ${value} ${search}
+ [Documentation]
+ ... ${value}:传入查询的数据
+ ... ${search}:传入搜索框查询的类型
+ sleep ${sleep}
+ click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[1]/span/div/div/div[2]/div/div/div/input #点击搜索框
+ sleep ${sleep_min}
+ run keyword if "${search}"=="name" run keywords sleep ${sleep_min}
+ ... AND click element xpath=/html/body/div/div[1]/div[1]/ul/li[3]
+ ... AND input text xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[1]/span/div/div/div[2]/div/div[1]/div[3]/div/input ${value}
+ sleep ${sleep}
+ click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[1]/span/div/i #点击搜索按钮
+ sleep ${sleep}
+
+Delete
+ click element xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1]
+ sleep ${sleep}
+ click element id=resinseDel
+ sleep ${sleep}
+ click element xpath=/html/body/div/div/div[3]/button[2]
+ sleep ${sleep}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/other/all_flow_case_variable.txt b/other/all_flow_case_variable.txt new file mode 100644 index 0000000..847d3e8 --- /dev/null +++ b/other/all_flow_case_variable.txt @@ -0,0 +1,5 @@ +*** Variables ***
+
+${deny_http_objectId19} 59367
+${deny_http_policyId11} 31543
+${testClentIpId} 104964
diff --git a/other/data/profiles/Create-Response_Pages-test-2.htm b/other/data/profiles/Create-Response_Pages-test-2.htm new file mode 100644 index 0000000..56b6510 --- /dev/null +++ b/other/data/profiles/Create-Response_Pages-test-2.htm @@ -0,0 +1 @@ +11111
\ No newline at end of file diff --git a/other/data/profiles/insert_script_data.yaml b/other/data/profiles/insert_script_data.yaml new file mode 100644 index 0000000..5874f11 --- /dev/null +++ b/other/data/profiles/insert_script_data.yaml @@ -0,0 +1,18 @@ +#ip正向用例
+insert_script_data:
+ -
+ -
+ operatingType: create
+ profileName: edittestname
+ file: insertscript/create_insert_scripts_js.js
+ Script Type:
+ -
+ js:
+ -
+ Insert on:
+ - After Page Load
+
+
+
+
+
diff --git a/other/data/profiles/response_page_data.yaml b/other/data/profiles/response_page_data.yaml new file mode 100644 index 0000000..249a71e --- /dev/null +++ b/other/data/profiles/response_page_data.yaml @@ -0,0 +1,14 @@ +#ip正向用例
+response_page_data:
+ -
+ -
+ operatingType: create
+ profileName: testname
+ file: responsepage/creat_response_pages.htm
+ -
+ operatingType: edit
+ profileName: Edittestname
+ file: responsepage/creat_response_pages.htm
+ -
+ -
+
\ No newline at end of file diff --git a/other/data/scriptfile/insertscript/create_insert_scripts_css.css b/other/data/scriptfile/insertscript/create_insert_scripts_css.css new file mode 100644 index 0000000..67f2f0b --- /dev/null +++ b/other/data/scriptfile/insertscript/create_insert_scripts_css.css @@ -0,0 +1,3 @@ +body{
+ background:red !important;
+}
\ No newline at end of file diff --git a/other/data/scriptfile/insertscript/create_insert_scripts_js.js b/other/data/scriptfile/insertscript/create_insert_scripts_js.js new file mode 100644 index 0000000..e27836d --- /dev/null +++ b/other/data/scriptfile/insertscript/create_insert_scripts_js.js @@ -0,0 +1 @@ +alert("执行javascript!");
diff --git a/other/data/scriptfile/responsepage/creat_response_pages.htm b/other/data/scriptfile/responsepage/creat_response_pages.htm new file mode 100644 index 0000000..56b6510 --- /dev/null +++ b/other/data/scriptfile/responsepage/creat_response_pages.htm @@ -0,0 +1 @@ +11111
\ No newline at end of file diff --git a/other/data/template/page_template.yaml b/other/data/template/page_template.yaml new file mode 100644 index 0000000..6fe9efa --- /dev/null +++ b/other/data/template/page_template.yaml @@ -0,0 +1,636 @@ +#ip正向用例
+response_page_page:
+ #"打开页面数据":
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings + - xpath=//*[@id="Settings"]/ul/li[1] + - id=responseAdd
+ edit:
+ - id=resinseEdit + PageData:
+ -
+ type: input
+ position: id=responsepages_profileName1
+ value: profileName
+ -
+ type: upload
+ position: xpath=//*[@id="policy_Manipulation_create6"]/div[2]/form/div/div/div/div/input
+ value: file
+ OkOrCancel:
+ position: id=responseAddOk1
+ confirm: 确认信息操作
+ alerm: id=responseAdd
+ assertPosition: xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr/td[2]/div/div/span
+
+insert_script_page:
+ #"打开页面数据":
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[1]
+ - xpath=//*[@id="profilesTabs"]/li[2]
+ - id=insertAdd
+ edit:
+ - id=insertEdit
+ PageData:
+ -
+ type: input
+ position: id=insert_profileName1
+ value: profileName
+ -
+ type: upload
+ position: xpath=//*[@id="insertAddUpload"]/div[1]/input
+ value: file
+ -
+ type: combination
+ position: id=insert_select_format
+ value: Script Type
+ data:
+ -
+ type: click
+ position: xpath=/html/body/div/div[1]/div[1]/ul/li[1]
+ value: css
+ data: null
+ -
+ type: click
+ position: xpath=/html/body/div/div[1]/div[1]/ul/li[2]
+ value: js
+ data:
+ -
+ type: click + position: id=insert_select_insertOn + value: Insert on + data: + - + type: click + position: xpath=/html/body/div[last()]/div[1]/div[1]/ul/li[1] + value: Before Page Load
+ data: null + - + type: click + position: xpath=/html/body/div[last()]/div[1]/div[1]/ul/li[2] + value: After Page Load
+ data: null
+ +
+
+
+
+ OkOrCancel:
+ position: id=insertAddOk1
+ confirm: 确认信息操作
+ alerm: id=insertAdd
+ assertPosition: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[2]/div/div[3]/table/tbody/tr[1]/td[2]/div/div/span
+ delete: id=insertDel
+
+hijack_file_page:
+ #"打开页面数据":
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[1]
+ - xpath=//*[@id="profilesTabs"]/li[3]
+ - id=hijackAdd
+ edit:
+ - id=hijackEdit
+ PageData:
+ -
+ type: input
+ position: id=hijack_profileName1
+ value: name
+ -
+ type: upload
+ position: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div/div[1]/div[2]/form/div[2]/div/div/div[1]/input
+ value: file
+ -
+ type: switchCombination
+ position: xpath=//*[@id="contentNameChoose"]/div[1]/span[2]
+ value: buttonStatus
+ default: open
+ data:
+ -
+ type: input
+ position: id=hijack_contentName
+ value: downloadName
+ -
+ type: combination
+ position: id=hijackAddContentType
+ value: combination
+ data:
+ -
+ type: click
+ position: id=image/gif0
+ value: image/gif
+ data: null
+ -
+ type: click
+ position: id=image/jpeg1
+ value: image/jpeg
+ data: null
+ -
+ type: click
+ position: id=image/png2
+ value: image/png
+ data: null
+ -
+ type: click
+ position: id=image/svg+xml3
+ value: image/svg+xml
+ data: null
+ -
+ type: click
+ position: id=application/x-msdos-program0
+ value: application/x-msdos-program
+ data: null
+ -
+ type: click
+ position: id=application/vnd.android.package-archive0
+ value: application/vnd.android.package-archive
+ data: null
+ -
+ type: click
+ position: id=text/html0
+ value: text/html
+ data: null
+
+ OkOrCancel:
+ position: id=hijackAddOk1
+ confirm: 确认信息操作
+ alerm: id=hijackAdd
+ assertPosition: xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1]/td[2]/div/span
+
+traffic_mirror_profile_page:
+ #"打开页面数据":
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[1]
+ - xpath=//*[@id="profilesTabs"]/li[4]
+ - id=trafficMirrorAdd
+ edit:
+ - id=trafficMirrorEdit
+ PageData:
+ -
+ type: input
+ position: id=trafficmirror_profileName1
+ value: profileName
+ -
+ type: input
+ position: id=trafficmirror_profileName1
+ value: profileName
+ -
+ type: combination
+ position: id=addrTypeChoose
+ value: combination
+ data:
+ -
+ type: click
+ position: xpath=/html/body/div[2]/div[1]/div[1]/ul/li[1]
+ value: vlan
+ data: null
+ -
+ type: click
+ position: xpath=/html/body/div[2]/div[1]/div[1]/ul/li[2]
+ value: mac
+ data: null
+ -
+ type: input
+ position: id=trafficmirror_addrArray0
+ value : vlan/mac
+ OkOrCancel:
+ position: id=trafficMirrorProfile_ok
+ confirm: 确认信息操作
+ alerm: id=trafficMirrorAdd
+ assertPosition: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div[1]/div/div[2]/div/div[3]/table/tbody/tr[1]/td[2]/div/div/span
+
+decryption_profile_page:
+ #"打开页面数据":
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[1]
+ - xpath=//*[@id="profilesTabs"]/li[5]
+ - id=insertAdd
+ edit:
+ - id=insertEdit
+ PageData:
+ -
+ type: input
+ position: id=decrytion_profileName1
+ value : name
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[3]/div[1]/div/div/span
+ value: Common Name
+ default: open
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[3]/div[2]/div/div/span
+ value: Issuer
+ default: open
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[3]/div[3]/div/div/span
+ value: Self-signed
+ default: open
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[3]/div[4]/div/div/span
+ value: Expiry Date
+ default: open
+ -
+ type: radioButton
+ value: Fail Action
+ data:
+ -
+ type: click
+ position: id=decryptionfail-close
+ value: Fail-close
+ -
+ type: click
+ position: id=decryptionpass-through
+ value: Pass-through
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[5]/div[1]/div/div/span
+ value: EV Certificate
+ default: close
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[5]/div[2]/div/div/span
+ value: Certificate Transparency
+ default: close
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[5]/div[3]/div/div/span
+ value: Mutual Authentication
+ default: open
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[5]/div[4]/div/div/span
+ value: On Protocol Errors
+ default: open
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[5]/div[5]/div/div/span
+ value: Certificate Pinning
+ default: open
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[5]/div[6]/div/div/span
+ value: Certificate Not Installed
+ default: open
+ -
+ type: switchCombination
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[7]/div[1]/div/div/span
+ value: Mirror Client Versions
+ default: open
+ data:
+ -
+ type: combination
+ position: id=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[7]/div[2]/div/div/div/span/span/i
+ value: Min Version
+ data:
+ -
+ type: click
+ position: id=pro_min0
+ value: SSLv3.0
+ data: null
+ -
+ type: click
+ position: id=pro_min1
+ value: TLSv1.0
+ data: null
+ -
+ type: click
+ position: id=pro_min2
+ value: TLSv1.1
+ data: null
+ -
+ type: click
+ position: id=pro_min3
+ value: TLSv1.2
+ data: null
+ -
+ type: click
+ position: id=pro_min4
+ value: TLSv1.3
+ data: null
+ -
+ type: combination
+ position: id=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[7]/div[3]/div/div/div[1]/span/span/i
+ value: Max Version
+ data:
+ -
+ type: click
+ position: id=pro_min0
+ value: SSLv3.0
+ data: null
+ -
+ type: click
+ position: id=pro_min1
+ value: TLSv1.0
+ data: null
+ -
+ type: click
+ position: id=pro_min2
+ value: TLSv1.1
+ data: null
+ -
+ type: click
+ position: id=pro_min3
+ value: TLSv1.2
+ data: null
+ -
+ type: click
+ position: id=pro_min4
+ value: TLSv1.3
+ data: null
+ -
+ type: switch
+ position: xpath=//*[@id="policy_Manipulation_create8"]/div[2]/form/div[7]/div[4]/div/div/span
+ value: Allow HTTP/2
+ default: open
+ OkOrCancel:
+ position: id=decryption-ok + confirm: 确认信息操作 + alerm: id=insertAdd + assertPosition: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div/div/div[2]/div/div[3]/table/tbody/tr[2]/td[2]/div/div/span
+
+dns_record_profile_page:
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[1]
+ - xpath=//*[@id="profilesTabs"]/li[6]
+ - id=DNSAdd
+ edit:
+ - id=DNSEdit
+ PageData:
+ -
+ type: input
+ position: id=objectAdd_name
+ value : name
+ -
+ type: radioButton
+ position: null
+ value: type
+ data:
+ -
+ type: click
+ position: id=objectAdd_ip0
+ value: A
+ -
+ type: click
+ position: id=objectAdd_ip1
+ value: AAAA
+ -
+ type: click
+ position: id=objectAdd_ip2
+ value: CNAME
+ -
+ type: combination
+ position: id=temporary_form
+ value: Values
+ data:
+ -
+ type: input
+ position: xpath=//*[@id="Profile_DNSRecordProfile"]/div/div[2]/div/div/form/div[3]/div/div[1]/div[2]/div[1]/div/div[last()]/div/div[1]/div[1]/div/div[2]/div/input
+ value: ip
+ data: 192.168.50.32
+ -
+ type: input
+ position: xpath=//*[@id="Profile_DNSRecordProfile"]/div/div[2]/div/div/form/div[4]/div/div/textarea
+ value : Description
+ OkOrCancel:
+ position: id=wanAdd_ok
+ confirm: 确认信息操作
+ alerm: id=DNSAdd
+ assertPosition: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[2]/div[1]/div/div[2]/div/div[3]/table/tbody/tr[1]/td[2]/div/div/span
+
+snat_ip_pools_page:
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[2]
+ - id=ip
+ - id=app_create
+ edit:
+ - id=appEdit
+ PageData:
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_color"]/form/div[1]/div/div/div[1]/input
+ value : name
+ -
+ type: combination
+ position: id=temporary_form
+ value: ip
+ data:
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_color"]/form/div[3]/div/div/div[2]/div[1]/div/div/div[1]/div[1]/div/div[2]/div/input
+ value: ip
+ data: null
+ -
+ type: click
+ position: id=wan_reach_test
+ value: reachability_test
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_color"]/form/div[5]/div/div/textarea
+ value: description
+ OkOrCancel:
+ position: id=wanAdd_ok
+ confirm: 确认信息操作
+ alerm: id=app_create
+ assertPosition: xpath=//*[@id="wannat-table"]/div[3]/table/tbody/tr[1]/td[3]/div/div
+
+vpn_accounts_page:
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[2]
+ - id=account
+ - id=app_create
+ edit:
+ - id=appEdit
+ PageData:
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_username"]/div/div/div[1]/input
+ value : vpn_name
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_password"]/div/div/input
+ value: password
+ OkOrCancel:
+ position: id=wanAdd_ok
+ confirm: 确认信息操作
+ alerm: id=app_create
+ assertPosition: xpath=//*[@id="wannat-table"]/div[3]/table/tbody/tr[1]/td[1]/div/div/div[2]/span
+
+test_server_page:
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[2]
+ - id=testserver
+ - id=app_create
+ edit:
+ - id=appEdit
+ PageData:
+ -
+ type: input
+ position: xpath=//*[@id="profileName"]/div[1]/input
+ value: name
+ -
+ type: combination
+ position: xpath=//*[@id="wannat_vpn_testserver"]/form/div[2]/div/div/div[1]/span/span/i
+ value: server_type
+ data:
+ -
+ type: click
+ position: xpath=/html/body/div[2]/div[1]/div[1]/ul/li[1]
+ value: dns
+ data: null
+ -
+ type: click
+ position: xpath=/html/body/div[2]/div[1]/div[1]/ul/li[2]
+ value: tcp
+ data: null
+ -
+ type: click
+ position: xpath=/html/body/div[2]/div[1]/div[1]/ul/li[3]
+ value: icmp
+ data: null
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_testserver"]/form/div[3]/div/div[1]/input
+ value: ip
+ -
+ type: combination
+ position: xpath=//*[@id="wannat_vpn_testserver"]/form/div[4]/div/div/div/span/span/i
+ value: server_relative_location
+ data:
+ -
+ type: click
+ position: xpath=/html/body/div[3]/div[1]/div[1]/ul/li[1]
+ value: Internal
+ data: null
+ -
+ type: click
+ position: xpath=/html/body/div[3]/div[1]/div[1]/ul/li[2]
+ value: External
+ data: null
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_password"]/div/div/input
+ value: server_location
+ -
+ type: input
+ position: xpath=//*[@id="wannat_vpn_testserver"]/form/div[6]/div/div/textarea
+ value: description
+ -
+ type: switch
+ position: xpath=//*[@id="wannat_vpn_testserver"]/form/div[7]/div/div/span
+ value: isvalid
+ default: open
+ OkOrCancel:
+ position: id=wanAdd_ok
+ confirm: 确认信息操作
+ alerm: id=app_create
+ assertPosition: xpath=//*[@id="wannat-table"]/div[3]/table/tbody/tr[1]/td[2]/div/div
+
+trusted_certificate_authorities_page:
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[3]
+ - xpath=//*[@id="proxyTabs"]/div/ul/li[1]
+ - id=app_create
+ edit:
+ - id=appEdit
+ PageData:
+ -
+ type: input
+ position: id=authoritiesAdd_name1
+ value: name
+ -
+ type: upload
+ position: xpath=//*[@id="upload_dome"]/div/input
+ value: file
+ OkOrCancel:
+ position: id=authoritiesAdd_sub
+ confirm: 确认信息操作
+ alerm: id=app_create
+ assertPosition: xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1]/td[2]/div/div/div/p/span
+
+decryption_keyrings_page:
+ OpenCreateOrEditPage:
+ create:
+ - id=Settings
+ - xpath=//*[@id="Settings"]/ul/li[3]
+ - xpath=//*[@id="proxyTabs"]/div/ul/li[2]
+ - id=app_create
+ edit:
+ - id=appEdit
+ PageData:
+ -
+ type: input
+ position: id=keyringsadd_name1
+ value: name
+ -
+ type: upload
+ position: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div/div[2]/div[2]/form/div[2]/div/div/div/input
+ value: certificate
+ -
+ type: combination
+ position: id=privateFile
+ value: private_key
+ data:
+ -
+ type: click
+ position: xpath=/html/body/div[3]/div[1]/div[1]/ul/li[1]
+ value: Private Key File
+ data:
+ -
+ type: upload
+ position: xpath=//*[@id="app"]/div/div[3]/div[2]/div/div/div[2]/div[2]/form/div[3]/div/div[2]/div/div/input
+ value: key_file
+ data: null
+ -
+ type: click
+ posotion: id=privateHSM
+ value: HSM
+ data:
+ -
+ type: input
+ position: id=keyringsadd_slotid
+ value: Slot ID
+ data: null
+ -
+ type:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/other/data/template/response_page_template.yaml b/other/data/template/response_page_template.yaml new file mode 100644 index 0000000..68ee0d6 --- /dev/null +++ b/other/data/template/response_page_template.yaml @@ -0,0 +1,23 @@ +#ip正向用例
+response_page_page:
+ #"打开页面数据":
+ OpenCreateOrEditPageIds:
+ create:
+ - id=children6 + - id=sidebarProxy_Profiles + - id=responseAdd
+ edit:
+ - id=responseAdd d + PageData:
+ -
+ type: input
+ id: id=responsepages_profileName1
+ name: profileName
+ -
+ type: upload
+ id: xpath=//*[@id="policy_Manipulation_create6"]/div[2]/form/div/div/div/div/input
+ name: file
+ OkOrCancel:
+ id: responseAddOk1
+ confirm: 确认信息操作
+ alerm: Sucess
\ No newline at end of file diff --git a/other/scriptfile/responsepage/creat_response_pages.htm b/other/scriptfile/responsepage/creat_response_pages.htm new file mode 100644 index 0000000..56b6510 --- /dev/null +++ b/other/scriptfile/responsepage/creat_response_pages.htm @@ -0,0 +1 @@ +11111
\ No newline at end of file diff --git a/other/write_file.txt b/other/write_file.txt new file mode 100644 index 0000000..3e0d080 --- /dev/null +++ b/other/write_file.txt @@ -0,0 +1,97 @@ +C:/Users/admin/git/tsg_autotest/05-Other/curl/test1.bat%%%%%%%%%%%%%%newbat
+C:\Users\admin\git\tsg_autotest>curl -kv https://wrong.host.badssl.com/ | iconv -f utf-8 -t gbk
+ % Total % Received % Xferd Average Speed Time Time Time Current
+ Dload Upload Total Spent Left Speed
+
+ 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 104.154.89.105:443...
+* TCP_NODELAY set
+* Connected to wrong.host.badssl.com (104.154.89.105) port 443 (#0)
+* ALPN, offering h2
+* ALPN, offering http/1.1
+} [5 bytes data]
+* TLSv1.3 (OUT), TLS handshake, Client hello (1):
+} [512 bytes data]
+* TLSv1.3 (IN), TLS handshake, Server hello (2):
+{ [108 bytes data]
+* TLSv1.2 (IN), TLS handshake, Certificate (11):
+{ [2897 bytes data]
+* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
+{ [333 bytes data]
+* TLSv1.2 (IN), TLS handshake, Server finished (14):
+{ [4 bytes data]
+* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
+} [70 bytes data]
+* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
+} [1 bytes data]
+* TLSv1.2 (OUT), TLS handshake, Finished (20):
+} [16 bytes data]
+
+ 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* TLSv1.2 (IN), TLS handshake, Finished (20):
+{ [16 bytes data]
+* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
+* ALPN, server accepted to use http/1.1
+* Server certificate:
+* subject: C=US; ST=California; L=Walnut Creek; O=Lucas Garron Torres; CN=*.badssl.com
+* start date: Mar 23 00:00:00 2020 GMT
+* expire date: May 17 12:00:00 2022 GMT
+* issuer: C=US; O=DigiCert Inc; CN=DigiCert SHA2 Secure Server CA
+* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
+} [5 bytes data]
+> GET / HTTP/1.1
+
+> Host: wrong.host.badssl.com
+
+> User-Agent: curl/7.67.0
+
+> Accept: */*
+
+>
+
+{ [5 bytes data]
+* Mark bundle as not supporting multiuse
+< HTTP/1.1 200 OK
+
+< Server: nginx/1.10.3 (Ubuntu)
+
+< Date: Fri, 07 May 2021 03:43:33 GMT
+
+< Content-Type: text/html
+
+< Content-Length: 500
+
+< Last-Modified: Tue, 23 Feb 2021 21:28:41 GMT
+
+< Connection: keep-alive
+
+< ETag: "60357389-1f4"
+
+< Cache-Control: no-store
+
+< Accept-Ranges: bytes
+
+<
+
+{ [500 bytes data]
+
+100 500 100 500 0 0 531 0 --:--:-- --:--:-- --:--:-- 540
+* Connection #0 to host wrong.host.badssl.com left intact
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="shortcut icon" href="/icons/favicon-red.ico"/>
+ <link rel="apple-touch-icon" href="/icons/icon-red.png"/>
+ <title>wrong.host.badssl.com</title>
+ <link rel="stylesheet" href="/style.css">
+ <style>body { background: red; }</style>
+</head>
+<body>
+<div id="content">
+ <h1 style="font-size: 12vw;">
+ wrong.host.<br>badssl.com
+ </h1>
+</div>
+
+</body>
+</html>
\ No newline at end of file diff --git a/variable/all_flow_case_variable.txt b/variable/all_flow_case_variable.txt new file mode 100644 index 0000000..c742ffc --- /dev/null +++ b/variable/all_flow_case_variable.txt @@ -0,0 +1 @@ +*** Variables *** diff --git a/variable/common_variable.txt b/variable/common_variable.txt new file mode 100644 index 0000000..c5c395f --- /dev/null +++ b/variable/common_variable.txt @@ -0,0 +1,95 @@ +*** Variables ***
+#登录类型:api | cli | ${None}(tsg mib) | 未指定,默认为ui
+${loginType} ui
+#执行环境是否Widonws
+${systemType} Windows
+#API配置信息
+${host} 192.168.44.72
+${port} 8080
+${authmode} 1
+${authCode} ${EMPTY}
+${ldapId} 27
+${version} v1
+${version2} v2
+${username} byb
+${password} 111111
+${encodePassword} ${EMPTY}
+${token} ${EMPTY}
+#[Documentation] 测试终端IP统一配置
+${testClentIP} 192.168.50.19
+${testSubscriberID} $test19
+#自动化标签
+${userTagIds} ${EMPTY}
+#Documentation] 是否添加测试终端IP到策略统一配置,0为不添加测试终端IP,1为添加测试终端IP,默认1
+${addTestClentIPFlag} 1
+#测试环境是否需要把tsgui和api添加为SecurityPolicy-Allow 1为需要,默认1 ,
+${addTsgUIAPIFlag} 1
+#执行需要暂停时间
+#策略下发后到验证需等待时间
+${policyVerificationSleepSeconds} 20
+#策略验证后到验证策略日志需等待时间
+${policyLogVerificationSleepSeconds} 60
+${path} C:/Users/admin/Desktop/sql/gap_tsg_ui/other/
+${Downloadpath} C:/Users/byb11/Downloads/
+${curlbatpath} ${path}curl/
+${mailpath} ${path}/mail/
+${responsePageFiles} ${path}/response_pages_files/
+#全流程分阶段测试参数
+#[Documentation] 当前测试部分,all为一个终端全网全流程测试,
+#1为添加策略和对象测试;
+#2为功能端业务验证部分测试;
+#3为llog日志验证测试
+${testPart} all
+#UI配置的本地IP名称
+${LocahIPName} ${EMPTY}
+${ipType} ipv4
+${ipMask} 255.255.255.255
+${browserType} chrome
+# Cli自动化测试变量[start]
+${cliHost} 192.168.40.165
+${cliUsername} tsgadmin
+${cliPassword} Cli2019
+${timeout} 600s
+${retryInterval} 300s
+@{PolicyTypes} tsg_security pxy_manipulation
+@{ObjectTypes} ip url fqdn keywords subscriberid fqdn_category account
+... http_signature
+# Cli自动化测试变量[end]
+# SNMP服务测试变量[start]
+${snmpHost} 192.168.40.165
+${snmpPort} 50161
+${snmpConnTimeout} 5 # 默认超时时间为6s,设置timeout值后超时时间为n*6s
+${snmpCommunity} public
+# SNMP服务测试变量[end]
+#API配置信息
+${oamHost} 192.168.40.210
+${oamPort} 50080
+${contrast} 0.1
+${editpasswd} no #设置密码过期时是否需要修改密码,no为不修改,yes为修改
+# Mysql数据库连接信息
+${mysqlHost} host='192.168.44.72',port=3306,user='root',passwd='bifang!@#',database='tsg-bifang'
+#休息时间
+${sleep_min} 1
+${sleep} 3
+# 隐式等待时间
+${sleep_Wait} 20
+#name个人标识
+${tag} lyf
+#日志查询次数
+${logfornumber} 3
+#邮箱账户信息
+${mailAccount163Dxy} [email protected]
+${mailPasswordDxy} CXFBCUSBOZCWSMRW
+${mailAccount163Lyf} [email protected]
+${mailPasswordLyf} XEYQVHEMTOBOJSAP
+
+#GTP协议添加到策略中字段
+${imsi} 11235666*
+${phone_number1} 1384487*
+${phone_number2} *0339
+${phone_number3} 4487
+${phone_number4} $13844870339
+${apn1} $huawei
+${apn2} *uawei
+#是否添加策略,添加策略则调用sql加载相关配置,默认为1
+${addPolicy} 0
\ No newline at end of file diff --git a/variable/config.yml b/variable/config.yml new file mode 100644 index 0000000..342e845 --- /dev/null +++ b/variable/config.yml @@ -0,0 +1,38 @@ +#待执行的产品项目, Cloud -云项目; rfcode -执行所有的项目
+https://www.cnblogs.com/jun-zi/p/12055300.html
+ProductItem: Cloud
+
+#待执行的测试套件(标签), all -所有的测试套件: debug -调试中套件; login -登录功能 ; filter -账号筛选: P1 -一级用例
+testSuite: P1
+
+#测试报告标题
+testReportTitle: Cloud_Report
+
+#失败重试开关, 0 -关, 1 -开 ,开启后默认重试一次
+retry_switch: 0
+#失败重试次数
+retryTime: 1
+
+#发送测试报告邮件开关, 0 -关, 1 -开
+emailSwitch: 1
+
+#邮件配置
+#发件邮箱
+smtp_server: smtp.126.com
+server_username: [email protected]
+server_pwd: XXXXXX
+#收件人(列表)
+msg_to:
+
+#邮件主题
+msg_subject: '[XX项目][测试环境-develop][jira号][自动化测试报告]'
+
+#日志级别(字典),由高到低: CRITICAL 、 ERROR 、 WARNING 、 INFO 、 DEBUG
+log:
+ file_name: test.log
+ backup: 5
+ console_level: DEBUG #控制台日志级别
+ file_level: DEBUG #文件日志级别
+ pattern: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
\ No newline at end of file diff --git a/variable/file_operation.robot b/variable/file_operation.robot new file mode 100644 index 0000000..44eca35 --- /dev/null +++ b/variable/file_operation.robot @@ -0,0 +1,36 @@ +*** Settings *** +Library String +Library json +Library OperatingSystem +Library RequestsLibrary +Library Selenium2Library +Library Collections +Library FileLibrary +Resource ../common.robot +Resource ../../../variable/common_variable.txt + +*** Keywords *** +insert_policyId_to_file + [Arguments] ${key} ${policyId} ${objectids} + ${dict} Create Dictionary policyId=${policyId} objectId=${objectids} + ${json} json.Dumps ${dict} + Alter Dict ${path}/variable/AllFlowCaseVariable.txt ${key} ${json} + +insert_time_to_file + [Arguments] ${key} ${starttime} ${endtime} + ${value} json.Loads ${${key}} + ${dict} Create Dictionary policyId=${value}[policyId] objectId=${value}[objectId] starttime=${starttime} endtime=${endtime} + ${json} json.Dumps ${dict} + Alter Dict ${path}/variable/AllFlowCaseVariable.txt ${key} ${json} + +insert_policyId_to_file1 + [Arguments] ${key} ${objectids} + Alter Dict ${path}/all_flow_case_variable.txt ${key} ${objectids} + +insert_time_to_file1 + [Arguments] ${key} ${starttime} + Alter Dict ${path}/AllFlowCaseVariable1.txt ${key} ${starttime} + +insert_Report_to_file1 + [Arguments] ${key} ${objectids} + Alter Dict ${path}/ReportCaseVariable.txt ${key} ${objectids} diff --git a/variable/policy_object_default.txt b/variable/policy_object_default.txt new file mode 100644 index 0000000..d38e644 --- /dev/null +++ b/variable/policy_object_default.txt @@ -0,0 +1,53 @@ +*** Variables ***
+# 通用
+${Default_IsValid} ${1}
+${Default_IsDelete} false
+
+# 策略
+${Default_PolicyName} autotest_policy
+${Default_PolicyType} tsg_security
+${Default_PolicyDesc} autotest
+${Default_Action} deny
+${Default_PolicySubAction} drop
+${Default_EffectiveRange}
+${Default_UserRegion} method:rst
+${Default_ReferenceObject} ${EMPTY}
+${Default_AppObjectIdArray} []
+${Default_UserTags} ${EMPTY}
+${Default_DoLog} ${1}
+${Default_ScheduleId} ${EMPTY}
+#策略v2
+${Default_v2_SourceObject} ${EMPTY}
+${Default_v2_DestinationObject} ${EMPTY}
+${Default_v2_FilterObject} ${EMPTY}
+# 对象
+${Default_ObjectType} ip
+${Default_CategoryType} fqdn
+${Default_ObjectSubType} ${EMPTY}
+${Default_IsInitialize} ${0}
+${Default_IsExclusion} ${0}
+${Default_ObjectName} autotestobj
+${Default_ObjectDesc} autotestobj
+${Default_SubObjectIds} ${None}
+${Default_Dimension} Function
+${Default_Origin} net
+${Default_AddItem_AddrType} ${4}
+${Default_AddItem_Protocol} ${0}
+${Default_AddItem_Direction} ${0}
+${Default_AddItem_IsSession} endpoint
+${Default_AddItem_ServerIpFormat} range
+${Default_AddItem_ServerIp1} ${EMPTY}
+${Default_AddItem_ServerIp2} ${EMPTY}
+${Default_AddItem_ServerPort} ${0}/${0}
+${Default_AddItem_IsHexbin} ${0}
+${Default_AddItem_IsInitialize} ${0}
+${Default_AddItem_ItemName} ${EMPTY}
+${Default_AddItem_ItemDesc} ${EMPTY}
+#默认客户端条件类型:clientip or clientsubid or clientImsi or clientPhoneNumber or clientApn
+${Default_Client_Type} clientip
+${Default_Client_subidType} clientsubid
+${Default_Client_imsiType} clientImsi
+${Default_Client_phonenumberType} clientPhoneNumber
+${Default_Client_apnType} clientApn
+${Default_PolicyEnabled} open
+${Default_PolicyLogSession} 1
\ No newline at end of file diff --git a/variable/var.yaml b/variable/var.yaml new file mode 100644 index 0000000..86170ae --- /dev/null +++ b/variable/var.yaml @@ -0,0 +1,7 @@ +username:dongxiaoyan
+password:111111
+bifang:
+ host:192.168.44.72
+ port:8080
+ mysqlHost:host='192.168.44.71',port=3306,user='root',passwd='bifang!@#',database='tsg-bifang'
+ui:
\ No newline at end of file |
