当前经过调整适配后,测试通过率为4/15,失败11个。两个原因,第一个是测试用例是3-6年前写的,文本之类的有改动,第二个问题是当前的界面通用关键字没考虑导航窗格被折叠的因素,导致CI失败。
用例 1:Verify Navigation To Date And Time Page
测试目的(名义上)
验证能否导航到“日期和时间”页面。
实际执行流程
Suite Setup Execution
登录 BMC GUI,进入 Overview 页面。
最大化浏览器窗口。
Test Setup
调用Navigate To Date And Time Page,其最新实现为:Navigate To Date And Time Page
[Documentation] Navigate to the date and time page from main menu.${current_url}= Get Location
${already_there}= Run Keyword And Return Status Should Contain ${current_url} date-time
IF not ${already_there}
Ensure Sidebar Expanded
Navigate To Required Sub Menu ${xpath_settings_menu} ${xpath_date_time_sub_menu} date-time
END
Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=30获取当前 URL,判断是否已包含
date-time。如果已经在日期时间页面,直接跳过导航。
如果不在,先确保侧边栏展开,再调用
Navigate To Required Sub Menu进行菜单导航。
Navigate To Required Sub Menu内部逻辑判断子菜单
${xpath_date_time_sub_menu}是否可见。若不可见,点击主菜单
${xpath_settings_menu}(//*[@data-test-id='nav-button-settings'])。点击子菜单
${xpath_date_time_sub_menu}(//*[@data-test-id='nav-item-date-time'])。验证 URL 包含
date-time。等待加载进度条消失。
用例体
Page Should Contain Element ${xpath_date_time_heading}(//h1[text()="Date and time"])。
问题分析
用例名为“Verify Navigation”,但导航动作完全由 Test Setup 完成,用例体只验证标题是否存在。
它并没有独立测试“点击菜单→跳转页面”的导航过程,因此测试目的名不副实。
该用例与 Test Setup 的职责重叠,属于冗余设计。
建议
最佳方案:改名为
Verify Date And Time Page Heading,承认它只是验证标题。次佳方案:删除该用例。导航已由每个用例的 Test Setup 保证,无需单独验证。
最差方案:保持现状。会继续造成测试意图混淆。因为如果标题不是date and time 那第一个测试用例会失败,如果标题又是导航到日期与时间界面,那实际情况就是确实导航过去了,只是标题不对造成的失败,并不是导航操作本身有问题
人工复刻:
登录 BMC GUI。
若左侧导航栏未显示,点击左上角按钮展开。
点击“Settings”菜单。
点击“Date and time”子菜单。
确认页面标题为“Date and time”。
用例 2:Verify Text Under Date And Time Page
测试目的:验证页面上的两段说明文字是否存在。
自动化操作:
Test Setup同上,导航到日期时间页面。用例体:
Page Should Contain To change how date and time are displayed (either UTC or browser offset) throughout the application, visit Profile SettingsPage Should Contain If NTP is selected but an NTP server is not given or the given NTP server is not reachable, then time.google.com will be used.
结果:FAIL(Setup failed: ElementNotInteractableException)
失败原因:第一,用例体第二段已被移除。第二,原始Navigate To Date And Time Page中,
Click Element ${xpath_settings_menu} Click Element ${xpath_date_time_sub_menu}它无条件点击“设置”菜单。如果当前已经在“日期和时间”页面,侧边栏的“设置”菜单是展开状态,再点击它会触发折叠。折叠动画期间,子菜单“日期和时间”逐渐消失,紧接着的点击就会失败(被拦截或元素不可见)。
人工复刻:
进入日期时间页面。
查看页面顶部文字,确认用例体第一段存在
用例 3:Verify Existence Of All Sections In Date And Time Page
测试目的:验证“Configure settings”区域存在。
自动化操作:
Test Setup导航到页面。用例体:
Page Should Contain Configure settings
人工复刻:
进入页面。
确认页面上有“Configure settings”标题。
用例 4:Verify Existence Of All Buttons In Date And Time Page
测试目的:验证手动模式、NTP 模式、保存按钮存在。
自动化操作:
Test Setup导航到页面。用例体:
Page Should Contain Element ${xpath_select_manual}(//*[@data-test-id="dateTime-radio-configureManual"])Page Should Contain Element ${xpath_select_ntp}(//*[@data-test-id="dateTime-radio-configureNTP"])Page Should Contain Element ${xpath_select_save_settings}(//button[@data-test-id="dateTime-button-saveSettings"])
结果:PASS。
原因:导航成功,元素存在。
人工复刻:
进入页面。
确认有“Configure manually”、“Configure NTP”单选按钮和“Save settings”按钮。
用例 5:Verify Existence Of All Input Boxes In Date And Time Page
测试目的:验证手动和 NTP 模式下的输入框存在。
自动化操作:
Test Setup导航到页面。用例体:
Click Element At Coordinates ${xpath_select_manual} 0 0(点击手动模式)Page Should Contain Element ${xpath_manual_date}(//input[@data-test-id="dateTime-input-manualDate"])Page Should Contain Element ${xpath_manual_time}(//input[@data-test-id="dateTime-input-manualTime"])再点击 NTP 模式,检查三个 NTP 输入框。
人工复刻:
进入页面。
点击“Configure manually”,确认出现日期和时间输入框。
点击“Configure NTP”,确认出现三个 NTP 服务器输入框。
用例 6:Verify Date And Time From Configuration Section
测试目的:从配置区域获取日期时间,与 BMC CLI 对比。
自动化操作:
Test Setup导航到页面。用例体:
点击手动模式。
Get Value ${xpath_manual_date}和Get Value ${xpath_manual_time}。通过 SSH 执行
date +"%Y-%m-%dT%H:%M:%S"。Should Contain ${cli_date_time} ${manual_date} ${manual_time}。
结果:PASS。
原因:页面已就绪,输入框存在且值正确。
人工复刻:
进入页面,选择“Configure manually”。
记下日期和时间。
SSH 登录 BMC,执行
date,对比。
用例 7:Verify Display Of Date And Time In GUI Page
测试目的:从 Redfish 获取时间,与 GUI 显示对比。
自动化操作:
Test Setup导航到页面。用例体:
Set Timezone In Profile Settings Page Default(可能涉及导航到 Profile Settings 再返回)再次
Navigate To Date And Time Page。通过 CLI 获取时间,转换格式。
Page Should Contain ${redfish_date}和${redfish_time}。
结果:FAIL(Setup failed: ElementClickInterceptedException)。
失败原因:Test Setup 导航失败。
人工复刻:
进入页面,查看日期时间。
通过 Redfish 接口获取时间,对比。
用例 8:Verify Profile Setting Button In Date And Time Page
测试目的:点击“Profile settings”链接跳转到个人设置页面。
自动化操作:
Test Setup导航到页面。用例体:
Click Element ${xpath_profile_settings_link}(//a[contains(text(),'Profile Settings')])Wait Until Page Contains Element ${xpath_profile_settings_heading}Location Should Contain profile-settings
结果:FAIL(ElementClickInterceptedException)。
失败原因:点击链接时被nav-overlay遮挡。
人工复刻:
进入页面。
点击“Profile Settings”链接,确认跳转。
用例 9:Verify Existence Of Timezone Buttons In Profile Settings Page
测试目的:验证个人设置页面的时区按钮存在。
自动化操作:
Test Setup导航到页面。用例体:
点击 Profile Settings 链接。
等待页面标题。
检查
xpath_default_UTC和xpath_browser_offset。
结果:FAIL(Setup failed: ElementClickInterceptedException)。
失败原因:Test Setup 导航失败。
人工复刻:
进入个人设置页面。
确认有“Default UTC”和“Browser offset”按钮。
用例 10:Verify Date And Time Change To Browser Offset Time
测试目的:选择 Browser offset 后时间变化。
自动化操作:
Test Setup导航到页面。用例体:
点击 Profile Settings 链接。
点击 Browser offset,保存。
获取偏移文本。
返回日期时间页面,验证显示。
结果:FAIL(ElementClickInterceptedException)。
失败原因:点击 Profile Settings 链接时被nav-overlay遮挡。
人工复刻:
进入个人设置,选择 Browser offset,保存。
返回日期时间页面,确认时间已变。
用例 11:Verify NTP Server Input Fields In Date And Time Page
测试目的:验证 NTP 服务器输入框可编辑保存。
自动化操作:
Test Setup:Setup To Power Off And Navigate(关机并导航)。用例体:
点击 NTP 模式。
输入三个 NTP 地址(
10.10.10.10等)。保存,刷新,验证值。
结果:FAIL(Setup failed: ElementClickInterceptedException)。
失败原因:Test Setup 导航失败。
人工复刻:
进入页面,选择 NTP。
输入 NTP 地址,保存,刷新,确认值已保存。
用例 12:Verify Setting Manual BMC Time
测试目的:手动设置时间并对比 CLI。
自动化操作:
Test Setup:Set Timezone...+Setup To Power Off And Navigate。用例体:
点击手动模式。
输入日期
2023-05-12,时间15:30。保存,等待 120 秒。
获取值,与 CLI 对比。
结果:FAIL(Setup failed: ElementClickInterceptedException)。
失败原因:Test Setup 导航失败。
人工复刻:
进入页面,选择手动,设置日期时间,保存,等待,SSH 对比。
用例 13:Verify Setting Invalid Date And Time Is Not Allowed
测试目的:输入非法日期时间,验证报错。
自动化操作:
Test Setup:Setup To Power Off And Navigate。用例体:
点击手动模式。
输入
2023-18-48,检查Invalid format消息。输入
29:48,再次检查。
结果:FAIL(Element with locator '//input[@data-test-id="dateTime-input-manualDate"]' not found.)。
失败原因:Test Setup 导航后,页面未正确显示手动模式输入框(可能导航未完成或模式未切换)。
人工复刻:
进入页面,选择手动,输入非法日期,确认出现错误提示。
用例 14:Verify Changing BMC Time From NTP To Manual
测试目的:从 NTP 切换到手动模式。
自动化操作:
Test Setup:Setup To Power Off And Navigate。用例体:
添加 NTP 服务器
time.google.com,保存。切换到手动,设置未来时间,保存,刷新验证。
结果:FAIL(Setup failed: ElementClickInterceptedException)。
失败原因:Test Setup 导航失败。
人工复刻:
进入页面,配置 NTP,保存。
切换手动,设置时间,保存,刷新确认。
用例 15:Verify Moving From Manual To NTP
测试目的:从手动切换到 NTP,循环两次。
自动化操作:
Test Setup:Setup To Power Off And Navigate。用例体:使用
Switch From Manual To NTP模板,循环${LOOP_COUNT}(2次):设置手动时间。
切换到 NTP,输入 NTP 地址
216.239.35.0(硬编码),保存。等待同步,验证 CLI 时间与页面显示。
结果:PASS。
原因:可能因为侧边栏在循环中恰好展开,或点击被拦截后重试成功。但硬编码的 NTP 地址216.239.35.0是 Google 公共 NTP,依赖外网。
人工复刻:
进入页面,手动设置未来时间,保存。
切换到 NTP,输入
216.239.35.0,保存。等待,通过 SSH 查看时间是否同步。
总结与修复建议
主要问题在于自动化操作时,导航窗口有可能被折叠起来,原有框架未考虑这一点。
硬编码 NTP 地址:
216.239.35.0应改为测试参数,由用户根据环境指定。文本检查:用例 2 的第二段文字不存在,需与当前 webui版本核对。用例11 12进行power server对服务器进行下电操作时等待过程逻辑发生变化。不适用于当前的webui版本