blob: f324f871ba5c85350c22e59757605c0ecbce7f7b [file] [log] [blame]
Rahul Maheshwari41747da2020-11-17 09:09:52 -06001*** Settings ***
2Documentation This is a resource file containing user-defined keywords for new Vue based OpenBMC GUI.
3
4Library XvfbRobot
5Library SeleniumLibrary
6Library SSHLibrary 30 Seconds
7Resource ../../lib/state_manager.robot
8Variables ../data/gui_variables.py
9
10
11*** Variables ***
rramyasr-in58fbfa12025-10-08 07:06:57 -050012${OPENBMC_GUI_URL} https://${OPENBMC_HOST}:${HTTPS_PORT}
13${xpath_power_page} //*[@data-test-id='appHeader-container-power']
14${xpath_power_shutdown} //*[@data-test-id='serverPowerOperations-button-shutDown']
15${xpath_power_power_on} //*[@data-test-id='serverPowerOperations-button-powerOn']
16${xpath_power_reboot} //*[@data-test-id='serverPowerOperations-button-reboot']
17${xpath_confirm} //button[contains(text(),'Confirm')]
Rahul Maheshwari41747da2020-11-17 09:09:52 -060018
George Keishing4d4ef992021-01-28 09:56:53 -060019# Default GUI browser and mode is set to "Firefox" and "headless"
Rahul Maheshwari41747da2020-11-17 09:09:52 -060020# respectively here.
21${GUI_BROWSER} ff
22${GUI_MODE} headless
23
Rahul Maheshwari41747da2020-11-17 09:09:52 -060024
25*** Keywords ***
26
27Open Browser With URL
28 [Documentation] Open browser with specified URL and returns browser id.
29 [Arguments] ${URL} ${browser}=ff ${mode}=${GUI_MODE}
30
31 # Description of argument(s):
32 # URL Openbmc GUI URL to be open
33 # (e.g. https://openbmc-test.mybluemix.net/#/login).
34 # browser Browser used to open above URL
35 # (e.g. gc for google chrome, ff for firefox).
36 # mode Browser opening mode(e.g. headless, header).
37
rramyasr-in714ed722025-05-20 02:19:50 -050038 IF '${mode}' == 'headless'
39 ${browser_ID}= Launch Headless Browser ${URL} ${browser}
40 ELSE
41 ${browser_ID}= Open Browser ${URL} ${browser}
42 END
George Keishing409df052024-01-17 22:36:14 +053043 RETURN ${browser_ID}
Rahul Maheshwari41747da2020-11-17 09:09:52 -060044
45
46Launch Header Browser
47 [Documentation] Open the browser with the URL and
48 ... login on windows platform.
49 [Arguments] ${browser_type}=${GUI_BROWSER}
50
51 # Description of argument(s):
52 # browser_type Type of browser (e.g. "firefox", "chrome", etc.).
53
Sridevi Rameshfba7a392025-03-27 10:21:40 -050054 ${BROWSER_ID}= Open Browser ${OPENBMC_GUI_URL} ${browser_type}
Rahul Maheshwari41747da2020-11-17 09:09:52 -060055 Maximize Browser Window
56 Set Global Variable ${BROWSER_ID}
57
58
59Launch Headless Browser
60 [Documentation] Launch headless browser.
Sridevi Rameshfba7a392025-03-27 10:21:40 -050061 [Arguments] ${URL}=${OPENBMC_GUI_URL} ${browser}=${GUI_BROWSER}
Rahul Maheshwari41747da2020-11-17 09:09:52 -060062
63 # Description of argument(s):
64 # URL Openbmc GUI URL to be open
65 # (e.g. https://openbmc-test.mybluemix.net/#/login).
66 # browser Browser to open given URL in headless way
67 # (e.g. gc for google chrome, ff for firefox).
68
69 Start Virtual Display
yuvanvarshitha761f5d92024-07-01 17:17:05 +053070 ${browser_ID}= Open Browser ${URL} ${browser}
Rahul Maheshwari41747da2020-11-17 09:09:52 -060071 Set Window Size 1920 1080
72
George Keishing409df052024-01-17 22:36:14 +053073 RETURN ${browser_ID}
Rahul Maheshwari41747da2020-11-17 09:09:52 -060074
75
76Launch Browser And Login GUI
rramyasr-inb874c312023-02-16 01:33:37 -060077 [Documentation] Launch browser and login to OpenBMC GUI, retry 2 attempts
78 ... in 1 minute time.
79
rramyasr-in4f16a512024-02-21 19:18:07 -060080 Wait Until Keyword Succeeds 195 sec 65 sec Retry Browser Login Attempts
rramyasr-inb874c312023-02-16 01:33:37 -060081
82
83Retry Browser Login Attempts
Rahul Maheshwari41747da2020-11-17 09:09:52 -060084 [Documentation] Launch browser and login to OpenBMC GUI.
85
Sridevi Rameshfba7a392025-03-27 10:21:40 -050086 Open Browser With URL ${OPENBMC_GUI_URL}
Rahul Maheshwari41747da2020-11-17 09:09:52 -060087 Login GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
88
89
90Login GUI
91 [Documentation] Login to OpenBMC GUI.
92 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
93
94 # Description of argument(s):
95 # username The username to be used for login.
96 # password The password to be used for login.
97
Sridevi Rameshfba7a392025-03-27 10:21:40 -050098 Go To ${OPENBMC_GUI_URL}
rramyasr-ind1ae7fa2023-02-20 11:00:41 -060099 Wait Until Element Is Enabled ${xpath_login_username_input}
100 Input Text ${xpath_login_username_input} ${username}
101 Input Password ${xpath_login_password_input} ${password}
shahmo32978f91d2023-04-05 20:59:03 +0530102 Wait Until Element Is Enabled ${xpath_login_button}
Rahul Maheshwari41747da2020-11-17 09:09:52 -0600103 Click Element ${xpath_login_button}
rramyasr-in58fbfa12025-10-08 07:06:57 -0500104 Wait Until Page Contains Operations timeout=60s
rramyasr-in319f27e2024-02-23 01:15:40 -0600105 Wait Until Element Is Not Visible
106 ... ${xpath_page_loading_progress_bar} timeout=120s
Rahul Maheshwari41747da2020-11-17 09:09:52 -0600107
rramyasr-inf133e8b2025-08-18 06:48:13 -0500108
sarandev37ef2c442024-09-27 03:15:32 -0500109Launch Browser And Login GUI With Given User
110 [Documentation] Launch browser and login eBMC with specified user
111 ... credentials through GUI.
112 [Arguments] ${user_name} ${user_password}
113
114 # Description of argument(s):
115 # user_name User name to login to eBMC.
116 # user_password User password to login to eBMC.
117
Sridevi Rameshfba7a392025-03-27 10:21:40 -0500118 Open Browser With URL ${OPENBMC_GUI_URL}
sarandev37ef2c442024-09-27 03:15:32 -0500119 LOGIN GUI ${user_name} ${user_password}
120
rramyasr-inf133e8b2025-08-18 06:48:13 -0500121
Rahul Maheshwari41747da2020-11-17 09:09:52 -0600122Logout GUI
123 [Documentation] Logout of OpenBMC GUI.
124
shrsuman123a9d93412021-07-13 04:06:05 -0500125 Click Element ${xpath_root_button_menu}
Rahul Maheshwari41747da2020-11-17 09:09:52 -0600126 Click Element ${xpath_logout_button}
127 Wait Until Page Contains Element ${xpath_login_button}
128
129
130Generate Test Error Log
131 [Documentation] Generate test error log.
132
rramyasr-inae6a3c22022-10-26 05:15:00 -0500133 BMC Execute Command ${CMD_UNRECOVERABLE_ERROR}
Anusha Dathatri54edcbc2020-12-10 04:04:08 -0600134
135
136Set Timezone In Profile Settings Page
137 [Documentation] Set the given timezone in profile settings page.
138 [Arguments] ${timezone}=Default
139
140 # Description of argument(s):
141 # timezone Timezone to select (eg. Default or Browser_offset).
142
143 Wait Until Page Contains Element ${xpath_root_button_menu}
144 Click Element ${xpath_root_button_menu}
145 Click Element ${xpath_profile_settings}
146 Click Element At Coordinates ${xpath_default_UTC} 0 0
147 Click Element ${xpath_profile_save_button}
Ashwini Chandrappa90c6a812021-07-07 04:50:00 -0500148
149
150Refresh GUI
151 [Documentation] Refresh GUI via refresh button in header.
152
153 Click Element ${xpath_refresh_button}
rramyasr-inf133e8b2025-08-18 06:48:13 -0500154 # Waiting for page to load fully after refresh.
155 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=120s
meghagn12345f942dae2021-08-27 02:53:00 -0500156
157
158Refresh GUI And Verify Element Value
159 [Documentation] Refresh GUI using refresh button and verify that given element contains expected value.
160 [Arguments] ${element} ${expected_value}
161
162 # Description of argument(s):
163 # element Element whose value need to be checked.
164 # expected_value Expected value of for the given element.
165
166 # Refresh GUI.
rramyasr-in7916eb32025-09-17 01:27:05 -0500167 Refresh GUI
meghagn12345f942dae2021-08-27 02:53:00 -0500168
169 # Check element value and verify that it contains expected value.
170 ${element_value}= Get Text ${element}
171 Log ${element_value}
172 Should Contain ${element_value} ${expected_value}
173
meghagn2052fdd2021-12-07 02:42:31 -0600174
175Reboot BMC via GUI
176 [Documentation] Reboot BMC via GUI.
177
178 Click Element ${xpath_operations_menu}
179 Click Element ${xpath_reboot_bmc_sub_menu}
180 Click Button ${xpath_reboot_bmc_button}
Megha G Nb9ae25a2023-01-27 06:25:00 -0600181 Wait Until Keyword Succeeds 30 sec 10 sec Click Button ${xpath_confirm_bmc_reboot}
meghagn2052fdd2021-12-07 02:42:31 -0600182 Wait Until Keyword Succeeds 2 min 10 sec Is BMC Unpingable
183 Wait For Host To Ping ${OPENBMC_HOST} 1 min
Megha G N2a31e512023-01-18 04:23:20 -0600184
185
186Add DNS Servers And Verify
187 [Documentation] Login to GUI Network page,add DNS server on BMC
188 ... and verify it via BMC CLI.
189 [Arguments] ${dns_server} ${expected_status}=Valid format
190
191 # Description of the argument(s):
192 # dns_server A list of static name server IPs to be
193 # configured on the BMC.
194 # expected_status Expected status while adding DNS server address
195 # (e.g. Invalid format / Field required).
196
197 Wait Until Page Contains Element ${xpath_add_dns_ip_address_button} timeout=15sec
198
199 Click Button ${xpath_add_dns_ip_address_button}
200 Input Text ${xpath_input_static_dns} ${dns_server}
201 Click Button ${xpath_add_button}
George Keishing068ff832025-06-24 11:38:10 +0530202 IF '${expected_status}' != 'Valid format'
203 Page Should Contain ${expected_status} AND Return From Keyword
204 END
Megha G N2a31e512023-01-18 04:23:20 -0600205
206 Wait Until Page Contains Element ${xpath_add_dns_ip_address_button} timeout=10sec
207 Wait Until Page Contains ${dns_server} timeout=40sec
208
209 # Check if newly added DNS server is configured on BMC.
210 ${cli_name_servers}= CLI Get Nameservers
211 ${cmd_status}= Run Keyword And Return Status
212 ... List Should Contain Sub List ${cli_name_servers} ${dns_server}
rramyasr-in714ed722025-05-20 02:19:50 -0500213 IF '${expected_status}' == '${HTTP_OK}'
214 Should Be True ${cmd_status} == ${True}
215 ELSE
216 Should Not Be True ${cmd_status}
217 END
shahmo32978f91d2023-04-05 20:59:03 +0530218
219
220Navigate To Server Power Page
221 [Documentation] Navigate To Server Power Page.
222
223 Click Element ${xpath_power_page}
rramyasr-in7916eb32025-09-17 01:27:05 -0500224 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=30s
shahmo32978f91d2023-04-05 20:59:03 +0530225
226
227Power Off Server
228 [Documentation] Powering off server.
rramyasr-in58fbfa12025-10-08 07:06:57 -0500229
230 ${boot_state} ${host_state}= Redfish Get Boot Progress
231 IF '${host_state}' == 'Disabled'
232 Log To Console Server is already powered Off.
shahmo32978f91d2023-04-05 20:59:03 +0530233 ELSE
rramyasr-in58fbfa12025-10-08 07:06:57 -0500234 Navigate To Server Power Page
235 Wait And Click Element ${xpath_power_shutdown}
236 Click Button ${xpath_confirm}
237 Wait Until Element Is Visible ${xpath_power_poweron} timeout=60
238 Verify And Close Information Message Via GUI
239 Wait Until Keyword Succeeds 5m 30s Check Boot Progress State Via Redfish None Disabled
shahmo32978f91d2023-04-05 20:59:03 +0530240 END
241
242
243Power On Server
244 [Documentation] Powering on server.
245
rramyasr-in58fbfa12025-10-08 07:06:57 -0500246 ${boot_state} ${host_state}= Redfish Get Boot Progress
247 IF '${boot_state}' == 'OSRunning'
248 Log To Console Server is already powered On.
shahmo32978f91d2023-04-05 20:59:03 +0530249 ELSE
rramyasr-in58fbfa12025-10-08 07:06:57 -0500250 Set BIOS Attribute pvm_stop_at_standby Disabled
251 Navigate To Server Power Page
252 Wait And Click Element ${xpath_power_power_on}
253 Wait Until Element Is Visible ${xpath_power_shutdown} timeout=60s
254 Verify And Close Information Message Via GUI
255 Wait Until Keyword Succeeds 10m 45s Check Boot Progress State Via Redfish OSRunning Enabled
shahmo32978f91d2023-04-05 20:59:03 +0530256 END
257
258
rramyasr-in58fbfa12025-10-08 07:06:57 -0500259Check Boot Progress State Via Redfish
260 [Documentation] Checking boot progress state via redfish.
261 [Arguments] ${expected_boot_state} ${expected_host_state}
262
263 # Description of argument(s):
264 # expected_boot_state Expected Boot states are "OSRunning" and "None".
265 # expected_host_state Expected Host states are "Enabled" and "Disabled"
266
267 ${boot_state} ${host_state}= Redfish Get Boot Progress
268 Log To Console Current boot state: ${boot_state}, host state: ${host_state}
269
270 Should Be Equal As Strings ${boot_state} ${expected_boot_state}
271 ... msg=Boot state mismatch: expected '${expected_boot_state}', got '${boot_state}'
272 Should Be Equal As Strings ${host_state} ${expected_host_state}
273 ... msg=Host state mismatch: expected '${expected_host_state}', got '${host_state}'
274
275
276Verify And Close Information Message Via GUI
277 [Documentation] Verify and close Information message via GUI page.
278
279 Wait Until Element Is Visible ${xpath_close_information_message} timeout=5s
280 Page Should Contain Element ${xpath_information_message}
281 Click Element ${xpath_close_information_message}
282
283
shahmo32978f91d2023-04-05 20:59:03 +0530284Reboot Server
285 [Documentation] Rebooting the server.
286
287 Navigate To Server Power Page
288 ${present}= Run Keyword And Return Status
289 ... Element Should Be Visible ${xpath_power_reboot}
290 IF ${present}
291 Click Element ${xpath_power_reboot}
292 Wait Until Element Is Visible ${xpath_confirm} timeout=30
293 Click Button ${xpath_confirm}
294 Wait Until Element Is Visible ${xpath_power_reboot} timeout=60
295 ELSE
296 Log To console Server is already powered Off, can't reboot.
297 END
rramyasr-inf133e8b2025-08-18 06:48:13 -0500298
299
300Verify Success Message On BMC GUI Page
301 [Documentation] Perform actions on the GUI and verify that a success message is displayed.
302
303 Wait Until Element Is Visible ${xpath_success_message} timeout=30
304 Page Should Contain Element ${xpath_success_message}
305 Wait Until Element Is Not Visible ${xpath_success_message} timeout=30
306
307
308Verify Error And Unauthorized Message On GUI
309 [Documentation] Perform operations on GUI with Readonly user and
310 ... verify Error and Unauthorized messages.
311
312 Wait Until Element Is Visible ${xpath_error_popup}
313 Page Should Contain Error
314 Page Should Contain Unauthorized
315 Click Element ${xpath_error_popup}
rramyasr-in069b2662025-09-04 03:36:22 -0500316 Click Element ${xpath_unauthorized_popup}
rramyasr-inf133e8b2025-08-18 06:48:13 -0500317
318
319Create Readonly User And Login To GUI
George Keishingbadb4c62025-09-18 16:14:12 +0530320 [Documentation] Logout current GUI sessions and Created Readonly_user
321 ... via Redfish and Login BMC GUI with Readonly user
rramyasr-inf133e8b2025-08-18 06:48:13 -0500322
323 # Logout current GUI session.
324 Logout GUI
325
George Keishingbadb4c62025-09-18 16:14:12 +0530326 # Created readonly_user via redfish and login BMC GUI with readonly
327 # user to perform test.
rramyasr-inf133e8b2025-08-18 06:48:13 -0500328 Redfish.Login
329 Redfish Create User readonly_user ${OPENBMC_PASSWORD} ReadOnly ${True}
330 Login GUI readonly_user ${OPENBMC_PASSWORD}
331
332
333Delete Readonly User And Logout Current GUI Session
334 [Documentation] Logout current GUI session and delete Readonly user,
335 ... Perform Login GUI with default user and password.
336
337 # Delete Read-only user and Logout current GUI session.
338 Logout GUI
339 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
rramyasr-in069b2662025-09-04 03:36:22 -0500340 Close Browser
rramyasr-inf133e8b2025-08-18 06:48:13 -0500341
342 # Login BMC GUI with default user.
343 Launch Browser And Login GUI
Karthik Bilebal91b08ad2025-09-26 00:55:09 -0500344
345
346Wait And Click Element
347 [Documentation] Wait until element is visible then click the element.
348 [Arguments] ${locator} ${wait_timeout}=10s
349
350 # Description of argument(s):
351 # locator xpath of the element.
352 # wait_timeout timeout for the locator to visible.
353
354 Wait Until Element Is Visible ${locator} timeout=${wait_timeout}
355 Click Element ${locator}
356
357
358Navigate To Required Sub Menu
359 [Documentation] Navigate to required sub menu from main menu.
360 [Arguments] ${xpath_main_menu} ${xpath_sub_menu} ${sub_menu_text}
361
362 # Description of argument(s):
363 # xpath_main_menu Locator of main menu.
364 # xpath_sub_menu Locator of sub menu.
365 # sub_menu_text Text of sub menu.
366
367 ${present}= Run Keyword And Return Status
368 ... Element Should Be Visible ${xpath_sub_menu}
369
370 IF not ${present}
371 Wait And Click Element ${xpath_main_menu}
372 END
373 Wait And Click Element ${xpath_sub_menu} wait_timeout=60s
374 Location Should Contain ${sub_menu_text}
375 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=1min