Updated Redfish Poweron/off with Poweron/off server

   - Updated Power On server keywords

Tested:- Successfully run.

Change-Id: Ibb8000c968e7e617512dfb5594fe28f7b206f2c0
Signed-off-by: rramyasr in <rramyasr@in.ibm.com>
diff --git a/gui/gui_test/operations_menu/test_firmware_sub_menu.robot b/gui/gui_test/operations_menu/test_firmware_sub_menu.robot
index 528bf08..0d9ba19 100644
--- a/gui/gui_test/operations_menu/test_firmware_sub_menu.robot
+++ b/gui/gui_test/operations_menu/test_firmware_sub_menu.robot
@@ -5,7 +5,7 @@
 Resource        ../../lib/gui_resource.robot
 
 Suite Setup     Suite Setup Execution
-Suite Teardown  Close Browser
+Suite Teardown  Close All Browsers
 
 Test Tags      Firmware_Sub_Menu
 
@@ -40,7 +40,8 @@
     [Documentation]  Verify existence of all buttons in firmware page at host power off.
     [Tags]  Verify_Existence_Of_All_Buttons_In_Firmware_Page_At_Host_Power_Off
 
-    Redfish Power Off  stack_mode=skip
+    Power Off Server
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_firmware_update_sub_menu}  firmware
 
     Page Should Contain Element  ${xpath_add_file_button}
     Page Should Contain Element  ${xpath_start_update_button}
@@ -50,7 +51,8 @@
     [Documentation]  Verify existence of all sub sections under BMC and server section at poweroff state.
     [Tags]  Verify_Existence_Of_All_Sub_Sections_Under_BMC_And_Server_Section_At_Poweroff_State
 
-    Redfish Power Off  stack_mode=skip  quiet=1
+    Power Off Server
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_firmware_update_sub_menu}  firmware
 
     Page Should Contain  Running image
     Page Should Contain  Backup image
@@ -65,7 +67,8 @@
     [Documentation]  Verify existence of all sub sections under BMC and server section at power on state.
     [Tags]  Verify_Existence_Of_All_Sub_Sections_Under_BMC_And_Server_Section_At_Power_On_State
 
-    Redfish Power On  stack_mode=skip  quiet=1
+    Power On Server
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_firmware_update_sub_menu}  firmware
 
     Page Should Contain  Running image
     Page Should Contain  Backup image
@@ -78,7 +81,8 @@
     [Documentation]  Verify existence of all buttons in firmware page at host power on.
     [Tags]  Verify_Existence_Of_All_Buttons_In_Firmware_Page_At_Host_Power_On
 
-    Redfish Power On  stack_mode=skip
+    Power On Server
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_firmware_update_sub_menu}  firmware
 
     Element Should Be Disabled  ${xpath_add_file_button}
     Element Should Be Disabled  ${xpath_start_update_button}
@@ -93,4 +97,4 @@
     Click Element  ${xpath_operations_menu}
     Click Element  ${xpath_firmware_update_sub_menu}
     Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  firmware
-    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
+    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
\ No newline at end of file
diff --git a/gui/gui_test/operations_menu/test_server_power_operations_sub_menu.robot b/gui/gui_test/operations_menu/test_server_power_operations_sub_menu.robot
index fc0d569..32317fb 100644
--- a/gui/gui_test/operations_menu/test_server_power_operations_sub_menu.robot
+++ b/gui/gui_test/operations_menu/test_server_power_operations_sub_menu.robot
@@ -6,7 +6,7 @@
 Resource        ../../../lib/state_manager.robot
 
 Suite Setup     Launch Browser And Login GUI
-Suite Teardown  Close Browser
+Suite Teardown  Close All Browsers
 Test Setup      Navigate to Server Power Operation Page
 
 Test Tags      Server_Power_Operations_Sub_Menu
@@ -73,34 +73,34 @@
 Verify Immediate Shutdown
     [Documentation]  Verify shutdown after clicking immediate shutdown button.
     [Tags]  Verify_Immediate_Shutdown
