1*** Settings ***
2Documentation  This is a resource file containing user-defined keywords for new Vue based OpenBMC GUI.
3
4Library        XvfbRobot
5Library        SeleniumLibrary
6Library        SSHLibrary  30 Seconds
7Resource       ../../lib/state_manager.robot
8Variables      ../data/gui_variables.py
9
10
11*** Variables ***
12${obmc_gui_url}              https://${OPENBMC_HOST}
13
14# Default GUI browser and mode is set to "Firefox" and "headless"
15# respectively here.
16${GUI_BROWSER}               ff
17${GUI_MODE}                  headless
18
19
20*** Keywords ***
21
22Open Browser With URL
23    [Documentation]  Open browser with specified URL and returns browser id.
24    [Arguments]  ${URL}  ${browser}=ff  ${mode}=${GUI_MODE}
25
26    # Description of argument(s):
27    # URL      Openbmc GUI URL to be open
28    #          (e.g. https://openbmc-test.mybluemix.net/#/login).
29    # browser  Browser used to open above URL
30    #          (e.g. gc for google chrome, ff for firefox).
31    # mode     Browser opening mode(e.g. headless, header).
32
33    ${browser_ID}=  Run Keyword If  '${mode}' == 'headless'
34    ...  Launch Headless Browser  ${URL}  ${browser}
35    ...  ELSE  Open Browser  ${URL}  ${browser}
36
37    [Return]  ${browser_ID}
38
39
40Launch Header Browser
41    [Documentation]  Open the browser with the URL and
42    ...              login on windows platform.
43    [Arguments]  ${browser_type}=${GUI_BROWSER}
44
45    # Description of argument(s):
46    # browser_type  Type of browser (e.g. "firefox", "chrome", etc.).
47
48    ${BROWSER_ID}=  Open Browser  ${obmc_gui_url}  ${browser_type}
49    Maximize Browser Window
50    Set Global Variable  ${BROWSER_ID}
51
52
53Launch Headless Browser
54    [Documentation]  Launch headless browser.
55    [Arguments]  ${URL}=${obmc_gui_url}  ${browser}=${GUI_BROWSER}
56
57    # Description of argument(s):
58    # URL      Openbmc GUI URL to be open
59    #          (e.g. https://openbmc-test.mybluemix.net/#/login).
60    # browser  Browser to open given URL in headless way
61    #          (e.g. gc for google chrome, ff for firefox).
62
63    Start Virtual Display
64    ${browser_ID}=  Open Browser  ${URL}
65    Set Window Size  1920  1080
66
67    [Return]  ${browser_ID}
68
69
70Launch Browser And Login GUI
71    [Documentation]  Launch browser and login to OpenBMC GUI.
72
73    Open Browser With URL  ${obmc_gui_url}
74    Login GUI  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
75
76
77Login GUI
78    [Documentation]  Login to OpenBMC GUI.
79    [Arguments]  ${username}=${OPENBMC_USERNAME}  ${password}=${OPENBMC_PASSWORD}
80
81    # Description of argument(s):
82    # username  The username to be used for login.
83    # password  The password to be used for login.
84
85    Go To  ${obmc_gui_url}
86    Wait Until Element Is Enabled  ${xpath_textbox_username}
87    Input Text  ${xpath_textbox_username}  ${username}
88    Input Password  ${xpath_textbox_password}  ${password}
89    Click Element  ${xpath_login_button}
90    Wait Until Page Contains  Overview  timeout=60s
91
92
93Logout GUI
94    [Documentation]  Logout of OpenBMC GUI.
95
96    Click Element  ${xpath_root_button_menu}
97    Click Element  ${xpath_logout_button}
98    Wait Until Page Contains Element  ${xpath_login_button}
99
100
101Generate Test Error Log
102    [Documentation]  Generate test error log.
103
104    BMC Execute Command  ${CMD_UNRECOVERABLE_ERROR}
105
106
107Set Timezone In Profile Settings Page
108    [Documentation]  Set the given timezone in profile settings page.
109    [Arguments]  ${timezone}=Default
110
111    # Description of argument(s):
112    # timezone  Timezone to select (eg. Default or Browser_offset).
113
114    Wait Until Page Contains Element  ${xpath_root_button_menu}
115    Click Element  ${xpath_root_button_menu}
116    Click Element  ${xpath_profile_settings}
117    Click Element At Coordinates  ${xpath_default_UTC}  0  0
118    Click Element  ${xpath_profile_save_button}
119
120
121Refresh GUI
122    [Documentation]  Refresh GUI via refresh button in header.
123
124    Click Element  ${xpath_refresh_button}
125    # Added delay for page to load fully after refresh.
126    Sleep  5s
127
128
129Refresh GUI And Verify Element Value
130    [Documentation]  Refresh GUI using refresh button and verify that given element contains expected value.
131    [Arguments]  ${element}  ${expected_value}
132
133    # Description of argument(s):
134    # element         Element whose value need to be checked.
135    # expected_value  Expected value of for the given element.
136
137    # Refresh GUI.
138
139    Click Element  ${xpath_refresh_button}
140
141    # Check element value and verify that it contains expected value.
142    ${element_value}=  Get Text  ${element}
143    Log  ${element_value}
144    Should Contain  ${element_value}  ${expected_value}
145
146
147Reboot BMC via GUI
148    [Documentation]  Reboot BMC via GUI.
149
150    Click Element  ${xpath_operations_menu}
151    Click Element  ${xpath_reboot_bmc_sub_menu}
152    Click Button  ${xpath_reboot_bmc_button}
153    Click Button  ${xpath_confirm_bmc_reboot}
154    Wait Until Keyword Succeeds  2 min  10 sec  Is BMC Unpingable
155    Wait For Host To Ping  ${OPENBMC_HOST}  1 min
156