1*** Settings ***
2
3Documentation  Test Open BMC GUI BMC host information under GUI Header.
4
5Library        DateTime
6
7Resource        ../../lib/resource.robot
8
9Suite Setup     Launch Browser And Login OpenBMC GUI
10Suite Teardown  Close Browser
11
12
13*** Variables ***
14${xpath_bmc_ip}                 //*[contains(@class, "header__server-ip")]
15${xpath_select_refresh_button}  //*[text()[contains(.,"Refresh")]]
16${xpath_select_date_text}       //*[@class="header__refresh"]
17${xpath_header_scroll}          //*[contains(@class,"header__action")]
18
19*** Test Cases ***
20
21Verify Server Power Button
22    [Documentation]  Verify server power page on clicking server power button.
23    [Tags]  Verify_Server_Power_Button
24
25    Wait Until Element Is Visible   ${xpath_select_server_power}
26    Click Element  ${xpath_select_server_power}
27    Wait Until Page Contains  Server power operations
28
29Verify Server Health Button
30    [Documentation]  Verify server health page on clicking server health button.
31    [Tags]  Verify_Server_Health_Button
32
33    Wait Until Element Is Visible   ${xpath_select_server_health}
34    Click Element  ${xpath_select_server_health}
35    Wait Until Page Contains  All events from the BMC
36
37Verify IP address
38    [Documentation]  Verify BMC IP address displayed in GUI header.
39    [Tags]  Verify_IP_address
40
41    # NOTE: gui_displayed_ip can be either a host name or an IP address.
42    #       (e.g. "machinex" or "xx.xx.xx.xx").
43    ${gui_displayed_ip}=  Get Text  ${xpath_bmc_ip}
44    Should Contain  ${gui_displayed_ip}  ${OPENBMC_HOST}
45
46Verify Refresh Button
47    [Documentation]  Verify Refresh Button in GUI header.
48    [Tags]  Verify_Refresh_Button
49
50    # Verify power is on after refresh button.
51
52    Expected Initial Test State  Off
53    Wait Until Element Is Visible  ${xpath_select_refresh_button}
54    Click Element  ${xpath_select_refresh_button}
55    GUI Power On
56    Wait Until Element Is Visible  ${xpath_select_refresh_button}
57    Click Element  ${xpath_select_refresh_button}
58    Wait Until Page Contains  Running
59
60Verify Date Last Refreshed
61    [Documentation]  Verify Date Last Refreshed text in GUI header.
62    [Tags]  Verify_Date_Last_Refreshed
63
64    Wait Until Element Is Visible  ${xpath_select_date_text}
65    ${date_info_1st_read}=  Get Text  ${xpath_select_date_text}
66    Should Not Be Empty  ${date_info_1st_read}
67    ${current_date}=  Get Time
68    ${date_conversion}=  Convert Date  ${current_date}  result_format=%b %-d %Y
69
70    ${mmmdd}  ${yyyy}=  Split String From Right  ${date_conversion}  ${SPACE}  1
71    Should Contain  ${date_info_1st_read}  ${mmmdd}  msg=Month and day mismatch.
72    Should Contain  ${date_info_1st_read}  ${yyyy}  msg=Year mismatch.
73
74    # Refresh button pressed.
75    Click Element  ${xpath_select_refresh_button}
76    Sleep  2s
77
78    ${date_info_2nd_read}=  Get Text  ${xpath_select_date_text}
79    ${current_date}=  Get Time
80    ${date_conversion}=  Convert Date  ${current_date}  result_format=%b %-d %Y
81
82    ${mmmdd}  ${yyyy}=  Split String From Right  ${date_conversion}  ${SPACE}  1
83    Should Contain  ${date_info_1st_read}  ${mmmdd}  msg=Month and day mismatch.
84    Should Contain  ${date_info_1st_read}  ${yyyy}  msg=Year mismatch.
85
86    # Comparison between 1st and 2nd read.
87    Should Not Be Equal As Strings  ${date_info_1st_read}
88    ...  ${date_info_2nd_read}
89
90Verify GUI Header Scrolls
91    [Documentation]  Verify GUI header scrolls on click "Server Info" element.
92    [Tags]  Verify_GUI_Header_Scrolls
93
94    ${current_browser_width}  ${current_browser_height}=  Get Window Size
95    Maximize Browser Window
96    ${max_browser_width}  ${max_browser_height}=  Get Window Size
97    # Shrink the browser to half from max size.
98    ${shrink_browser_width}=  Evaluate  ${max_browser_width} / 2
99    ${shrink_browser_height}=  Evaluate  ${max_browser_height} / 2
100    # Reduce the browser size which enables scroll element.
101    Set Window Size  ${shrink_browser_width}  ${shrink_browser_height}
102    Click Element  ${xpath_header_scroll}
103    # Below element is to scroll back.
104    Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
105    Click Element  ${xpath_header_scroll}
106    # Restore to original browser size.
107    Set Window Size  ${current_browser_width}  ${current_browser_height}
108
109
110OpenBMC GUI Logoff
111    [Documentation]  Log out from openBMC GUI.
112    [Tags]  OpenBMC_GUI_Logoff
113
114
115    Click Button  ${xpath_button_user_action}
116    Click Button  ${xpath_button_logout}
117    Wait Until Page Contains Element  ${xpath_button_login}
118