17 TC are automated from "Server control" module

Change-Id: If1fa2f36275359ab9323ea7a41c92c870b61632c
Signed-off-by: Sathyajith M S <sathyajith.ms@in.ibm.com>
diff --git a/gui/obmc_gui/data/resource_variables.py b/gui/obmc_gui/data/resource_variables.py
index 6fd1de6..27b33a0 100644
--- a/gui/obmc_gui/data/resource_variables.py
+++ b/gui/obmc_gui/data/resource_variables.py
@@ -17,15 +17,62 @@
     xpath_openbmc_ip = "//*[@id='login__form']/input[1]"
     xpath_display_server_power_status = \
         "//*[@id='header__wrapper']/div/div[3]/a[3]/span"
-    xpath_select_button_orderly_power_shutdown = \
-        "//*[@id='power__soft-shutdown']"
-    xpath_select_button_orderly_power_shutdown_yes = \
-        "//*[@id='power-operations']/div[3]/div[5]/confirm/div/div[2]/" \
-        "button[1]"
     xpath_select_button_power_on = "//*[@id='power__power-on']"
 
+    xpath_select_button_warm_reboot = \
+        "//*[@id='power__warm-boot']"
+    xpath_warm_reboot_warning_message = \
+        "//*[@id='power-operations']" \
+        "/div[3]/div[3]/confirm/div/div[1]/p[1]/strong"
+    xpath_select_button_warm_reboot_no = \
+        "//*[@id='power-operations']/div[3]" \
+        "/div[3]/confirm/div/div[2]/button[2]"
+    text_warm_reboot_warning_message = "warm reboot?"
+    xpath_select_button_warm_reboot_yes = \
+        "//*[@id='power-operations']" \
+        "/div[3]/div[3]/confirm/div/div[2]/button[1]"
+
+    xpath_select_button_cold_reboot = \
+        "//*[@id='power__cold-boot']"
+    xpath_cold_reboot_warning_message = \
+        "//*[@id='power-operations']/div[3]/div[4]" \
+        "/confirm/div/div[1]/p[1]/strong"
+    xpath_select_button_cold_reboot_no = \
+        "//*[@id='power-operations']/div[3]/div[4]" \
+        "/confirm/div/div[2]/button[2]"
+    text_cold_reboot_warning_message = "cold reboot?"
+    xpath_select_button_cold_reboot_yes = \
+        "//*[@id='power-operations']" \
+        "/div[3]/div[4]/confirm/div/div[2]/button[2]"
+
+    xpath_select_button_orderly_shutdown = \
+        "//*[@id='power__soft-shutdown']"
+    xpath_orderly_shutdown_warning_message = \
+        "//*[@id='power-operations']/div[3]/div[5]/" \
+        "confirm/div/div[1]/p[1]/strong"
+    xpath_select_button_orderly_shutdown_button_no = \
+        "//*[@id='power-operations']/div[3]/div[5]"\
+        "/confirm/div/div[2]/button[2]"
+    text_orderly_shutdown_warning_message = "orderly shutdown?"
+    xpath_select_button_orderly_shutdown_yes = \
+        "//*[@id='power-operations']/div[3]/div[5]" \
+        "/confirm/div/div[2]/button[1]"
+
+    xpath_select_button_immediate_shutdown = \
+        "//*[@id='power__hard-shutdown']"
+    xpath_immediate_shutdown_warning_message = \
+        "//*[@id='power-operations']/div[3]/div[6]" \
+        "/confirm/div/div[1]/p[1]/strong"
+    xpath_select_button_immediate_shutdown_no = \
+        "//*[@id='power-operations']/div[3]/div[6]" \
+        "/confirm/div/div[2]/button[2]"
+    text_immediate_shutdown_warning_message = "immediate shutdown?"
+    xpath_select_button_immediate_shutdown_yes = \
+        "//*[@id='power-operations']/div[3]/div[6]" \
+        "/confirm/div/div[2]/button[1]"
+
     obmc_off_state = "Off"
-    obmc_quiesced_state = "Quiesced"
+    obmc_standby_state = "Standby"
     obmc_running_state = "Running"
 
     # Power operation elements needed for power on.
diff --git a/gui/obmc_gui/lib/resource.robot b/gui/obmc_gui/lib/resource.robot
index 29b676a..3e5c90d 100644
--- a/gui/obmc_gui/lib/resource.robot
+++ b/gui/obmc_gui/lib/resource.robot
@@ -25,11 +25,11 @@
 *** Variables ***
 ${openbmc_gui_url}              http://localhost:8080/#/login
 # Default Browser.
