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_logout_button}
101    Wait Until Page Contains Element  ${xpath_login_button}
102
103
104Generate Test Error Log
105    [Documentation]  Generate test error log.
106
107    BMC Execute Command  ${CMD_INTERNAL_FAILURE}
108
109
110Set Timezone In Profile Settings Page
111    [Documentation]  Set the given timezone in profile settings page.
112    [Arguments]  ${timezone}=Default
113
114    # Description of argument(s):
115    # timezone  Timezone to select (eg. Default or Browser_offset).
116
117    Wait Until Page Contains Element  ${xpath_root_button_menu}
118    Click Element  ${xpath_root_button_menu}
119    Click Element  ${xpath_profile_settings}
120    Click Element At Coordinates  ${xpath_default_UTC}  0  0
121    Click Element  ${xpath_profile_save_button}
122