Enable GUI headerless run, init, new GUI directory structure.
Resolves openbmc/openbmc-test-automation#736
Change-Id: I9d6cb1eca31585dc2f85b78ae03de8ac8c799fd9
Signed-off-by: Sathyajith M S <sathyajith.ms@in.ibm.com>
diff --git a/gui/obmc_asmi/__init__.robot b/gui/obmc_asmi/__init__.robot
new file mode 100644
index 0000000..c747479
--- /dev/null
+++ b/gui/obmc_asmi/__init__.robot
@@ -0,0 +1,36 @@
+*** Settings ***
+Documentation Main initialization file for the test cases contained in this
+... directory and setting up the test environment variables.
+
+Resource lib/resource.robot
+Suite Setup Initializing Setup
+Suite Teardown Init Teardown Steps
+
+*** Keywords ***
+Initializing Setup
+ [Documentation] Initialize test environment.
+ Launch OpenBMC GUI Browser
+ Login OpenBMC GUI
+ Get OpenBMC System Info
+ Initial Message
+ LogOut OpenBMC GUI
+
+Initial Message
+ [Documentation] Display initial info about the test cases.
+ Rpvars EXECDIR
+ Rprint Timen OBMC_GUI Testing ==> [IN PROGRESS]
+ Print Dashes 0 100 1 =
+
+Get OpenBMC System Info
+ [Documentation] Display open BMC system info like system name and IP.
+ ${OPENBMC_HOST_NAME}= Get Hostname From IP Address ${OPENBMC_HOST}
+ Rpvars OPENBMC_HOST OPENBMC_HOST_NAME
+ ${build_info} ${stderr} ${rc}= BMC Execute Command cat /etc/os-release
+ ... print_output=1
+ Print Dashes 0 100 1 =
+
+Init Teardown Steps
+ [Documentation] End the test execution by closing browser.
+ Print Timen OBMC_GUI Testing ==> [Finished]
+ Print Dashes 0 100 1 =
+ Close Browser
diff --git a/gui/obmc_asmi/data/resource_variables.py b/gui/obmc_asmi/data/resource_variables.py
new file mode 100644
index 0000000..21f5b3f
--- /dev/null
+++ b/gui/obmc_asmi/data/resource_variables.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+
+r"""
+Contains xpaths and related string constants applicable to all openBMC GUI
+menus.
+"""
+
+class resource_variables():
+
+ xpath_textbox_username = "//*[@id='username']"
+ xpath_textbox_password = "//*[@id='password']"
+ xpath_button_login = "//*[@id='login__submit']"
+ xpath_button_logout = "//*[@id='header']/a"
diff --git a/gui/obmc_asmi/lib/resource.robot b/gui/obmc_asmi/lib/resource.robot
new file mode 100644
index 0000000..bfba9ab
--- /dev/null
+++ b/gui/obmc_asmi/lib/resource.robot
@@ -0,0 +1,93 @@
+*** Settings ***
+Documentation This is a resource file of OpenBMC ASMI It contains the
+... user-defined keywords which are available to all gui modules
+
+Library String
+Library Collections
+Library DateTime
+Library XvfbRobot
+Library OperatingSystem
+Library Selenium2Library 120 120
+Library AngularJSLibrary
+Library SSHLibrary 30 Seconds
+Library Process
+Library supporting_libs.py
+Library ../../../lib/gen_print.py
+Library ../../../lib/gen_robot_print.py
+Library ../../../lib/gen_valid.py
+Library ../../../lib/gen_robot_ssh.py
+Library ../../../lib/bmc_ssh_utils.py
+Resource ../../../lib/resource.txt
+Variables ../data/resource_variables.py
+
+*** Variables ***
+# TO Do: Change the variable once the code finally switches to the OpenBMC.
+${obmc_gui_url} https://openbmc-test.mybluemix.net/#/login
+# Default Browser.
+${default_browser} chrome
+
+*** Keywords ***
+Launch OpenBMC GUI Browser
+ [Documentation] Launch the OpenBMC GUI URL on a browser.
+ # By default uses headless mode, otherwise, the GUI browser.
+ ${op_system}= Get Operating System
+ Run Keyword If '${op_system}' == 'windows'
+ ... Launch Browser in Windows Platform
+ ... ELSE
+ ... Launch Headless Browser
+
+Get Operating System
+ [Documentation] Identify platform/OS.
+ ${curdir_lower_case}= Convert To Lowercase ${CURDIR}
+ ${windows_platform}= Run Keyword And Return Status
+ ... Should Contain ${curdir_lower_case} c:\
+ ${op_system}= Run Keyword If '${windows_platform}' == 'True'
+ ... Set Variable windows
+ ... ELSE
+ ... Set Variable linux
+ [Return] ${op_system}
+
+Launch Browser in Windows Platform
+ [Documentation] Open the browse with the URL and login on windows platform.
+ ${BROWSER_ID}= Open Browser ${obmc_gui_url} ${default_browser}
+ Maximize Browser Window
+ Set Global Variable ${BROWSER_ID}
+
+Launch Headless Browser
+ [Documentation] Launch headless browser.
+ Start Virtual Display 1920 1080
+ ${BROWSER_ID}= Open Browser ${obmc_gui_url}
+ Set Global Variable ${BROWSER_ID}
+ Set Window Size 1920 1080
+
+OpenBMC Test Setup
+ [Documentation] Verify all the preconditions to be tested.
+ Rprint Timen ${TEST NAME}:${TESTDOCUMENTATION} ==> [STARTED]
+ Print Dashes 0 100 1 =
+ Login OpenBMC GUI
+
+Login OpenBMC GUI
+ [Documentation] Perform login to open BMC GUI.
+ [Arguments] ${username}=${OPENBMC_USERNAME}
+ ... ${password}=${OPENBMC_PASSWORD}
+ # Description of argument(s):
+ # username The username.
+ # password The password.
+ Go To ${obmc_gui_url}
+ Input Text ${xpath_textbox_username} ${username}
+ Input Password ${xpath_textbox_password} ${password}
+ Click Button ${xpath_button_login}
+ Wait Until Element Is Enabled ${xpath_button_logout}
+
+LogOut OpenBMC GUI
+ [Documentation] Log out of OpenBMC GUI.
+ SSHLibrary.Close All Connections
+ click button ${xpath_button_logout}
+ Wait Until Page Contains Element ${xpath_button_login}
+
+OpenBMC Test Closure
+ [Documentation] Do final closure activities of test case execution.
+ Rprint Pgm Footer
+ Print Dashes 0 100 1 =
+ LogOut OpenBMC GUI
+
diff --git a/gui/obmc_asmi/lib/supporting_libs.py b/gui/obmc_asmi/lib/supporting_libs.py
new file mode 100644
index 0000000..40ea135
--- /dev/null
+++ b/gui/obmc_asmi/lib/supporting_libs.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+r"""
+This is an extended user library to support Robot Selenium code.
+The class contains functions which the robot framework will use
+and import as a user-defined keyword.
+"""
+
+import socket
+
+class supporting_libs():
+
+ def get_hostname_from_ip_address(self, ip):
+ return socket.gethostbyaddr(ip)[0]
+
+
+
diff --git a/gui/obmc_asmi/test/server_overview/server_overview.robot b/gui/obmc_asmi/test/server_overview/server_overview.robot
new file mode 100644
index 0000000..a24aa32
--- /dev/null
+++ b/gui/obmc_asmi/test/server_overview/server_overview.robot
@@ -0,0 +1,26 @@
+*** Settings ***
+Documentation This test suite will validate the "OpenBMC ASMI Menu ->
+... Server Overview" module.
+
+Resource ../../lib/resource.robot
+Test Setup OpenBMC Test Setup
+Test Teardown OpenBMC Test Closure
+
+*** Variables ***
+${xpath_select_overview_1} //*[@id="nav__top-level"]/li[1]/a/span
+${xpath_select_overview_2} //a[@href='#/overview/system']
+${string_display_content} Server overview
+
+*** Test Case ***
+Verify Title Text Content
+ [Documentation] Verify display of title text from "Server Overview"
+ ... module of OpenBMC GUI.
+ [Tags] Verify_Title_Text_Content
+ Verify Display Content
+
+*** Keywords ***
+Verify Display Content
+ [Documentation] Verify displaying of text.
+ Click Button ${xpath_select_overview_1}
+ Click Button ${xpath_select_overview_2}
+ Page Should Contain ${string_display_content}