-${default_browser}           chrome
+${default_browser}           ff
 
 ${obmc_PowerOff_state}       Off
 ${obmc_PowerRunning_state}   Running
-${obmc_PowerQuiesced_state}  Quiesced
+${obmc_PowerStandby_state}   Standby
 
 *** Keywords ***
 Launch OpenBMC GUI Browser
@@ -89,7 +89,7 @@
 
 Test Setup Execution
     [Documentation]  Verify all the preconditions to be tested.
-    [Arguments]  ${obmc_test_setup_state}=NONE
+    [Arguments]  ${obmc_test_setup_state}=${OBMC_PowerOff_state}
     # Description of argument(s):
     # obmc_test_setup      The OpenBMC required state.
 
@@ -98,12 +98,16 @@
     Log To Console  Verifying the system state and stablity...
     ${obmc_current_state}=  Get Text  ${xpath_display_server_power_status}
     Rpvars  obmc_current_state
-    ${obmc_state}=  Run Keyword And Return Status
+
+    ${obmc_state_status}=  Run Keyword And Return Status
     ...  Should Contain  ${obmc_current_state}  ${obmc_test_setup_state}
-    Return From Keyword If  '${obmc_state}' == 'True'
-    ${obmc_quiesced_state}=  Run Keyword And Return Status
-    ...  Should Contain  ${obmc_current_state}  ${obmc_quiesced_state}
-    Run Keyword If  '${obmc_quiesced_state}' == 'True'  Reboot OpenBMC
+    Return From Keyword If  '${obmc_state_status}' == 'True'
+
+    ${obmc_standby_state}=  Run Keyword And Return Status
+    ...  Should Contain  ${obmc_current_state}  ${obmc_standby_state}
+
+    Run Keyword If  '${obmc_standby_state}' == 'True'
+    ...  Reboot OpenBMC
     Run Keyword If  '${obmc_test_setup_state}' == '${obmc_PowerRunning_state}'
     ...  Power On OpenBMC
     Run Keyword If  '${obmc_test_setup_state}' == '${obmc_PowerOff_state}'
@@ -115,8 +119,8 @@
     Log To Console  Power Off OpenBMC...
     Click Element  ${xpath_display_server_power_status}
     Execute JavaScript  window.scrollTo(0, document.body.scrollHeight)
-    Click Button  ${xpath_select_button_orderly_power_shutdown}
-    Click Yes Button  ${xpath_select_button_orderly_power_shutdown_yes}
+    Click Button  ${xpath_select_button_orderly_shutdown}
+    Click Yes Button  ${xpath_select_button_orderly_shutdown_yes}
     Wait OpenBMC To Become Stable  ${obmc_off_state}
 
 Power On OpenBMC
@@ -132,13 +136,13 @@
 
     Log To Console  Reboting the OpenBMC...
     Click Element  ${xpath_display_server_power_status}
-    Click Button  ${xpath_select_button_orderly_power_shutdown}
-    Click Yes Button  ${xpath_select_button_orderly_power_shutdown_yes}
+    Click Button  ${xpath_select_button_orderly_shutdown}
+    Click Yes Button  ${xpath_select_button_orderly_shutdown_yes}
     Wait OpenBMC To Become Stable  ${obmc_off_state}
 
 Wait OpenBMC To Become Stable
     [Documentation]  Power off the OBMC.
-    [Arguments]  ${OBMC_expected_state}  ${retry_time}=5 min
+    [Arguments]  ${OBMC_expected_state}  ${retry_time}=15 min
     ...  ${retry_interval}=45 sec
     # Description of argument(s):
     # OBMC_expected_state      The OBMC state which is required for test.
@@ -162,10 +166,10 @@
     Should Be Equal  ${obmc_current_state_REST}  ${obmc_required_state}
 
 Click Yes Button
-    [Documentation]  Click the 'yes' button.
+    [Documentation]  Click the 'Yes' button.
     [Arguments]  ${xpath_button_yes}
     # Description of argument(s):
-    # xpath_button_yes      The xpath of 'yes' button.
+    # xpath_button_yes      The xpath of 'Yes' button.
 
     Click Button  ${xpath_button_yes}
 
