Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This is a resource file containing user-defined keywords for new Vue based OpenBMC GUI. |
| 3 | |
| 4 | Library XvfbRobot |
| 5 | Library SeleniumLibrary |
| 6 | Library SSHLibrary 30 Seconds |
| 7 | Resource ../../lib/state_manager.robot |
| 8 | Variables ../data/gui_variables.py |
| 9 | |
| 10 | |
| 11 | *** Variables *** |
Matt Fischer | d315df4 | 2023-11-13 16:26:21 -0700 | [diff] [blame] | 12 | ${obmc_gui_url} https://${OPENBMC_HOST}:${HTTPS_PORT} |
shahmo32 | 978f91d | 2023-04-05 20:59:03 +0530 | [diff] [blame] | 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 Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 18 | |
George Keishing | 4d4ef99 | 2021-01-28 09:56:53 -0600 | [diff] [blame] | 19 | # Default GUI browser and mode is set to "Firefox" and "headless" |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 20 | # respectively here. |
| 21 | ${GUI_BROWSER} ff |
| 22 | ${GUI_MODE} headless |
| 23 | |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 24 | |
| 25 | *** Keywords *** |
| 26 | |
| 27 | Open 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 | |
| 38 | ${browser_ID}= Run Keyword If '${mode}' == 'headless' |
| 39 | ... Launch Headless Browser ${URL} ${browser} |
| 40 | ... ELSE Open Browser ${URL} ${browser} |
| 41 | |
| 42 | [Return] ${browser_ID} |
| 43 | |
| 44 | |
| 45 | Launch Header Browser |
| 46 | [Documentation] Open the browser with the URL and |
| 47 | ... login on windows platform. |
| 48 | [Arguments] ${browser_type}=${GUI_BROWSER} |
| 49 | |
| 50 | # Description of argument(s): |
| 51 | # browser_type Type of browser (e.g. "firefox", "chrome", etc.). |
| 52 | |
| 53 | ${BROWSER_ID}= Open Browser ${obmc_gui_url} ${browser_type} |
| 54 | Maximize Browser Window |
| 55 | Set Global Variable ${BROWSER_ID} |
| 56 | |
| 57 | |
| 58 | Launch Headless Browser |
| 59 | [Documentation] Launch headless browser. |
| 60 | [Arguments] ${URL}=${obmc_gui_url} ${browser}=${GUI_BROWSER} |
| 61 | |
| 62 | # Description of argument(s): |
| 63 | # URL Openbmc GUI URL to be open |
| 64 | # (e.g. https://openbmc-test.mybluemix.net/#/login). |
| 65 | # browser Browser to open given URL in headless way |
| 66 | # (e.g. gc for google chrome, ff for firefox). |
| 67 | |
| 68 | Start Virtual Display |
| 69 | ${browser_ID}= Open Browser ${URL} |
| 70 | Set Window Size 1920 1080 |
| 71 | |
| 72 | [Return] ${browser_ID} |
| 73 | |
| 74 | |
| 75 | Launch Browser And Login GUI |
rramyasr-in | b874c31 | 2023-02-16 01:33:37 -0600 | [diff] [blame] | 76 | [Documentation] Launch browser and login to OpenBMC GUI, retry 2 attempts |
| 77 | ... in 1 minute time. |
| 78 | |
rramyasr-in | 4f16a51 | 2024-02-21 19:18:07 -0600 | [diff] [blame] | 79 | Wait Until Keyword Succeeds 195 sec 65 sec Retry Browser Login Attempts |
rramyasr-in | b874c31 | 2023-02-16 01:33:37 -0600 | [diff] [blame] | 80 | |
| 81 | |
| 82 | Retry Browser Login Attempts |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 83 | [Documentation] Launch browser and login to OpenBMC GUI. |
| 84 | |
| 85 | Open Browser With URL ${obmc_gui_url} |
| 86 | Login GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 87 | |
| 88 | |
| 89 | Login GUI |
| 90 | [Documentation] Login to OpenBMC GUI. |
| 91 | [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} |
| 92 | |
| 93 | # Description of argument(s): |
| 94 | # username The username to be used for login. |
| 95 | # password The password to be used for login. |
| 96 | |
| 97 | Go To ${obmc_gui_url} |
rramyasr-in | d1ae7fa | 2023-02-20 11:00:41 -0600 | [diff] [blame] | 98 | Wait Until Element Is Enabled ${xpath_login_username_input} |
| 99 | Input Text ${xpath_login_username_input} ${username} |
| 100 | Input Password ${xpath_login_password_input} ${password} |
shahmo32 | 978f91d | 2023-04-05 20:59:03 +0530 | [diff] [blame] | 101 | Wait Until Element Is Enabled ${xpath_login_button} |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 102 | Click Element ${xpath_login_button} |
Rahul Maheshwari | 7ae30a4 | 2021-02-01 20:02:00 -0600 | [diff] [blame] | 103 | Wait Until Page Contains Overview timeout=60s |
rramyasr-in | 319f27e | 2024-02-23 01:15:40 -0600 | [diff] [blame] | 104 | Wait Until Element Is Not Visible |
| 105 | ... ${xpath_page_loading_progress_bar} timeout=120s |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 106 | |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 107 | Logout GUI |
| 108 | [Documentation] Logout of OpenBMC GUI. |
| 109 | |
shrsuman123 | a9d9341 | 2021-07-13 04:06:05 -0500 | [diff] [blame] | 110 | Click Element ${xpath_root_button_menu} |
Rahul Maheshwari | 41747da | 2020-11-17 09:09:52 -0600 | [diff] [blame] | 111 | Click Element ${xpath_logout_button} |
| 112 | Wait Until Page Contains Element ${xpath_login_button} |
| 113 | |
| 114 | |
| 115 | Generate Test Error Log |
| 116 | [Documentation] Generate test error log. |
| 117 | |
rramyasr-in | ae6a3c2 | 2022-10-26 05:15:00 -0500 | [diff] [blame] | 118 | BMC Execute Command ${CMD_UNRECOVERABLE_ERROR} |
Anusha Dathatri | 54edcbc | 2020-12-10 04:04:08 -0600 | [diff] [blame] | 119 | |
| 120 | |
| 121 | Set Timezone In Profile Settings Page |
| 122 | [Documentation] Set the given timezone in profile settings page. |
| 123 | [Arguments] ${timezone}=Default |
| 124 | |
| 125 | # Description of argument(s): |
| 126 | # timezone Timezone to select (eg. Default or Browser_offset). |
| 127 | |
| 128 | Wait Until Page Contains Element ${xpath_root_button_menu} |
| 129 | Click Element ${xpath_root_button_menu} |
| 130 | Click Element ${xpath_profile_settings} |
| 131 | Click Element At Coordinates ${xpath_default_UTC} 0 0 |
| 132 | Click Element ${xpath_profile_save_button} |
Ashwini Chandrappa | 90c6a81 | 2021-07-07 04:50:00 -0500 | [diff] [blame] | 133 | |
| 134 | |
| 135 | Refresh GUI |
| 136 | [Documentation] Refresh GUI via refresh button in header. |
| 137 | |
| 138 | Click Element ${xpath_refresh_button} |
| 139 | # Added delay for page to load fully after refresh. |
| 140 | Sleep 5s |
meghagn12345 | f942dae | 2021-08-27 02:53:00 -0500 | [diff] [blame] | 141 | |
| 142 | |
| 143 | Refresh GUI And Verify Element Value |
| 144 | [Documentation] Refresh GUI using refresh button and verify that given element contains expected value. |
| 145 | [Arguments] ${element} ${expected_value} |
| 146 | |
| 147 | # Description of argument(s): |
| 148 | # element Element whose value need to be checked. |
| 149 | # expected_value Expected value of for the given element. |
| 150 | |
| 151 | # Refresh GUI. |
| 152 | |
| 153 | Click Element ${xpath_refresh_button} |
| 154 | |
| 155 | # Check element value and verify that it contains expected value. |
| 156 | ${element_value}= Get Text ${element} |
| 157 | Log ${element_value} |
| 158 | Should Contain ${element_value} ${expected_value} |
| 159 | |
meghagn | 2052fdd | 2021-12-07 02:42:31 -0600 | [diff] [blame] | 160 | |
| 161 | Reboot BMC via GUI |
| 162 | [Documentation] Reboot BMC via GUI. |
| 163 | |
| 164 | Click Element ${xpath_operations_menu} |
| 165 | Click Element ${xpath_reboot_bmc_sub_menu} |
| 166 | Click Button ${xpath_reboot_bmc_button} |
Megha G N | b9ae25a | 2023-01-27 06:25:00 -0600 | [diff] [blame] | 167 | Wait Until Keyword Succeeds 30 sec 10 sec Click Button ${xpath_confirm_bmc_reboot} |
meghagn | 2052fdd | 2021-12-07 02:42:31 -0600 | [diff] [blame] | 168 | Wait Until Keyword Succeeds 2 min 10 sec Is BMC Unpingable |
| 169 | Wait For Host To Ping ${OPENBMC_HOST} 1 min |
Megha G N | 2a31e51 | 2023-01-18 04:23:20 -0600 | [diff] [blame] | 170 | |
| 171 | |
| 172 | Add DNS Servers And Verify |
| 173 | [Documentation] Login to GUI Network page,add DNS server on BMC |
| 174 | ... and verify it via BMC CLI. |
| 175 | [Arguments] ${dns_server} ${expected_status}=Valid format |
| 176 | |
| 177 | # Description of the argument(s): |
| 178 | # dns_server A list of static name server IPs to be |
| 179 | # configured on the BMC. |
| 180 | # expected_status Expected status while adding DNS server address |
| 181 | # (e.g. Invalid format / Field required). |
| 182 | |
| 183 | Wait Until Page Contains Element ${xpath_add_dns_ip_address_button} timeout=15sec |
| 184 | |
| 185 | Click Button ${xpath_add_dns_ip_address_button} |
| 186 | Input Text ${xpath_input_static_dns} ${dns_server} |
| 187 | Click Button ${xpath_add_button} |
| 188 | Run keyword if '${expected_status}' != 'Valid format' |
| 189 | ... Run keywords Page Should Contain ${expected_status} AND Return From Keyword |
| 190 | |
| 191 | Wait Until Page Contains Element ${xpath_add_dns_ip_address_button} timeout=10sec |
| 192 | Wait Until Page Contains ${dns_server} timeout=40sec |
| 193 | |
| 194 | # Check if newly added DNS server is configured on BMC. |
| 195 | ${cli_name_servers}= CLI Get Nameservers |
| 196 | ${cmd_status}= Run Keyword And Return Status |
| 197 | ... List Should Contain Sub List ${cli_name_servers} ${dns_server} |
Megha G N | b9e3c71 | 2024-01-09 04:48:43 -0600 | [diff] [blame] | 198 | Run Keyword If '${expected_status}' == '${HTTP_OK}' |
| 199 | ... Should Be True ${cmd_status} == ${True} |
| 200 | ... ELSE Should Not Be True ${cmd_status} |
shahmo32 | 978f91d | 2023-04-05 20:59:03 +0530 | [diff] [blame] | 201 | |
| 202 | |
| 203 | Navigate To Server Power Page |
| 204 | [Documentation] Navigate To Server Power Page. |
| 205 | |
| 206 | Click Element ${xpath_power_page} |
| 207 | Wait Until Element Is Not Visible ${xpath_progress_bar} timeout=30 |
| 208 | |
| 209 | |
| 210 | Power Off Server |
| 211 | [Documentation] Powering off server. |
| 212 | |
| 213 | Navigate To Server Power Page |
| 214 | ${present}= Run Keyword And Return Status |
| 215 | ... Element Should Be Visible ${xpath_power_shutdown} |
| 216 | IF ${present} |
| 217 | Click Element ${xpath_power_shutdown} |
| 218 | Click Button ${xpath_confirm} |
| 219 | Wait Until Element Is Visible ${xpath_power_poweron} timeout=60 |
| 220 | ELSE |
| 221 | Log To console Server is already powered Off. |
| 222 | END |
| 223 | |
| 224 | |
| 225 | Power On Server |
| 226 | [Documentation] Powering on server. |
| 227 | |
| 228 | Navigate To Server Power Page |
| 229 | ${present}= Run Keyword And Return Status |
| 230 | ... Element Should Be Visible ${xpath_power_power_on} |
| 231 | IF (${present}) |
| 232 | Click Element ${xpath_power_power_on} |
| 233 | Wait Until Element Is Visible ${xpath_power_shutdown} timeout=60 |
| 234 | ELSE |
| 235 | Log To console Server is already powered On. |
| 236 | END |
| 237 | |
| 238 | |
| 239 | Reboot Server |
| 240 | [Documentation] Rebooting the server. |
| 241 | |
| 242 | Navigate To Server Power Page |
| 243 | ${present}= Run Keyword And Return Status |
| 244 | ... Element Should Be Visible ${xpath_power_reboot} |
| 245 | IF ${present} |
| 246 | Click Element ${xpath_power_reboot} |
| 247 | Wait Until Element Is Visible ${xpath_confirm} timeout=30 |
| 248 | Click Button ${xpath_confirm} |
| 249 | Wait Until Element Is Visible ${xpath_power_reboot} timeout=60 |
| 250 | ELSE |
| 251 | Log To console Server is already powered Off, can't reboot. |
| 252 | END |