-    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
-    ...  AND  Navigate to Server Power Operation Page
+    [Setup]   Launch Browser And Login GUI
+
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_server_power_operations_sub_menu}  server-power-operations
+    Power On Server
 
     Click Element At Coordinates  ${xpath_shutdown_immediate_radio}  0  0
     Click Element  ${xpath_shutdown_button}
-    Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
-    Click Element  ${xpath_confirm_button}
+    Wait And Click Element  ${xpath_confirm_button}
+    Verify And Close Information Message Via GUI
     Wait Until Keyword Succeeds  3 min  15 sec  Element Should Contain  ${xpath_current_power_state}  Off
 
 
 Verify Orderly Shutdown
     [Documentation]  Verify shutdown after clicking orderly shutdown button.
     [Tags]  Verify_Orderly_Shutdown
-    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
-    ...  AND  Navigate to Server Power Operation Page
+    [Setup]  Power On Server
 
     Click Element At Coordinates  ${xpath_shutdown_orderly_radio}  0  0
     Click Element  ${xpath_shutdown_button}
-    Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
-    Click Element  ${xpath_confirm_button}
-    Wait Until Keyword Succeeds  10 min  15 sec  Element Should Contain  ${xpath_current_power_state}  Off
+    Wait And Click Element  ${xpath_confirm_button}
+    Verify And Close Information Message Via GUI
+    Wait Until Keyword Succeeds  15 min  30 sec  Element Should Contain  ${xpath_current_power_state}  Off
 
 
 Verify System State At Power On
     [Documentation]  Verify state of the system in power on state.
     [Tags]  Verify_System_State_At_Power_On
-    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
-    ...  AND  Navigate to Server Power Operation Page
+    [Setup]  Power On Server
 
     Wait Until Keyword Succeeds  15 sec  5 sec   Element Should Contain   ${xpath_current_power_state}  On
 
@@ -108,22 +108,24 @@
 Verify Shutdown And Reboot Buttons Presence At Power On
     [Documentation]  Verify existence of shutdown and reboot buttons at power on.
     [Tags]  Verify_Shutdown_And_Reboot_Buttons_Presence_At_Power_On
-    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
-    ...  AND  Navigate to Server Power Operation Page
+    [Setup]   Launch Browser And Login GUI
+
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_server_power_operations_sub_menu}  server-power-operations
+    Power On Server
 
     # TODO: Implement power on using GUI later.
     Page Should Contain Element  ${xpath_shutdown_button}
     Page Should Contain Element  ${xpath_reboot_button}
 
+
 Verify Host Immediate Reboot
     [Documentation]  Verify host reboot after triggering immediate reboot.
     [Tags]  Verify_Host_Immediate_Reboot
-    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
-    ...  AND  Navigate to Server Power Operation Page
+    [Setup]  Power On Server
 
     Click Element At Coordinates  ${xpath_reboot_immediate_radio}  0  0
     Click Element  ${xpath_reboot_button}
-    Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
+    Wait Until Element Is Visible  ${xpath_confirm_button}  timeout=10
     Click Element  ${xpath_confirm_button}
     Wait Until Keyword Succeeds  3 min  2 sec  Element Should Contain  ${xpath_current_power_state}  Off
     Click Element  ${xpath_refresh_button}
@@ -133,14 +135,16 @@
 Verify Host Orderly Reboot
     [Documentation]  Verify host reboot after triggering orderly reboot.
     [Tags]  Verify_Host_Orderly_Reboot
-    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
-    ...  AND  Navigate to Server Power Operation Page
+    [Setup]  Power On Server
+
+    Navigate To Required Sub Menu  ${xpath_operations_menu}  ${xpath_server_power_operations_sub_menu}  server-power-operation
 
     Click Element  ${xpath_reboot_button}
     # Delay for confirm button to appear.
     Sleep  5s
     Wait Until Element Is Visible  ${xpath_confirm_button}  timeout=10
     Click Element  ${xpath_confirm_button}