@@ -233,10 +237,77 @@
     ...  //*[@id='power-operations']/div[${main_element}]/div[${sub_element}]/confirm/div/div[${confirm_msg_elt}]/button[${confirmation}]
 
 GUI Power On
-    [Documentation]  Power on the Host using GUI.
+    [Documentation]  Power on the host using GUI.
 
     Model Server Power Click Button  ${header_wrapper}  ${header_wrapper_elt}
     Page Should Contain  Attempts to power on the server
     Controller Server Power Click Button  power__power-on
     Page Should Contain  Running
 
+Verify Display Content
+    [Documentation]  Verify text content display.
+    [Arguments]  ${display_text}
+
+    # Description of argument(s):
+    # display_text   The text which is expected to be found on the web page.
+
+    Page Should Contain  ${display_text}
+
+Warm Reboot openBMC
+    [Documentation]  Warm reboot the OBMC system.
+
+    Log To Console  Warm Reboting the OpenBMC...
+    Click Element  ${xpath_select_button_warm_reboot}
+    Verify Warning Message Display Text  ${xpath_warm_reboot_warning_message}
+    ...  ${text_warm_reboot_warning_message}
+    Click Yes Button  ${xpath_select_button_warm_reboot_yes}
+    Wait OpenBMC To Become Stable  ${obmc_running_state}
+
+Click No Button
+    [Documentation]  Click the 'No' button.
+    [Arguments]  ${xpath_button_no}
+
+    # Description of argument(s):
+    # xpath_button_no      The xpath of 'No' button.
+
+    Click Button  ${xpath_button_no}
+
+Cold Reboot openBMC
+    [Documentation]  Cold reboot the OBMC system.
+
+    Log To Console  Cold Reboting the OpenBMC...
+    Click Element  ${xpath_select_button_cold_reboot}
+    Verify Warning Message Display Text  ${xpath_cold_reboot_warning_message}
+    ...  ${text_cold_reboot_warning_message}
+    Click Yes Button  ${xpath_select_button_cold_reboot_yes}
+    Wait OpenBMC To Become Stable  ${obmc_running_state}
+
+Orderly Shutdown OpenBMC
+    [Documentation]  Do orderly shutdown the OBMC system.
+
+    Log To Console  Orderly Shutdown the OpenBMC...
+    Click Element  ${xpath_select_button_orderly_shutdown}
+    Verify Warning Message Display Text  ${xpath_orderly_shutdown_warning_message}
+    ...  ${text_orderly_shutdown_warning_message}
+    Click Yes Button  ${xpath_select_button_orderly_shutdown_yes}
+    Wait OpenBMC To Become Stable  ${obmc_off_state}
+
+Immediate Shutdown openBMC
+    [Documentation]  Do immediate shutdown the OBMC system.
+
+    Log To Console  Immediate Shutdown the OpenBMC...
+    Click Element  ${xpath_select_button_immediate_shutdown}
+    Verify Warning Message Display Text
+    ...  ${xpath_immediate_shutdown_warning_message}
+    ...  ${text_immediate_shutdown_warning_message}
+    Click Yes Button  ${xpath_select_button_immediate_shutdown_yes}
+    Wait OpenBMC To Become Stable  ${obmc_off_state}
+
+Verify Warning Message Display Text
+    [Documentation]  Verify the warning message display text.
+    [Arguments]  ${xpath_text_message}  ${text_message}
+
+    # xpath_text_message  Xpath of warning message display.
+    # text_message        Content of the display message info.
+
+    Element Text Should Be  ${xpath_text_message}  ${text_message}
diff --git a/gui/obmc_gui/test/server_control/server_power_operations.robot b/gui/obmc_gui/test/server_control/server_power_operations.robot
new file mode 100644
index 0000000..79abb3a
--- /dev/null
+++ b/gui/obmc_gui/test/server_control/server_power_operations.robot
@@ -0,0 +1,215 @@
+*** Settings ***
+Documentation  This test suite will validate the "OpenBMC" GUI ->
+...            "Server control" main menu -> "Server power
+...            operations" submenu module.
+
+Resource         ../../lib/resource.robot
+Test Setup       Test Setup Execution  ${OBMC_PowerOff_state}
+Test Teardown    Test Teardown Execution
+
+*** Variables ***
+${xpath_select_server_control}           //*[@id="nav__top-level"]/li[3]/button/span
+${xpath_select_server_power_operations}  //a[@href='#/server-control/power-operations']
+${string_server_power_operations}        Server power operations
+${string_current_status}                 Current status
+${string_select_power_operation}         Select a power operation
+${string_warm_reboot}                    Attempts to perform an orderly shutdown before restarting the server
+${string_cold_reboot}                    Shuts down the server immediately, then restarts it
+${string_orderly_shutdown}               Attempts to stop all software on the server before removing power
+${string_immediate_shutdown}             Removes power from the server without waiting for software to stop
+${string_power_on}                       Attempts to power on the server
+
+*** Test Case ***
+# OpenBMC @ Power Off state test cases.
+
+Verify Title Text Should Be Server Power Operations At Power Off
+    [Documentation]  Verify display of title text "Server Power Operations".
+    [Tags]  Verify_Title_Text_Should_Be_Server_Power_Operations_At_Power_Off
+    ...  OBMC_PowerOff_state
+
+    Select Server Power Operations Sub Menu
+    Verify Display Content  ${string_server_power_operations}
+
+Verify Sub Title Text Should Be Current Status At Power Off
+    [Documentation]  Verify display of title text "Current Status".
+    [Tags]  Verify_Sub_Title_Text_Should_Be_Current_Status_At_Power_Off
+    ...  OBMC_PowerOff_state
+
+    Select Server Power Operations Sub Menu
+    Verify Display Content  ${string_current_status}
+
+Verify Sub Title Text Should Be Select Power Operation At Power Off
+    [Documentation]  Verify display of title text "Select a power operation".
+    [Tags]  Verify_Sub_Title_Text_Should_Be_Select_Power_Operation_At_Power_Off
+    ...  OBMC_PowerOff_state
+
+    Select Server Power Operations Sub Menu
+    Verify Display Content  ${string_Select_power_operation}
+
+Verify Power On Button Should Present At ower Off
+    [Documentation]  Verify presence of "Warm reboot" button.
+    [Tags]  Verify_Power_On_Button_Should_Present_At_Power_Off
+    ...  OBMC_PowerOff_State
+
+    Select Server Power Operations Sub Menu
+    Verify Presence of Power Button And Text Info
+    ...  ${xpath_select_button_power_on}  ${string_power_on}
+
+Verify Power On At Power Off
+    [Documentation]  Verify presence of "Warm reboot" button.
+    [Tags]  Verify_Power_On_At_Power_Off
+    ...  OBMC_PowerOff_State
+
+    Power On OpenBMC
+
+
+# OpenBMC @ Power Running state test cases.
+
+Verify Warm Reboot Button Should Present At Power Running
+    [Documentation]  Verify presence of "Warm reboot" button.
+    [Tags]  Verify_Warm_Reboot_Button_Should_Present_At_Power_Running
+    ...  OBMC_PowerRunning_State
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Verify Presence of Power Button And Text Info
+    ...  ${xpath_select_button_warm_reboot}  ${string_warm_reboot}
+
+Verify Cold Reboot Button Should Present At Power Running
+    [Documentation]  Verify presence of "cold reboot" button.
+    [Tags]  Verify_Cold_Reboot_Button_Should_Present_At_Power_Running
+    ...  OBMC_PowerRunning_State
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Verify Presence of Power Button And Text Info
+    ...  ${xpath_select_button_cold_reboot}  ${string_cold_reboot}
+
+Verify Orderly Shutdown Button Should Present At Power Running
+    [Documentation]  Verify presence of "Orderly shutdow " button.
+    [Tags]  Verify_Orderly_Shutdown_Button_Should_Present_At_Power_Running
+    ...  OBMC_PowerRunning_State
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Verify Presence of Power Button And Text Info
+    ...  ${xpath_select_button_orderly_shutdown}  ${string_orderly_shutdown}
+
+Verify Immediate Shutdown Button Should Present At Power Running
+    [Documentation]  Verify presence of "Immediate shutdown" button.
+    [Tags]  Verify_Immediate_Shutdown_Button_Should_Present_At_Power_Running
+    ...  OBMC_PowerRunning_State
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Verify Presence of Power Button And Text Info
+    ...  ${xpath_select_button_immediate_shutdown}  ${string_immediate_shutdown}
+
+Verify Warm Reboot Should Not Happen By Clicking No Button
+    [Documentation]  Verify functionality of warm reboot "No" button clicking.
+    [Tags]  Verify_Warm_Reboot_Should_Not_Happen_By_Clicking_No_Button
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Click Element  ${xpath_select_button_warm_reboot}
+    Verify Warning Message Display Text  ${xpath_warm_reboot_warning_message}
+    ...  ${text_warm_reboot_warning_message}
+    Verify No Button Functionality
+    ...  ${xpath_select_button_warm_reboot_no}
+
+Verify Cold Reboot Should Not Happen By Clicking No Button
+    [Documentation]  Verify functionality of cold reboot "No" button clicking.
+    [Tags]  Verify_Cold_Reboot_Should_Not_Happen_By_Clicking_No_Button
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Click Element  ${xpath_select_button_cold_reboot}
+    Verify Warning Message Display Text  ${xpath_cold_reboot_warning_message}
+    ...  ${text_cold_reboot_warning_message}
+    Verify No Button Functionality
+    ...  ${xpath_select_button_cold_reboot_no}
+
+Verify Orderly Shutdown Should Not Happen By Clicking No Button
+    [Documentation]  Verify functionality of orderly shutdown "No" button clicking.
+    [Tags]  Verify_Orderly_Shutdown_Should_Not_Happen_By_Clicking_No_Button
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Click Element  ${xpath_select_button_orderly_shutdown}
+    Verify Warning Message Display Text  ${xpath_orderly_shutdown_warning_message}
+    ...  ${text_orderly_shutdown_warning_message}
+    Verify No Button Functionality
+    ...  ${xpath_select_button_orderly_shutdown_button_no}
+
+Verify Immediate Shutdown Should Not Happen By Clicking No Button
+    [Documentation]  Verify functionality of immediate shutdown "No" button clicking.
+    [Tags]  Verify_Immediate_Shutdown_Should_Not_Happen_By_Clicking_No_Button
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Click Element  ${xpath_select_button_immediate_shutdown}
+    Verify Warning Message Display Text  ${xpath_immediate_shutdown_warning_message}
+    ...  ${text_immediate_shutdown_warning_message}
+    Verify No Button Functionality
+    ...  ${xpath_select_button_immediate_shutdown_no}
+
+Verify Warm Reboot Should Happen By Clicking Yes Button
+    [Documentation]  Verify functionality of warm reboot "Yes" button clicking.
+    [Tags]  Verify_Warm_Reboot_Should_Happen_By_Clicking_Yes_Button
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Warm Reboot openBMC
+
+Verify Cold Reboot Should Happen By Clicking Yes Button
+    [Documentation]  Verify functionality of cold reboot "Yes" button clicking.
+    [Tags]  Verify_Cold_Reboot_Should_Happen_By_Clicking_Yes_Button
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Cold Reboot openBMC
+
+Verify Orderly Shutdown Should Happen By Clicking Yes Button
+    [Documentation]  Verify functionality of orderly shutdown "Yes" button clicking.
+    [Tags]  Verify_Orderly_Shutdown_Should_Happen_By_Clicking_Yes_Button
+    ...  OBMC_PowerRunning_State
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Orderly Shutdown OpenBMC
+
+Verify Immediate Shutdown Should Happen By Clicking Yes Button
+    [Documentation]  Verify functionality of immediate shutdown "Yes" button clicking.
+    [Tags]  Verify_Immediate_Shutdown_Should_Happen_By_Clicking_Yes_Button
+    ...  OBMC_PowerRunning_State
+    [Setup]  Test Setup Execution  ${OBMC_PowerRunning_state}
+
+    Select Server Power Operations Sub Menu
+    Immediate Shutdown openBMC
+
+*** Keywords ***
+Select Server Power Operations Sub Menu
+    [Documentation]  Selecting of OpenBMC "Server Power Operations" Submenu.
+
+    Click Button  ${xpath_select_server_control}
+    Click Button  ${xpath_select_server_power_operations}
+
+Verify Presence of Power Button And Text Info
+    [Documentation]  Verify the presens fo power button and text message info.
+    [Arguments]      ${power_button}  ${power_button_text}
+
+    # power_button         Xpath of power button.
+    # power_button_text    Text message info.
+
+    Page Should Contain Button  ${power_button}
+    Verify Display Content  ${power_button_text}
+
+Verify No Button Functionality
+    [Documentation]  Verify the functionality of "No" button click.
+    [Arguments]      ${xpath_no_button}
+
+    # xpath_no_button      Xpath of "No" button.
+
+    Click No Button  ${xpath_no_button}
+    ${obmc_current_state}=  Get Text  ${xpath_display_server_power_status}
+    Should Contain  ${obmc_current_state}  ${obmc_running_state}