一 概述
test_resource_management_menu中当前仅有2个测试用例,一个导航测试,一个设置封顶数值测试。
变量分析
变量主要是 XPath 定位器:
| 变量 | 作用 |
|---|---|
${xpath_resource_management_menu} |
左侧导航 Resource Management 菜单 |
${xpath_resource_management_power_menu} |
Power 子菜单 |
${xpath_resource_management_header} |
页面标题,要求包含 "Power" |
${xpath_power_tab_power_consumption} |
当前功耗区域 |
${xpath_power_cap_setting} |
Power cap setting 区域 |
${xpath_power_cap_apply} |
Apply power cap 标签 |
${xpath_power_cap_checkbox} |
Power cap 开关复选框 |
${xpath_asset_tag_save_button} |
Save 按钮 |
${xpath_power_cap_value} |
Power cap 数值输入框 |
对应如下:
关键字
Suite Setup Execution Launch Browser And Login GUI Navigate To Required Sub Menu ${xpath_resource_management_menu} ${xpath_resource_management_power_menu} power
套件初始化流程:
-
调用
Launch Browser And Login GUI:启动浏览器并登录 GUI。 -
调用
Navigate To Required Sub Menu:进入 Resource Management → Power 页面。 -
最后一个参数
power用于校验当前页面标题,具体实现依赖gui_resource.robot。
二、测试用例讲解
用例 1:Verify Navigate To Resource Management Page
Verify Navigate To Resource Management Page
[Documentation] Login to GUI and perform page navigation to
... Resource Management page and verify it loads successfully.
[Tags] Verify_Navigate_To_Resource_Management_Page
Page Should Contain Element ${xpath_resource_management_header}
测试目的:
验证能够导航到 Resource Management 页面,并且页面加载成功。
实际步骤:
由于 Suite Setup 已经完成登录并导航到 Resource Management → Power 页面,所以该用例只检查页面标题元素是否存在:
${xpath_resource_management_header} = //h1[contains(normalize-space(.), "Power")]
也就是说,它验证的是页面 H1 标题中是否包含 Power。
验证点:
-
Power 页面标题存在。
-
间接说明导航成功。
用例 2:Verify Able To Set Power Cap Value
Verify Able To Set Power Cap Value
[Documentation] Verify that the power cap value can be set successfully.
[Tags] Verify_Able_To_Set_Power_Cap_Value
Page Should Contain Element ${xpath_power_tab_power_consumption}
Page Should Contain Element ${xpath_power_cap_setting}
Page Should Contain Element ${xpath_power_cap_apply}
Page Should Contain Checkbox ${xpath_power_cap_checkbox}
Click Element ${xpath_power_cap_checkbox}
${value}= Evaluate random.randint(1, 10000) modules=random
Input Text ${xpath_power_cap_value} ${value}
Page Should Contain Element ${xpath_asset_tag_save_button}
Click Element ${xpath_asset_tag_save_button}
测试目的:
验证 Power Cap 值是否可以设置成功。
执行步骤:
-
检查页面存在:
-
Current power consumption -
Power cap setting -
Apply power cap
-
-
检查 Power Cap 复选框存在。
-
点击复选框,启用 Power Cap 设置。
-
随机生成一个 1 到 10000 之间的整数:
${value}= Evaluate random.randint(1, 10000) modules=random -
将随机值输入到 Power Cap 输入框:
Input Text ${xpath_power_cap_value} ${value} -
检查 Save 按钮存在。
-
点击 Save 按钮保存。
验证点:
目前只验证了元素存在、输入框可输入、Save 按钮可点击。
关键问题:
代码中已经注明:
# Need to add verification step to check if the power cap value is set successfully.
# once the open issue is resolved, add verification step here.
也就是说,该用例目前没有形成闭环验证。点击 Save 后,并没有验证:
-
是否出现保存成功提示;
-
Power Cap 值是否回显正确;
-
刷新页面后值是否仍然存在;
-
后端 Redfish/API 是否真正生效。
因此,该用例目前只能算"操作执行型"测试,不能算完整的"功能验证型"测试。
三、执行流程总结
整个套件的执行顺序是:
-
Suite Setup Execution-
启动浏览器并登录 GUI;
-
导航到 Resource Management → Power 页面。
-
-
执行测试用例 1:
- 验证 Power 页面标题存在。
-
执行测试用例 2:
-
检查 Power Cap 相关元素;
-
启用 Power Cap;
-
输入随机值;
-
点击 Save。
-
-
Suite Teardown- 关闭浏览器。
四、主要问题与改进建议
-
保存后缺少验证
- 应增加保存成功提示、值回读、刷新后校验或 API 校验。
-
随机值范围可能不符合实际规格
1~10000只是随机范围,不一定符合 BMC 的 Power Cap 允许范围。可以根据实际情况进行调整 -
变量命名不一致
${xpath_asset_tag_save_button}实际是 Power Cap 的 Save 按钮,建议改名为${xpath_power_cap_save_button}。不适用文本查找而是power-button-savePowerCapValue
总体来看,这个测试套件完成了 登录、导航、Power Cap 设置操作 的基础流程,但第二个核心用例还缺少保存结果验证,属于待完善的半闭环测试。