diff --git a/Project/task3/Resources/Common.robot b/Project/task3/Resources/Common.robot new file mode 100644 index 0000000..bebe194 --- /dev/null +++ b/Project/task3/Resources/Common.robot @@ -0,0 +1,17 @@ +*** Settings *** +Library Selenium2Library +Resource Element.robot + + +*** Keywords *** +点击按钮 + [Arguments] ${button} + Set Focus To Element ${button} + Click Element ${button} + sleep 2s + +输入文本 + [Arguments] ${path} ${Text} + Set Focus To Element ${path} + Input Text ${path} ${Text} + sleep 1s diff --git a/Project/task3/Resources/Element.robot b/Project/task3/Resources/Element.robot new file mode 100644 index 0000000..8fd495a --- /dev/null +++ b/Project/task3/Resources/Element.robot @@ -0,0 +1,67 @@ +*** Variables *** +${login_slogan} id=slogan # 黑方登录页面的logo元素 +${input_userName} id=userName # 黑方登录页面用户名输入框 +${input_passwd} id=passWord # 黑方登录页面密码输入框 +${btn_login} id=login_btn # 黑方登录页面登录按钮 +${button_loginmessage} id=header_loginRecord_a # 黑方操作页面-登录记录按钮 +${button_sideNav_cdm} id=sideNav_cdm # 黑方操作页面-侧边栏-副本数据管理 +${cdm_sideNav_all} xpath=//span[text()='所有主机'] # 黑方操作页面-副本数据管理-所有主机 +${cdm_inputSuccess2} id=inputSuccess2 # 黑方操作页面-副本数据管理-代理搜索框 +${cdm_newpolicy} xpath=//span[text()='新建备份策略'] # 黑方操作页面-副本数据管理-新建备份策略 +${cdm_tab_policy_li} id=cdm_tab_policy_li # 黑方操作页面-副本数据管理-策略 +${mssql_newpolicy_title} xpath=//h4[text()='新建备份策略'] # mssql副本-新建备份策略-弹窗标题 +${mssql_newpolicy_type} xpath=//span[text()='数据库(SQLServer)'] # mssql副本-新建备份策略-mssql副本组件 +${mssql_newpolicy_goStep1} id=cdm_sqlserver_sideNav_addMode_goStep1_btn # mssql副本-新建备份策略-连接凭据 +${mssql_newpolicy_goStep1_PolicyName} id=PolicyName # mssql副本-新建备份策略-连接凭据-策略名 +${mssql_newpolicy_goStep1_nextStep2_btn} id=cdm_sqlServer_addPolicyGuide_nextStep2_btn # mssql副本-新建备份策略-连接凭据-下一步 +${mssql_newpolicy_goStep2} xpath=//h4[text()='选择sqlserver实例'] # mssql副本-新建备份策略-选择sqlserver实例 +${mssql_newpolicy_goStep2_nextStep3_btn} id=cdm_sqlServer_addPolicyGuide_backStep3_btn # mssql副本-新建备份策略-实例选择-下一步 +${mssql_newpolicy_goStep3} xpath=//h4[text()='选择目标数据库'] # mssql副本-新建备份策略-选择目标数据库 +${mssql_newpolicy_goStep3_database_all} xpath=(//span[text()='SqlServer数据库'])/../../td[2] # mssql副本-新建备份策略-目标数据库-全选 +${mssql_newpolicy_goStep3_filterBtn_btn} id=dialogues_baseFilter_filterBtn_btn # mssql副本-新建备份策略-目标数据库-过滤设置 +${mssql_newpolicy_goStep3_baseFilterSel_btn} id=dialogues_baseFilter_baseFilterSel_btn # mssql副本-新建备份策略-过滤设置-数据库过滤 +${mssql_newpolicy_goStep3_baseFilterKey_btn} id=dialogues_baseFilter_baseFilterKey_btn # mssql副本-新建备份策略-过滤设置-关键字过滤 +${mssql_newpolicy_goStep3_baseFilterKey_keyFilterCon} id=keyFilterCon # mssql副本-新建备份策略-过滤设置-关键字过滤-关键字输入框 +${mssql_newpolicy_goStep3_baseFilterKey_addkeyFilter} xpath=//button[@id='dialogues_baseFilter_filterModalSure_btn'][text()="添加"] # mssql副本-新建备份策略-过滤设置-关键字过滤-添加 +${mssql_newpolicy_goStep3_baseFilterKey_addkeyFilterSure_btn} xpath=//button[@id='dialogues_baseFilter_filterModalSure_btn'][text()="确定"] # mssql副本-新建备份策略-过滤设置-关键字过滤-确定 +${mssql_newpolicy_goStep3_nextStep4_btn} id=cdm_sqlServer_addPolicyGuide_backStep4_btn # mssql副本-新建备份策略-目标数据库-下一步 +${mssql_newpolicy_goStep4} xpath=//span[text()='设置任务周期'] # mssql副本-新建备份策略-设置任务周期 +${mssql_newpolicy_goStep4_AddTaskCycle} id=AddTaskCycle # mssql副本-新建备份策略-设置任务周期-添加任务周期 +${mssql_newpolicy_goStep4_AddTaskCycle_sunday} id=dialogues_addCycleStorage_cycleMode_sunday_checkboxInput # mssql副本-新建备份策略-设置任务周期-添加任务周期-星期日 +${mssql_newpolicy_goStep4_AddTaskCycle_Sure_btn} id=dialogues_addCycleStorage_step3_3_define_btn # mssql副本-新建备份策略-设置任务周期-添加任务周期-确定 +${mssql_newpolicy_goStep4_nextStep5_btn} id=dialogues_addCycleStorage_step3_2_next_btn # mssql副本-新建备份策略-设置任务周期-下一步 +${mssql_newpolicy_goStep5} xpath=//h4[text()='设置存储路径'] # mssql副本-新建备份策略-设置存储路径 +${mssql_newpolicy_goStep5_nextStep6_btn} id=dialogues_addCycleStorage_step3_4_nodb2_next_btn # mssql副本-新建备份策略-设置存储路径-下一步 +${mssql_newpolicy_goStep6} xpath=//h4[text()='备份高级选项'] # mssql副本-新建备份策略-备份高级选项 +${mssql_newpolicy_goStep6_next_btn} xpath=(//button[text()='完成'])[5] # mssql副本-新建备份策略-备份高级选项-完成 +${mssql_newpolicy_addsucess} xpath=//p[text()='添加成功!'] # mssql副本-新建备份策略-添加成功 +${mssql_define_btn} id=tipsPop_define_btn # mssql副本-策略-默认确定按钮 +${policy_input_backupNameSearch} id=backupNameSearch # mssql副本-策略-查询策略输入框 +${policy_btn_backContentSearch} id=cdm_tab_policy_backContent_search_btn # mssql副本-策略-查询按钮 +${policy_table_firstname} xpath=(//td[@align='left'])[2][text()] # mssql副本-策略-查询结果第一个策略名 +${policy_run} xpath=//span[text()='立即执行'] # mssql副本-策略-立即执行 +${policy_run_title} xpath=//h4[text()='立即执行策略'] # mssql副本-策略-立即执行-立即执行策略 +${policy_run_select} xpath=//select[@ng-model='selectedSrctype'] # mssql副本-策略-立即执行-选择 +${policy_run_select_type} 永久增量备份 # mssql副本-策略-立即执行-选择备份类型 +${policy_run_executePolicyExecute_btn} id=cdm_sqlServer_executePolicy_executePolicyExecute_btn # mssql副本-策略-立即执行-选择备份类型-确定 +${policy_run_msg} xpath=//p[text()='添加成功'] # mssql副本-策略-立即执行-添加成功 +${cdm_tab_work_li} id=cdm_tab_work_li # 黑方操作页面-副本数据管理-作业 +${cdm_tab_work_export_btn} id=cdm_tab_work_export_btn # 黑方操作页面-副本数据管理-导出当前作业日志 +${cdm_tab_work_PolicyName} id=workPolicyName # 黑方操作页面-副本数据管理-作业策略名称 +${cdm_tab_work_search_span} id=cdm_tab_work_workPolicyName_search_span # 黑方操作页面-副本数据管理-作业页面查询 +${task_select_count} $("#pcWorktable_cdm_outerDiv").find("tr").length # 黑方操作页面-作业详情页面-作业个数 +${task_status} $("#pcWorktable_cdm_outerDiv").find("td").eq(-2)[0].textContent # 黑方操作页面-作业详情页面-作业状态 +${cdm_tab_backupset_li} id=cdm_tab_backupset_li # 黑方操作页面-副本数据管理-副本数据 +${policy_input_backTabPolicy} id=backTabPolicy # 黑方操作页面-副本数据-副本数据管理-查询策略输入框 +${cdm_tab_backupset_search_span} id=cdm_tab_backupset_searchfilter_span # 黑方操作页面-副本数据管理-副本数据管理-查询 +${cdm_tab_recovery_step1} xpath=//label[text()='选择需要恢复到的主机:'] # 黑方操作页面-副本数据管理-副本数据管理-恢复目标 +${cdm_tab_recovery_step1_next_btn} id=cdm_sqlServer_addRecoveryPolicy_nextStep12_btn # 黑方操作页面-副本数据管理-副本数据管理-恢复目标-下一步 +${cdm_tab_recovery_step2_next_btn} id=cdm_sqlServer_addRecoveryPolicy_backStep23_btn # 黑方操作页面-副本数据管理-副本数据管理-实列选择-下一步 +${cdm_tab_recovery_step3_next_btn} id=cdm_sqlServer_addRecoveryPolicy_backStep4_btn # 黑方操作页面-副本数据管理-副本数据管理-目标数据库-下一步 +${cdm_tab_recovery_step4_title} xpath=//h4[text()='恢复高级选项'] # 黑方操作页面-副本数据管理-副本数据管理-恢复高级选项-标题 +${cdm_tab_recovery_step4_next_btn} id=cdm_sqlServer_addRecoveryPolicy_finish_btn # 黑方操作页面-副本数据管理-副本数据管理-恢复高级选项-完成 +${cdm_tab_recovery_step4_recTargetPath} id=recTargetPath # 黑方操作页面-副本数据管理-副本数据管理-恢复高级选项-恢复路径 +${cdm_tab_recovery_step4_finish_title} xpath=//div[text()='确认要执行恢复吗?'] # 黑方操作页面-副本数据管理-副本数据管理-恢复高级选项-确认要执行恢复标题 +${cdm_tab_recovery_step4_finish_btn} xpath=//a[text()='确认'] # 黑方操作页面-副本数据管理-副本数据管理-恢复高级选项-确认要执行恢复按钮 +${recovery_run_msg} xpath=//p[text()='添加成功!'] # mssql副本-副本数据管理-恢复数据-添加成功 +${mssql_recovery_goStep3_database_all} xpath=((//span[text()='SqlServer数据库'])/../../td[2])[2] # mssql副本-新建恢复策略-目标数据库-全选 diff --git a/Project/task3/Resources/KeyWord.robot b/Project/task3/Resources/KeyWord.robot new file mode 100644 index 0000000..6a547ec --- /dev/null +++ b/Project/task3/Resources/KeyWord.robot @@ -0,0 +1,151 @@ +*** Settings *** +Library Selenium2Library +Resource Element.robot +Resource Common.robot +Variables ../config/myConfig.py +Library DateTime + +*** Keywords *** +登录黑方 + Open Browser ${unbackupIP} ${browser} + Maximize Browser Window + Wait Until Element Is Visible ${login_slogan} 30s 黑方打开失败 + 输入文本 ${input_userName} ${login_username} + 输入文本 ${input_passwd} ${login_passwd} + 点击按钮 ${btn_login} + Wait Until Element Is Visible ${button_loginmessage} 30s 黑方登录失败 + Log 黑方登录成功 + +创建Sqlserver副本备份策略 + Wait Until Element Is Visible ${button_sideNav_cdm} 30s 副本数据管理模块不存在 + 点击按钮 ${button_sideNav_cdm} + Wait Until Element Is Visible ${cdm_sideNav_all} 30s 副本数据管理模块页面异常 + # 选中SqlserverCDM代理机 + 输入文本 ${cdm_inputSuccess2} ${hostname} + 点击按钮 xpath=//span[text()='${hostname}'] + Wait Until Element Is Visible ${cdm_tab_policy_li} 10s 定时数据保护页面打开异常 + # 新建策略 + 点击按钮 ${cdm_newpolicy} + Wait Until Element Is Visible ${mssql_newpolicy_title} 5s 新建备份策略弹窗未打开 + Wait Until Element Is Visible ${mssql_newpolicy_type} 5s mssql副本组件未安装 + # 点击mssql副本组件 + 点击按钮 ${mssql_newpolicy_type} + Wait Until Element Is Visible ${mssql_newpolicy_goStep1} 5s 连接凭据页面未发现 + # 连接凭据 + 输入文本 ${mssql_newpolicy_goStep1_PolicyName} ${PolicyName} + 点击按钮 ${mssql_newpolicy_goStep1_nextStep2_btn} + # 实例选择 + Wait Until Element Is Visible ${mssql_newpolicy_goStep2} 5s 实例选择页面未发现 + 点击按钮 ${mssql_newpolicy_goStep2_nextStep3_btn} + # 目标数据库 + Wait Until Element Is Visible ${mssql_newpolicy_goStep3} 5s 目标数据库页面未发现 + 点击按钮 ${mssql_newpolicy_goStep3_database_all} + # 目标数据库-过滤设置 + 点击按钮 ${mssql_newpolicy_goStep3_filterBtn_btn} + Wait Until Element Is Visible ${mssql_newpolicy_goStep3_baseFilterSel_btn} 5s 过滤设置-数据库过滤页面未发现 + Wait Until Element Is Visible ${mssql_newpolicy_goStep3_baseFilterKey_btn} 5s 过滤设置-关键字过滤页面未发现 + 点击按钮 ${mssql_newpolicy_goStep3_baseFilterKey_btn} + Wait Until Element Is Visible ${mssql_newpolicy_goStep3_baseFilterKey_keyFilterCon} 5s 过滤设置-关键字过滤未打开 + 输入文本 ${mssql_newpolicy_goStep3_baseFilterKey_keyFilterCon} ${keyFilter} + 点击按钮 ${mssql_newpolicy_goStep3_baseFilterKey_addkeyFilter} + 点击按钮 ${mssql_newpolicy_goStep3_baseFilterKey_addkeyFilterSure_btn} + 点击按钮 ${mssql_newpolicy_goStep3_nextStep4_btn} + # 任务周期 + Wait Until Element Is Visible ${mssql_newpolicy_goStep4} 5s 目标数据库页面未发现 + 点击按钮 ${mssql_newpolicy_goStep4_AddTaskCycle} + 点击按钮 ${mssql_newpolicy_goStep4_AddTaskCycle_sunday} + 点击按钮 ${mssql_newpolicy_goStep4_AddTaskCycle_Sure_btn} + 点击按钮 ${mssql_newpolicy_goStep4_nextStep5_btn} + # 备份集存储 + Wait Until Element Is Visible ${mssql_newpolicy_goStep5} 5s 设置存储路径页面未发现 + 点击按钮 ${mssql_newpolicy_goStep5_nextStep6_btn} + # 备份高级选项 + Wait Until Element Is Visible ${mssql_newpolicy_goStep6} 5s 设置存储路径页面未发现 + 点击按钮 ${mssql_newpolicy_goStep6_next_btn} + # 添加成功 + Wait Until Element Is Visible ${mssql_newpolicy_addsucess} 10s + 点击按钮 ${mssql_define_btn} + Log 已经创建备份策略:${PolicyName} + +执行备份任务并校验 + # 选择上面创建的策略并运行 + 输入文本 ${policy_input_backupNameSearch} ${PolicyName} + # 点击查询 + 点击按钮 ${policy_btn_backContentSearch} + Sleep 2s + Element Text Should Be ${policy_table_firstname} ${PolicyName} + 点击按钮 ${policy_run} + Wait Until Element Is Visible ${policy_run_title} 5s 立即执行窗口未打开 + Select From List By Label ${policy_run_select} ${policy_run_select_type} + Sleep 2s + 点击按钮 ${policy_run_executePolicyExecute_btn} + Wait Until Element Is Visible ${policy_run_msg} 10s 添加成功窗口未打开 + 点击按钮 ${mssql_define_btn} + 作业校验 ${PolicyName} + +作业校验 + [Arguments] ${workname} + # 切换到作业 + 点击按钮 ${cdm_tab_work_li} + Wait Until Element Is Visible ${cdm_tab_work_export_btn} 10s 作业页面打开异常 + # 输入策略查询 + 输入文本 ${cdm_tab_work_PolicyName} ${workname} + 点击按钮 ${cdm_tab_work_search_span} + # 确认创建成功了 + FOR ${counter} IN RANGE 60 + Log ${counter} + ${select_text}= Execute Javascript return ${task_select_count} + Log 查询到的作业个数:${select_text} + IF '${select_text}' >= '2' BREAK + Sleep 2s + 点击按钮 ${cdm_tab_work_search_span} + END + Log 作业创建成功,正在运行中 + # 等待运行完成 + FOR ${index} IN RANGE 300 + Log 第${index}次查询作业状态 + ${task_run}= Execute Javascript return ${task_status} + Log 作业状态:${task_run} + Exit For Loop If '${task_run}' == '成功' or '${task_run}' == '失败' + Sleep 2s + 点击按钮 ${cdm_tab_work_search_span} + END + Should Be Equal As Strings ${task_run} 成功 任务运行失败 + Log 作业策略执行成功 + +创建恢复任务并校验 + # 进入备份集页面 + 点击按钮 ${cdm_tab_backupset_li} + # 按照策略查询备份集 + 输入文本 ${policy_input_backTabPolicy} ${PolicyName} + 点击按钮 ${cdm_tab_backupset_search_span} + # 点击操作 + 点击按钮 id=backupAction_${PolicyName} + Wait Until Element Is Visible id=cdmBkset_recovery_${PolicyName} 10s 操作按钮异常 + # 恢复 + 点击按钮 id=cdmBkset_recovery_${PolicyName} + Wait Until Element Is Visible ${cdm_tab_recovery_step1} 10s 恢复页面未打开 + # 恢复目标 + 点击按钮 ${cdm_tab_recovery_step1_next_btn} + # 实列选择 + Wait Until Element Is Visible ${cdm_tab_recovery_step2_next_btn} 10s 实列选择页面异常 + 点击按钮 ${cdm_tab_recovery_step2_next_btn} + # 选择目标数据库 + Wait Until Element Is Visible ${cdm_tab_recovery_step3_next_btn} 10s 选择目标数据库页面异常 + 点击按钮 ${mssql_recovery_goStep3_database_all} + 点击按钮 ${cdm_tab_recovery_step3_next_btn} + # 高级选项 + Wait Until Element Is Visible ${cdm_tab_recovery_step4_title} 10s 高级选项页面异常 + 输入文本 ${cdm_tab_recovery_step4_recTargetPath} ${recTargetPath} + 点击按钮 ${cdm_tab_recovery_step4_next_btn} + Wait Until Element Is Visible ${cdm_tab_recovery_step4_finish_title} 10s 确认恢复页面未出现 + 点击按钮 ${cdm_tab_recovery_step4_finish_btn} + Wait Until Element Is Visible ${recovery_run_msg} 10s 添加成功窗口未打开 + 点击按钮 ${mssql_define_btn} + Log 恢复作业已经创建 + ${Date}= Get Current Date result_format=%Y-%m-%d %H:%M + ${recoveryname}= Catenate SEPARATOR= 恢复策略 ${Date[:-1]} + Log ${recoveryname} + 作业校验 ${recoveryname} + + diff --git a/Project/task3/Resources/__init__.robot b/Project/task3/Resources/__init__.robot new file mode 100644 index 0000000..6514f6f --- /dev/null +++ b/Project/task3/Resources/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Library Selenium2Library diff --git a/Project/task3/Script/.gitkeep b/Project/task3/Script/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Project/task3/TestSuite/Project3.robot b/Project/task3/TestSuite/Project3.robot new file mode 100644 index 0000000..4ac416f --- /dev/null +++ b/Project/task3/TestSuite/Project3.robot @@ -0,0 +1,16 @@ +*** Settings *** +Library Selenium2Library +Resource ../Resources/KeyWord.robot +Resource ../Resources/Element.robot +Resource ../Resources/Common.robot + +*** Test Cases *** +Sqlserver副本备份恢复 + [Setup] 登录黑方 # 登录黑方 + # 初始化数据库 + 创建Sqlserver副本备份策略 + 执行备份任务并校验 + # 删除表确认该表不存在 + 创建恢复任务并校验 + # 校验恢复结果 + [Teardown] Close Browser # Close Browser diff --git a/Project/task3/TestSuite/__init__.robot b/Project/task3/TestSuite/__init__.robot new file mode 100644 index 0000000..6514f6f --- /dev/null +++ b/Project/task3/TestSuite/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Library Selenium2Library diff --git a/Project/task3/config/myConfig.py b/Project/task3/config/myConfig.py new file mode 100644 index 0000000..5879522 --- /dev/null +++ b/Project/task3/config/myConfig.py @@ -0,0 +1,22 @@ +# encoding=utf-8 +from datetime import datetime + + +# 定义一些公共的参数 + +# 浏览器类型 +browser = "Firefox" +# 黑方的地址 +unbackupIP = "https://10.10.13.197" +login_username = "sys_admin" +login_passwd = "test@2008" + +# 代理相关 +# 策略名 +actime_time = datetime.now().strftime('%Y%m%d%H%M%S') +PolicyName = "AutoTest-SQLServerCDM-Backup-" + actime_time +# 代理名称 +hostname = "SqlserverCDM" +# 过滤关键词 +keyFilter = "test1" +recTargetPath='C:\\data'