141747da7SRahul Maheshwari*** Settings ***
241747da7SRahul MaheshwariDocumentation  This is a resource file containing user-defined keywords for new Vue based OpenBMC GUI.
341747da7SRahul Maheshwari
441747da7SRahul MaheshwariLibrary        XvfbRobot
541747da7SRahul MaheshwariLibrary        SeleniumLibrary
641747da7SRahul MaheshwariLibrary        SSHLibrary  30 Seconds
741747da7SRahul MaheshwariResource       ../../lib/state_manager.robot
841747da7SRahul MaheshwariVariables      ../data/gui_variables.py
941747da7SRahul Maheshwari
1041747da7SRahul Maheshwari
1141747da7SRahul Maheshwari*** Variables ***
12d315df4bSMatt Fischer${obmc_gui_url}              https://${OPENBMC_HOST}:${HTTPS_PORT}
13978f91d6Sshahmo32${xpath_power_page}          //*[@data-test-id='appHeader-container-power']
14978f91d6Sshahmo32${xpath_power_shutdown}      //*[@data-test-id='serverPowerOperations-button-shutDown']
15978f91d6Sshahmo32${xpath_power_power_on}      //*[@data-test-id='serverPowerOperations-button-powerOn']
16978f91d6Sshahmo32${xpath_power_reboot}        //*[@data-test-id='serverPowerOperations-button-reboot']
17978f91d6Sshahmo32${xpath_confirm}             //button[contains(text(),'Confirm')]
1841747da7SRahul Maheshwari
194d4ef99fSGeorge Keishing# Default GUI browser and mode is set to "Firefox" and "headless"
2041747da7SRahul Maheshwari# respectively here.
2141747da7SRahul Maheshwari${GUI_BROWSER}               ff
2241747da7SRahul Maheshwari${GUI_MODE}                  headless
2341747da7SRahul Maheshwari
2441747da7SRahul Maheshwari
2541747da7SRahul Maheshwari*** Keywords ***
2641747da7SRahul Maheshwari
2741747da7SRahul MaheshwariOpen Browser With URL
2841747da7SRahul Maheshwari    [Documentation]  Open browser with specified URL and returns browser id.
2941747da7SRahul Maheshwari    [Arguments]  ${URL}  ${browser}=ff  ${mode}=${GUI_MODE}
3041747da7SRahul Maheshwari
3141747da7SRahul Maheshwari    # Description of argument(s):
3241747da7SRahul Maheshwari    # URL      Openbmc GUI URL to be open
3341747da7SRahul Maheshwari    #          (e.g. https://openbmc-test.mybluemix.net/#/login).
3441747da7SRahul Maheshwari    # browser  Browser used to open above URL
3541747da7SRahul Maheshwari    #          (e.g. gc for google chrome, ff for firefox).
3641747da7SRahul Maheshwari    # mode     Browser opening mode(e.g. headless, header).
3741747da7SRahul Maheshwari
3841747da7SRahul Maheshwari    ${browser_ID}=  Run Keyword If  '${mode}' == 'headless'
3941747da7SRahul Maheshwari    ...  Launch Headless Browser  ${URL}  ${browser}
4041747da7SRahul Maheshwari    ...  ELSE  Open Browser  ${URL}  ${browser}
4141747da7SRahul Maheshwari
42*409df05dSGeorge Keishing    RETURN  ${browser_ID}
4341747da7SRahul Maheshwari
4441747da7SRahul Maheshwari
4541747da7SRahul MaheshwariLaunch Header Browser
4641747da7SRahul Maheshwari    [Documentation]  Open the browser with the URL and
4741747da7SRahul Maheshwari    ...              login on windows platform.
4841747da7SRahul Maheshwari    [Arguments]  ${browser_type}=${GUI_BROWSER}
4941747da7SRahul Maheshwari
5041747da7SRahul Maheshwari    # Description of argument(s):
5141747da7SRahul Maheshwari    # browser_type  Type of browser (e.g. "firefox", "chrome", etc.).
5241747da7SRahul Maheshwari
5341747da7SRahul Maheshwari    ${BROWSER_ID}=  Open Browser  ${obmc_gui_url}  ${browser_type}
5441747da7SRahul Maheshwari    Maximize Browser Window
5541747da7SRahul Maheshwari    Set Global Variable  ${BROWSER_ID}
5641747da7SRahul Maheshwari
5741747da7SRahul Maheshwari
5841747da7SRahul MaheshwariLaunch Headless Browser
5941747da7SRahul Maheshwari    [Documentation]  Launch headless browser.
6041747da7SRahul Maheshwari    [Arguments]  ${URL}=${obmc_gui_url}  ${browser}=${GUI_BROWSER}
6141747da7SRahul Maheshwari
6241747da7SRahul Maheshwari    # Description of argument(s):
6341747da7SRahul Maheshwari    # URL      Openbmc GUI URL to be open
6441747da7SRahul Maheshwari    #          (e.g. https://openbmc-test.mybluemix.net/#/login).
6541747da7SRahul Maheshwari    # browser  Browser to open given URL in headless way
6641747da7SRahul Maheshwari    #          (e.g. gc for google chrome, ff for firefox).
6741747da7SRahul Maheshwari
6841747da7SRahul Maheshwari    Start Virtual Display
6941747da7SRahul Maheshwari    ${browser_ID}=  Open Browser  ${URL}
7041747da7SRahul Maheshwari    Set Window Size  1920  1080
7141747da7SRahul Maheshwari
72*409df05dSGeorge Keishing    RETURN  ${browser_ID}
7341747da7SRahul Maheshwari
7441747da7SRahul Maheshwari
7541747da7SRahul MaheshwariLaunch Browser And Login GUI
76b874c315Srramyasr-in    [Documentation]  Launch browser and login to OpenBMC GUI, retry 2 attempts
77b874c315Srramyasr-in    ...              in 1 minute time.
78b874c315Srramyasr-in
794f16a513Srramyasr-in    Wait Until Keyword Succeeds  195 sec   65 sec  Retry Browser Login Attempts
80b874c315Srramyasr-in
81b874c315Srramyasr-in
82b874c315Srramyasr-inRetry Browser Login Attempts
8341747da7SRahul Maheshwari    [Documentation]  Launch browser and login to OpenBMC GUI.
8441747da7SRahul Maheshwari
8541747da7SRahul Maheshwari    Open Browser With URL  ${obmc_gui_url}
8641747da7SRahul Maheshwari    Login GUI  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
8741747da7SRahul Maheshwari
8841747da7SRahul Maheshwari
8941747da7SRahul MaheshwariLogin GUI
9041747da7SRahul Maheshwari    [Documentation]  Login to OpenBMC GUI.
9141747da7SRahul Maheshwari    [Arguments]  ${username}=${OPENBMC_USERNAME}  ${password}=${OPENBMC_PASSWORD}
9241747da7SRahul Maheshwari
9341747da7SRahul Maheshwari    # Description of argument(s):
9441747da7SRahul Maheshwari    # username  The username to be used for login.
9541747da7SRahul Maheshwari    # password  The password to be used for login.
9641747da7SRahul Maheshwari
9741747da7SRahul Maheshwari    Go To  ${obmc_gui_url}
98d1ae7fa3Srramyasr-in    Wait Until Element Is Enabled  ${xpath_login_username_input}
99d1ae7fa3Srramyasr-in    Input Text  ${xpath_login_username_input}  ${username}
100d1ae7fa3Srramyasr-in    Input Password  ${xpath_login_password_input}  ${password}
101978f91d6Sshahmo32    Wait Until Element Is Enabled  ${xpath_login_button}
10241747da7SRahul Maheshwari    Click Element  ${xpath_login_button}
1037ae30a48SRahul Maheshwari    Wait Until Page Contains  Overview  timeout=60s
104319f27ecSrramyasr-in    Wait Until Element Is Not Visible
105319f27ecSrramyasr-in    ...  ${xpath_page_loading_progress_bar}  timeout=120s
10641747da7SRahul Maheshwari
10741747da7SRahul MaheshwariLogout GUI
10841747da7SRahul Maheshwari    [Documentation]  Logout of OpenBMC GUI.
10941747da7SRahul Maheshwari
110a9d9341cSshrsuman123    Click Element  ${xpath_root_button_menu}
11141747da7SRahul Maheshwari    Click Element  ${xpath_logout_button}
11241747da7SRahul Maheshwari    Wait Until Page Contains Element  ${xpath_login_button}
11341747da7SRahul Maheshwari
11441747da7SRahul Maheshwari
11541747da7SRahul MaheshwariGenerate Test Error Log
11641747da7SRahul Maheshwari    [Documentation]  Generate test error log.
11741747da7SRahul Maheshwari
118ae6a3c23Srramyasr-in    BMC Execute Command  ${CMD_UNRECOVERABLE_ERROR}
11954edcbcfSAnusha Dathatri
12054edcbcfSAnusha Dathatri
12154edcbcfSAnusha DathatriSet Timezone In Profile Settings Page
12254edcbcfSAnusha Dathatri    [Documentation]  Set the given timezone in profile settings page.
12354edcbcfSAnusha Dathatri    [Arguments]  ${timezone}=Default
12454edcbcfSAnusha Dathatri
12554edcbcfSAnusha Dathatri    # Description of argument(s):
12654edcbcfSAnusha Dathatri    # timezone  Timezone to select (eg. Default or Browser_offset).
12754edcbcfSAnusha Dathatri
12854edcbcfSAnusha Dathatri    Wait Until Page Contains Element  ${xpath_root_button_menu}
12954edcbcfSAnusha Dathatri    Click Element  ${xpath_root_button_menu}
13054edcbcfSAnusha Dathatri    Click Element  ${xpath_profile_settings}
13154edcbcfSAnusha Dathatri    Click Element At Coordinates  ${xpath_default_UTC}  0  0
13254edcbcfSAnusha Dathatri    Click Element  ${xpath_profile_save_button}
13390c6a81cSAshwini Chandrappa
13490c6a81cSAshwini Chandrappa
13590c6a81cSAshwini ChandrappaRefresh GUI
13690c6a81cSAshwini Chandrappa    [Documentation]  Refresh GUI via refresh button in header.
13790c6a81cSAshwini Chandrappa
13890c6a81cSAshwini Chandrappa    Click Element  ${xpath_refresh_button}
13990c6a81cSAshwini Chandrappa    # Added delay for page to load fully after refresh.
14090c6a81cSAshwini Chandrappa    Sleep  5s
141f942dae4Smeghagn12345
142f942dae4Smeghagn12345
143f942dae4Smeghagn12345Refresh GUI And Verify Element Value
144f942dae4Smeghagn12345    [Documentation]  Refresh GUI using refresh button and verify that given element contains expected value.
145f942dae4Smeghagn12345    [Arguments]  ${element}  ${expected_value}
146f942dae4Smeghagn12345
147f942dae4Smeghagn12345    # Description of argument(s):
148f942dae4Smeghagn12345    # element         Element whose value need to be checked.
149f942dae4Smeghagn12345    # expected_value  Expected value of for the given element.
150f942dae4Smeghagn12345
151f942dae4Smeghagn12345    # Refresh GUI.
152f942dae4Smeghagn12345
153f942dae4Smeghagn12345    Click Element  ${xpath_refresh_button}
154f942dae4Smeghagn12345
155f942dae4Smeghagn12345    # Check element value and verify that it contains expected value.
156f942dae4Smeghagn12345    ${element_value}=  Get Text  ${element}
157f942dae4Smeghagn12345    Log  ${element_value}
158f942dae4Smeghagn12345    Should Contain  ${element_value}  ${expected_value}
159f942dae4Smeghagn12345
1602052fdddSmeghagn
1612052fdddSmeghagnReboot BMC via GUI
1622052fdddSmeghagn    [Documentation]  Reboot BMC via GUI.
1632052fdddSmeghagn
1642052fdddSmeghagn    Click Element  ${xpath_operations_menu}
1652052fdddSmeghagn    Click Element  ${xpath_reboot_bmc_sub_menu}
1662052fdddSmeghagn    Click Button  ${xpath_reboot_bmc_button}
167b9ae25afSMegha G N    Wait Until Keyword Succeeds  30 sec  10 sec  Click Button  ${xpath_confirm_bmc_reboot}
1682052fdddSmeghagn    Wait Until Keyword Succeeds  2 min  10 sec  Is BMC Unpingable
1692052fdddSmeghagn    Wait For Host To Ping  ${OPENBMC_HOST}  1 min
1702a31e512SMegha G N
1712a31e512SMegha G N
1722a31e512SMegha G NAdd DNS Servers And Verify
1732a31e512SMegha G N    [Documentation]  Login to GUI Network page,add DNS server on BMC
1742a31e512SMegha G N    ...  and verify it via BMC CLI.
1752a31e512SMegha G N    [Arguments]  ${dns_server}   ${expected_status}=Valid format
1762a31e512SMegha G N
1772a31e512SMegha G N    # Description of the argument(s):
1782a31e512SMegha G N    # dns_server           A list of static name server IPs to be
1792a31e512SMegha G N    #                      configured on the BMC.
1802a31e512SMegha G N    # expected_status      Expected status while adding DNS server address
1812a31e512SMegha G N    #                      (e.g. Invalid format / Field required).
1822a31e512SMegha G N
1832a31e512SMegha G N    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=15sec
1842a31e512SMegha G N
1852a31e512SMegha G N    Click Button  ${xpath_add_dns_ip_address_button}
1862a31e512SMegha G N    Input Text  ${xpath_input_static_dns}  ${dns_server}
1872a31e512SMegha G N    Click Button  ${xpath_add_button}
1882a31e512SMegha G N    Run keyword if  '${expected_status}' != 'Valid format'
1892a31e512SMegha G N    ...  Run keywords  Page Should Contain  ${expected_status}  AND  Return From Keyword
1902a31e512SMegha G N
1912a31e512SMegha G N    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=10sec
1922a31e512SMegha G N    Wait Until Page Contains  ${dns_server}  timeout=40sec
1932a31e512SMegha G N
1942a31e512SMegha G N    # Check if newly added DNS server is configured on BMC.
1952a31e512SMegha G N    ${cli_name_servers}=  CLI Get Nameservers
1962a31e512SMegha G N    ${cmd_status}=  Run Keyword And Return Status
1972a31e512SMegha G N    ...  List Should Contain Sub List  ${cli_name_servers}  ${dns_server}
198b9e3c716SMegha G N    Run Keyword If  '${expected_status}' == '${HTTP_OK}'
199b9e3c716SMegha G N    ...  Should Be True  ${cmd_status} == ${True}
200b9e3c716SMegha G N    ...  ELSE  Should Not Be True  ${cmd_status}
201978f91d6Sshahmo32
202978f91d6Sshahmo32
203978f91d6Sshahmo32Navigate To Server Power Page
204978f91d6Sshahmo32    [Documentation]  Navigate To Server Power Page.
205978f91d6Sshahmo32
206978f91d6Sshahmo32    Click Element  ${xpath_power_page}
207978f91d6Sshahmo32    Wait Until Element Is Not Visible  ${xpath_progress_bar}  timeout=30
208978f91d6Sshahmo32
209978f91d6Sshahmo32
210978f91d6Sshahmo32Power Off Server
211978f91d6Sshahmo32    [Documentation]  Powering off server.
212978f91d6Sshahmo32
213978f91d6Sshahmo32    Navigate To Server Power Page
214978f91d6Sshahmo32    ${present}=    Run Keyword And Return Status
215978f91d6Sshahmo32    ...  Element Should Be Visible    ${xpath_power_shutdown}
216978f91d6Sshahmo32    IF  ${present}
217978f91d6Sshahmo32      Click Element  ${xpath_power_shutdown}
218978f91d6Sshahmo32      Click Button  ${xpath_confirm}
219978f91d6Sshahmo32      Wait Until Element Is Visible  ${xpath_power_poweron}  timeout=60
220978f91d6Sshahmo32    ELSE
221978f91d6Sshahmo32      Log To console    Server is already powered Off.
222978f91d6Sshahmo32    END
223978f91d6Sshahmo32
224978f91d6Sshahmo32
225978f91d6Sshahmo32Power On Server
226978f91d6Sshahmo32    [Documentation]  Powering on server.
227978f91d6Sshahmo32
228978f91d6Sshahmo32    Navigate To Server Power Page
229978f91d6Sshahmo32    ${present}=    Run Keyword And Return Status
230978f91d6Sshahmo32    ...  Element Should Be Visible    ${xpath_power_power_on}
231978f91d6Sshahmo32    IF  (${present})
232978f91d6Sshahmo32      Click Element  ${xpath_power_power_on}
233978f91d6Sshahmo32      Wait Until Element Is Visible  ${xpath_power_shutdown}  timeout=60
234978f91d6Sshahmo32    ELSE
235978f91d6Sshahmo32      Log To console    Server is already powered On.
236978f91d6Sshahmo32    END
237978f91d6Sshahmo32
238978f91d6Sshahmo32
239978f91d6Sshahmo32Reboot Server
240978f91d6Sshahmo32    [Documentation]  Rebooting the server.
241978f91d6Sshahmo32
242978f91d6Sshahmo32    Navigate To Server Power Page
243978f91d6Sshahmo32    ${present}=    Run Keyword And Return Status
244978f91d6Sshahmo32    ...  Element Should Be Visible    ${xpath_power_reboot}
245978f91d6Sshahmo32    IF  ${present}
246978f91d6Sshahmo32      Click Element  ${xpath_power_reboot}
247978f91d6Sshahmo32      Wait Until Element Is Visible  ${xpath_confirm}  timeout=30
248978f91d6Sshahmo32      Click Button  ${xpath_confirm}
249978f91d6Sshahmo32      Wait Until Element Is Visible  ${xpath_power_reboot}  timeout=60
250978f91d6Sshahmo32    ELSE
251978f91d6Sshahmo32      Log To console    Server is already powered Off, can't reboot.
252978f91d6Sshahmo32    END
253