Fix GUI Server Power operations suite failures

Resolves openbmc/openbmc-test-automation#1885

Change-Id: Iedefa5ef809c5c4bb3962994d2d5df48468b90eb
Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
diff --git a/gui/data/resource_variables.py b/gui/data/resource_variables.py
index aa4892d..1dfe247 100644
--- a/gui/data/resource_variables.py
+++ b/gui/data/resource_variables.py
@@ -17,15 +17,12 @@
     xpath_openbmc_url = "http://localhost:8080/#/login"
     xpath_openbmc_ip = "//*[@id='login__form']/input[1]"
     xpath_power_indicator = "//*[@id='power-indicator-bar']"
-    xpath_display_server_power_status = \
-        "//*[@id='header__wrapper']/div/div[3]/a[3]/span"
     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_operation_warning_message = \
+        "//*[@class='inline__confirm active']"
     xpath_select_button_warm_reboot_no = \
         "//*[@id='power-operations']/div[3]" \
         "/div[3]/confirm/div/div[2]/button[2]"
@@ -36,9 +33,6 @@
 
     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]"
@@ -49,9 +43,6 @@
 
     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]"
@@ -62,9 +53,6 @@
 
     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]"
diff --git a/gui/lib/resource.robot b/gui/lib/resource.robot
index b59f2df..11b3386 100644
--- a/gui/lib/resource.robot
+++ b/gui/lib/resource.robot
@@ -122,6 +122,7 @@
     Log To Console  Verifying the system state and stablity...
 
     Click Element  ${xpath_select_server_power}
+    Wait Until Page Does Not Contain  Unreachable
     ${obmc_current_state}=  Get Text  ${xpath_power_indicator}
     Rpvars  obmc_current_state
 
@@ -144,7 +145,7 @@
     [Documentation]  Power off the OBMC system.
 
     Log To Console  Power Off OpenBMC...
-    Click Element  ${xpath_display_server_power_status}
+    Click Element  ${xpath_select_server_power}
     Execute JavaScript  window.scrollTo(0, document.body.scrollHeight)
     Click Button  ${xpath_select_button_orderly_shutdown}
     Click Yes Button  ${xpath_select_button_orderly_shutdown_yes}
@@ -154,7 +155,7 @@
     [Documentation]  Power on the OBMC system.
 
     Log To Console  Power On OpenBMC...
-    Click Element  ${xpath_display_server_power_status}
+    Click Element  ${xpath_select_server_power}
     Click Button  ${xpath_select_button_power_on }
     Wait OpenBMC To Become Stable  ${obmc_running_state}
 
@@ -162,7 +163,7 @@
     [Documentation]  Rebooting the OBMC system.
 
     Log To Console  Reboting the OpenBMC...
-    Click Element  ${xpath_display_server_power_status}
+    Click Element  ${xpath_select_server_power}
     Click Button  ${xpath_select_button_orderly_shutdown}
     Click Yes Button  ${xpath_select_button_orderly_shutdown_yes}
     Wait OpenBMC To Become Stable  ${obmc_off_state}
@@ -179,7 +180,7 @@
     #                          above total wait time.
 
     Wait Until Keyword Succeeds  ${retry_time}  ${retry_interval}
-    ...  Wait Until Element Contains  ${xpath_display_server_power_status}
+    ...  Wait Until Element Contains  ${xpath_select_server_power}
     ...  ${obmc_expected_state}
     Wait Until Keyword Succeeds  ${retry_time}  ${retry_interval}
     ...  Verify OpenBMC State From REST Interface  ${obmc_expected_state}
@@ -287,7 +288,7 @@
 
     Log To Console  Warm Reboting the OpenBMC...
     Click Element  ${xpath_select_button_warm_reboot}
-    Verify Warning Message Display Text  ${xpath_warm_reboot_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_warm_reboot_warning_message}
     Click Yes Button  ${xpath_select_button_warm_reboot_yes}
     Wait OpenBMC To Become Stable  ${obmc_running_state}
@@ -306,7 +307,7 @@
 
     Log To Console  Cold Reboting the OpenBMC...
     Click Element  ${xpath_select_button_cold_reboot}
-    Verify Warning Message Display Text  ${xpath_cold_reboot_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_cold_reboot_warning_message}
     Click Yes Button  ${xpath_select_button_cold_reboot_yes}
     Wait OpenBMC To Become Stable  ${obmc_running_state}
