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