+    Verify And Close Information Message Via GUI
     Wait Until Keyword Succeeds  2 min  1 sec  Is Server Status Off
     Click Element  ${xpath_refresh_button}
     Wait Until Keyword Succeeds  10 min  15 sec  Element Should Contain  ${xpath_current_power_state}  On
@@ -168,8 +172,8 @@
 Verify System State At Power Off
     [Documentation]  Verify state of the system in power off state.
     [Tags]  Verify_System_State_At_Power_Off
+    [Setup]  Power Off Server
 
-    Redfish Power Off  stack_mode=skip
     Page Should Contain Element  ${xpath_current_power_state}
     Element Should Contain   ${xpath_current_power_state}  Off
 
@@ -177,25 +181,23 @@
 Verify PowerOn Button Should Present At Power Off
     [Documentation]  Verify existence of poweron button at power off.
     [Tags]  Verify_PowerOn_Button_Should_Present_At_Power_Off
+    [Setup]  Power Off Server
 
-    Redfish Power Off  stack_mode=skip
     # TODO: Implement power off using GUI later.
     Page Should Contain Element  ${xpath_poweron_button}
 
 
 Verify Server Power Operations Page With Readonly User When Host Off State
     [Documentation]  Verify Server Power Operations page with readonly user when Host Off state.
-    [Tags]  Verify_Server_Power_Operations_Page_With_Readonly_User_When_Host_Off_State
     [Setup]  Run Keywords  Power Off Server  AND  Create Readonly User And Login To GUI
     ...      AND  Navigate to Server Power Operation Page
+    [Tags]  Verify_Server_Power_Operations_Page_With_Readonly_User_When_Host_Off_State
     [Teardown]  Delete Readonly User And Logout Current GUI Session
 
     Refresh GUI
     Page Should Contain Element  ${xpath_poweron_button}
     Click Element  ${xpath_poweron_button}
-    Wait Until Page Contains Element  ${xpath_unauthorized_popup}  timeout=10
-    Page Should Contain   Unauthorized
-    Click Element  ${xpath_unauthorized_popup}
+    Verify Error And Unauthorized Message On GUI
 
 
 *** Keywords ***
@@ -208,6 +210,7 @@
     Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  server-power-operations
     Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
 
+
 Is Server Status Off
     [Documentation]  Perform GUI refresh and verify server status to Off.
 
@@ -233,7 +236,4 @@
     Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
     Sleep  5s
     Click Element At Coordinates  ${xpath_confirm_button}  0  0
-    Wait Until Page Contains Element  ${xpath_unauthorized_popup}  timeout=10
-    Page Should Contain  Unauthorized
-    Click Element  ${xpath_unauthorized_popup}
-    Refresh GUI
+    Verify Error And Unauthorized Message On GUI
diff --git a/gui/lib/gui_resource.robot b/gui/lib/gui_resource.robot
index d99d8aa..2681931 100644
--- a/gui/lib/gui_resource.robot
+++ b/gui/lib/gui_resource.robot
@@ -245,15 +245,20 @@
     [Documentation]  Powering on server.
 
     ${boot_state}  ${host_state}=  Redfish Get Boot Progress
+    Log To Console  Current boot state: ${boot_state}
+
     IF  '${boot_state}' == 'OSRunning'
-        Log To Console    Server is already powered On.
+        Log To Console    Server is already powered on.
     ELSE
-        Set BIOS Attribute    pvm_stop_at_standby    Disabled
         Navigate To Server Power Page
+        IF  '${boot_state}' != 'None'
+            Power Off Server
+        END
+        Set BIOS Attribute  pvm_stop_at_standby  Disabled
         Wait And Click Element  ${xpath_power_power_on}
         Wait Until Element Is Visible  ${xpath_power_shutdown}  timeout=60s
         Verify And Close Information Message Via GUI
-        Wait Until Keyword Succeeds  10m  45s  Check Boot Progress State Via Redfish  OSRunning  Enabled
+        Wait Until Keyword Succeeds  15m  45s  Check Boot Progress State Via Redfish  OSRunning  Enabled
     END