@@ -316,7 +317,7 @@
 
     Log To Console  Orderly Shutdown the OpenBMC...
     Click Element  ${xpath_select_button_orderly_shutdown}
-    Verify Warning Message Display Text  ${xpath_orderly_shutdown_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_orderly_shutdown_warning_message}
     Click Yes Button  ${xpath_select_button_orderly_shutdown_yes}
     Wait OpenBMC To Become Stable  ${obmc_off_state}
@@ -327,7 +328,7 @@
     Log To Console  Immediate Shutdown the OpenBMC...
     Click Element  ${xpath_select_button_immediate_shutdown}
     Verify Warning Message Display Text
-    ...  ${xpath_immediate_shutdown_warning_message}
+    ...  ${xpath_operation_warning_message}
     ...  ${text_immediate_shutdown_warning_message}
     Click Yes Button  ${xpath_select_button_immediate_shutdown_yes}
     Wait OpenBMC To Become Stable  ${obmc_off_state}
@@ -339,7 +340,7 @@
     # 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}
+    Element Should Contain  ${xpath_text_message}  ${text_message}
 
 
 Expected Initial Test State
diff --git a/gui/test/server_control/test_obmc_gui_server_power_operations.robot b/gui/test/server_control/test_obmc_gui_server_power_operations.robot
index e3e2790..d59dfd7 100644
--- a/gui/test/server_control/test_obmc_gui_server_power_operations.robot
+++ b/gui/test/server_control/test_obmc_gui_server_power_operations.robot
@@ -8,7 +8,7 @@
 Test Teardown    Test Teardown Execution
 
 *** Variables ***
-${xpath_select_server_control}           //*[@id="nav__top-level"]/li[3]/button/span
+${xpath_select_server_control}           //*[contains(@class,"btn-control")]
 ${xpath_select_server_power_operations}  //a[@href='#/server-control/power-operations']
 ${string_server_power_operations}        Server power operations
 ${string_current_status}                 Current status
@@ -142,7 +142,7 @@
 
     Select Server Power Operations Sub Menu
     Click Element  ${xpath_select_button_warm_reboot}
-    Verify Warning Message Display Text  ${xpath_warm_reboot_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_warm_reboot_warning_message}
     Verify No Button Functionality
     ...  ${xpath_select_button_warm_reboot_no}
@@ -154,7 +154,7 @@
 
     Select Server Power Operations Sub Menu
     Click Element  ${xpath_select_button_cold_reboot}
-    Verify Warning Message Display Text  ${xpath_cold_reboot_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_cold_reboot_warning_message}
     Verify No Button Functionality
     ...  ${xpath_select_button_cold_reboot_no}
@@ -166,7 +166,7 @@
 
     Select Server Power Operations Sub Menu
     Click Element  ${xpath_select_button_orderly_shutdown}
-    Verify Warning Message Display Text  ${xpath_orderly_shutdown_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_orderly_shutdown_warning_message}
     Verify No Button Functionality
     ...  ${xpath_select_button_orderly_shutdown_button_no}
@@ -178,7 +178,7 @@
 
     Select Server Power Operations Sub Menu
     Click Element  ${xpath_select_button_immediate_shutdown}
-    Verify Warning Message Display Text  ${xpath_immediate_shutdown_warning_message}
+    Verify Warning Message Display Text  ${xpath_operation_warning_message}
     ...  ${text_immediate_shutdown_warning_message}
     Verify No Button Functionality
     ...  ${xpath_select_button_immediate_shutdown_no}
@@ -222,7 +222,7 @@
     [Documentation]  Selecting of OpenBMC "Server Power Operations" Submenu.
 
     Click Button  ${xpath_select_server_control}
-    Click Button  ${xpath_select_server_power_operations}
+    Click Element  ${xpath_select_server_power_operations}
 
 Verify Presence of Power Button And Text Info
     [Documentation]  Verify the presens fo power button and text message info.
@@ -241,5 +241,5 @@
     # xpath_no_button      Xpath of "No" button.
 
     Click No Button  ${xpath_no_button}
-    ${obmc_current_state}=  Get Text  ${xpath_display_server_power_status}
+    ${obmc_current_state}=  Get Text  ${xpath_power_indicator}
     Should Contain  ${obmc_current_state}  ${obmc_running_state}