robotframework-demo/Project/task4/Resource/RE8_Sec/KeyWord.robot

80 lines
4.0 KiB
Plaintext

*** Settings ***
Resource ElementPath.robot
Library Selenium2Library
*** Keywords ***
Nessus扫描
[Arguments] ${bc_ip}
Open Browser ${nessus_ip} ff
Wait Until Element Is Visible ${nessus_logo} 30s 打开nessus页面失败
元素输入 ${nessus_input_name} ${nessus_name} 定位登录名输入框失败
元素输入 ${nessus_input_pwd} ${nessus_pwd} 定位密码输入框失败
元素点击 ${nessus_login_button} 点击登录按钮 定位登录按钮失败
FOR ${num} IN RANGE 5
${policy_status} Run Keyword And Return Status Wait Until Element Is Visible xpath=//tr[@data-name="${bc_ip}"]//i[@title="Trash"] 10s
Run Keyword If ${policy_status}==True Click Element xpath=//tr[@data-name="${bc_ip}"]//i[@title="Trash"]
... ELSE Exit For Loop
Sleep 2s
END
Log 重复策略名清理完毕
元素点击 ${nessus_new_policy} 点击创建新扫描策略 定位创建新扫描策略失败
元素点击 ${nessus_uesr_defined} 点击切换到用户自定义模板栏 定位用户自定义模板栏失败
元素点击 ${nessus_template} 点击选择用户模板 定位用户模板失败
元素输入 ${nessus_input_ip} ${bc_ip} 定位黑方IP输入框失败
元素输入 ${nessus_input_policyname} ${bc_ip} 定位策略名输入框失败
元素点击 ${nessus_save_policy} 点击保存策略 定位保存策略按钮失败
Sleep 2s
元素点击 xpath=//tr[@data-name="${bc_ip}"]//td[@class="scan-action-1"]/i 点击执行策略 定位执行策略失败
Wait Until Element Is Visible ${nessus_running} 10s 策略执行失败
[Teardown] Close Browser
元素点击
[Arguments] ${location} ${log_localsuccess} ${log_localfail} ${sleeptime}=30s
Wait Until Page Contains Element ${location} ${sleeptime} ${log_localfail}
Set Focus To Element ${location}
Click Element ${location}
Log ${log_localsuccess}
Sleep 5s
元素输入
[Arguments] ${location} ${input_content} ${log_localfail} ${sleeptime}=30s
Wait Until Element Is Visible ${location} ${sleeptime} ${log_localfail}
Set Focus To Element ${location}
Input Text ${location} ${input_content}
Log 输入内容为${input_content}
Sleep 2s
绿盟扫描
[Arguments] ${ip}
Open Browser ${rsas_ip} ff
Wait Until Element Is Visible ${rsas_logo} 30s 打开nessus页面失败
元素输入 ${rsas_input_name} ${rsas_name} 定位绿盟用户名输入框失败
元素输入 ${rsas_input_pwd} ${rsas_pwd} 定位绿盟密码输入框失败
元素点击 ${rsas_login} 点击登录绿盟 定位绿盟登录按钮失败
Sleep 15s
Select Frame ${rsas_iframe}
循环点击 ${rsas_all_scan} ${rsas_input_taskname}
Sleep 5s
元素输入 ${rsas_input_taskname} ${ip} 定位任务名输入框失败
Sleep 5s
元素输入 ${rsas_input_ip} ${ip} 定位ip输入框失败
Sleep 5s
元素点击 ${rsas_senior_config} 点击切换到高级选项 定位高级选项失败
Sleep 5s
元素点击 ${all_ports} 点击勾选全部端口 定位全部端口失败
Sleep 5s
元素点击 ${rsas_complete} 点击确定完成扫描策略 定位确定完成策略按钮失败
Sleep 30s
Wait Until Element Is Visible ${rsas_process} 60s 扫描任务开启失败
循环点击
[Arguments] ${locator1} ${locator2}
FOR ${n} IN RANGE 10
Sleep 5s
元素点击 ${locator1} 点击指定元素 定位指定元素失败
Sleep 5s
${status}= Run Keyword And Return Status Wait Until Element Is Visible ${locator2}
Run Keyword If ${status} Exit For Loop
... ELSE Log 点击${n}次
END