GUI: Fix for powercap test

Changes: -
    - Updated Verify_Server_Power_Cap_Setting_Is_Off

Tested: -
Successfully ran this from /gui/gui_test/resource_management_menu/test_power_sub_menu.robot

Change-Id: I9f6427c0b366aa3344550c028ad459929c628090
Signed-off-by: rramyasr-in <rramyasr@in.ibm.com>
diff --git a/gui/gui_test/resource_management_menu/test_power_sub_menu.robot b/gui/gui_test/resource_management_menu/test_power_sub_menu.robot
index e21fedd..1e6c382 100644
--- a/gui/gui_test/resource_management_menu/test_power_sub_menu.robot
+++ b/gui/gui_test/resource_management_menu/test_power_sub_menu.robot
@@ -76,28 +76,29 @@
     Wait Until Keyword Succeeds  1 min  15 sec  Is Power Cap Value Set  ${power_cap_value}
 
 
-Verify Server Power Cap Setting Is Off
-    [Documentation]   Verify power cap cannot be set or modified when power cap check box is off.
+Verify Server Power Cap Setting With Power Cap Disabled
+    [Documentation]  Verify that valid server power cap value can be set
+    ...  in GUI with power cap is in disabled state.
     [Tags]  Verify_Server_Power_Cap_Setting_Is_Off
+    [Setup]  Save Initial Power Cap State
+    [Teardown]  Restore Initial Power Cap State
 
-    Page Should Contain Element  ${xpath_power_ops_checkbox}
+    Run Keyword If  '${checkbox_initial_state}' == 'True'
+    ...  Click Element At Coordinates  ${xpath_power_ops_checkbox}  0  0
 
-    # Set a value in check box.
-    ${checkbox_Selected}=  Run Keyword And Return Status
-    ...  Checkbox Should Be Selected  ${xpath_power_ops_checkbox}
-    Run Keyword If  False == ${checkbox_Selected}  Click Element  ${xpath_power_ops_checkbox}
+    # Now input a cap value and submit.
     Wait Until Element Is Enabled  ${xpath_cap_input_button}  timeout=10
-    Input Text  ${xpath_cap_input_button}  ${499}
 
-    # Now disable input box by deselecting the check box
-    Click Element  ${xpath_power_ops_checkbox}
-    Checkbox Should Not Be Selected  ${xpath_power_ops_checkbox}
-    Element Should Be Disabled  ${xpath_cap_input_button}
+    # Get maximum and minimum values of power cap.
+    ${resp}=  Redfish.Get Properties  /redfish/v1/Chassis/${CHASSIS_ID}/EnvironmentMetrics
 
-    # Click submit.
+    ${power_cap_value}=  Evaluate
+    ...  random.randint(${resp['PowerLimitWatts']['AllowableMin']},${resp['PowerLimitWatts']['AllowableMax']})
+    ...  modules=random
+
+    Input Text  ${xpath_cap_input_button}  ${power_cap_value}
     Click Element  ${xpath_submit_button}
-    ${power_cap}=  Get Power Cap Value
-    Should Not Be True  ${power_cap} == 499
+    Wait Until Keyword Succeeds  1 min  15 sec  Is Power Cap Value Set  ${power_cap_value}
 
 
 *** Keywords ***