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${CMD_INTERNAL_FAILURE}      busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
20...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
21...  xyz.openbmc_project.Logging.Entry.Level.Error 0
22
23
24*** Keywords ***
25
26Open Browser With URL
27    [Documentation]  Open browser with specified URL and returns browser id.
28    [Arguments]  ${URL}  ${browser}=ff  ${mode}=${GUI_MODE}
29
30    # Description of argument(s):
31    # URL      Openbmc GUI URL to be open
32    #          (e.g. https://openbmc-test.mybluemix.net/#/login).
33    # browser  Browser used to open above URL
34    #          (e.g. gc for google chrome, ff for firefox).
35    # mode     Browser opening mode(e.g. headless, header).
36
37    ${browser_ID}=  Run Keyword If  '${mode}' == 'headless'
38    ...  Launch Headless Browser  ${URL}  ${browser}
39    ...  ELSE  Open Browser  ${URL}  ${browser}
40
41    [Return]  ${browser_ID}
42
43
44Launch Header Browser
45    [Documentation]  Open the browser with the URL and
46    ...              login on windows platform.
47    [Arguments]  ${browser_type}=${GUI_BROWSER}
48
49    # Description of argument(s):
50    # browser_type  Type of browser (e.g. "firefox", "chrome", etc.).
51
52    ${BROWSER_ID}=  Open Browser  ${obmc_gui_url}  ${browser_type}
53    Maximize Browser Window
54    Set Global Variable  ${BROWSER_ID}
55
56
57Launch Headless Browser
58    [Documentation]  Launch headless browser.
59    [Arguments]  ${URL}=${obmc_gui_url}  ${browser}=${GUI_BROWSER}
60
61    # Description of argument(s):
62    # URL      Openbmc GUI URL to be open
63    #          (e.g. https://openbmc-test.mybluemix.net/#/login).
64    # browser  Browser to open given URL in headless way
65    #          (e.g. gc for google chrome, ff for firefox).
66
67    Start Virtual Display
68    ${browser_ID}=  Open Browser  ${URL}
69    Set Window Size  1920  1080
70
71    [Return]  ${browser_ID}
72
73
74Launch Browser And Login GUI
75    [Documentation]  Launch browser and login to OpenBMC GUI.
76
77    Open Browser With URL  ${obmc_gui_url}
78    Login GUI  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
79
80
81Login GUI
82    [Documentation]  Login to OpenBMC GUI.
83    [Arguments]  ${username}=${OPENBMC_USERNAME}  ${password}=${OPENBMC_PASSWORD}
84
85    # Description of argument(s):
86    # username  The username to be used for login.
87    # password  The password to be used for login.
88
89    Go To  ${obmc_gui_url}
90    Wait Until Element Is Enabled  ${xpath_textbox_username}
91    Input Text  ${xpath_textbox_username}  ${username}
92    Input Password  ${xpath_textbox_password}  ${password}
93    Click Element  ${xpath_login_button}
94    Wait Until Page Contains  Overview  timeout=60s
95
96
97Logout GUI
98    [Documentation]  Logout of OpenBMC GUI.
99
100    Click Element  ${xpath_root_button_menu}
101    Click Element  ${xpath_logout_button}
102    Wait Until Page Contains Element  ${xpath_login_button}
103
104
105Generate Test Error Log
106    [Documentation]  Generate test error log.
107
108    BMC Execute Command  ${CMD_INTERNAL_FAILURE}
109
110
111Set Timezone In Profile Settings Page
112    [Documentation]  Set the given timezone in profile settings page.
113    [Arguments]  ${timezone}=Default
114
115    # Description of argument(s):
116    # timezone  Timezone to select (eg. Default or Browser_offset).
117
118    Wait Until Page Contains Element  ${xpath_root_button_menu}
119    Click Element  ${xpath_root_button_menu}
120    Click Element  ${xpath_profile_settings}
121    Click Element At Coordinates  ${xpath_default_UTC}  0  0
122    Click Element  ${xpath_profile_save_button}
123
124
125Refresh GUI
126    [Documentation]  Refresh GUI via refresh button in header.
127
128    Click Element  ${xpath_refresh_button}
129    # Added delay for page to load fully after refresh.
130    Sleep  5s
131