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_select_server_control}  //*[@id="header__wrapper"]/div/div[2]/p[2]
15${xpath_select_refresh_button}  //*[@id="header__wrapper"]/div/div[3]/button
16${xpath_select_date_text}       //*[@id="header__wrapper"]/div/div[3]/p/span
17${xpath_header_scroll_front}    //*[@id="header__wrapper"]/div/div[3]/a[1]/span
18${xpath_header_scroll_back}     //*[@id="header__wrapper"]/div/div[3]/a[1]/i
19
20*** Test Cases ***
21
22Verify IP address
23    [Documentation]  Verify BMC IP address displayed in GUI header.
24    [Tags]  Verify_IP_address
25
26    # NOTE: gui_displayed_ip can be either a host name or an IP address.
27    #       (e.g. "machinex" or "xx.xx.xx.xx").
28    ${gui_displayed_ip}=  Get Text  ${xpath_select_server_control}
29    Should Contain  ${gui_displayed_ip}  ${OPENBMC_HOST}
30
31
32Verify Refresh Button
33    [Documentation]  Verify Refresh Button in GUI header.
34    [Tags]  Verify_Refresh_Button
35
36    # Verify power is on after refresh button.
37
38    Expected Initial Test State  Off
39    Click Element  ${xpath_select_refresh_button}
40    GUI Power On
41    Click Element  ${xpath_select_refresh_button}
42    Wait Until Page Contains  Running
43
44Verify Date Last Refreshed
45    [Documentation]  Verify Date Last Refreshed text in GUI header.
46    [Tags]  Verify_Date_Last_Refreshed
47
48    ${date_info_1st_read}=  Get Text  ${xpath_select_date_text}
49    ${current_date}=  Get Time
50    ${date_conversion}=  Convert Date  ${current_date}  result_format=%b %d %Y
51
52    ${mmmdd}  ${yyyy}=  Split String From Right  ${date_conversion}  ${SPACE}  1
53    Should Contain  ${date_info_1st_read}  ${mmmdd}  msg=Month and day mismatch.
54    Should Contain  ${date_info_1st_read}  ${yyyy}  msg=Year mismatch.
55
56    # Refresh button pressed.
57    Click Element  ${xpath_select_refresh_button}
58    Sleep  2s
59
60    ${date_info_2nd_read}=  Get Text  ${xpath_select_date_text}
61    ${current_date}=  Get Time
62    ${date_conversion}=  Convert Date  ${current_date}  result_format=%b %d %Y
63
64    ${mmmdd}  ${yyyy}=  Split String From Right  ${date_conversion}  ${SPACE}  1
65    Should Contain  ${date_info_1st_read}  ${mmmdd}  msg=Month and day mismatch.
66    Should Contain  ${date_info_1st_read}  ${yyyy}  msg=Year mismatch.
67
68    # Comparison between 1st and 2nd read.
69    Should Not Be Equal As Strings  ${date_info_1st_read}
70    ...  ${date_info_2nd_read}
71
72Verify GUI Header Scrolls
73    [Documentation]  Verify GUI header scrolls on click "Server Info" element.
74    [Tags]  Verify_GUI_Header_Scrolls
75
76    ${current_browser_width}  ${current_browser_height}=  Get Window Size
77    Maximize Browser Window
78    ${max_browser_width}  ${max_browser_height}=  Get Window Size
79    # Shrink the browser to half from max size.
80    ${shrink_browser_width}=  Evaluate  ${max_browser_width} / 2
81    ${shrink_browser_height}=  Evaluate  ${max_browser_height} / 2
82    # Reduce the browser size which enables scroll element.
83    Set Window Size  ${shrink_browser_width}  ${shrink_browser_height}
84    Click Element  ${xpath_header_scroll_front}
85    # Below element is to scroll back.
86    Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
87    Click Element  ${xpath_header_scroll_back}
88    # Restore to original browser size.
89    Set Window Size  ${current_browser_width}  ${current_browser_height}
90