Automation fix for SNMP tescases

Changes :
    - Modified SNMP Testcase
    - Modified "Reboot Via GUI" keyword

Tested:
    - Ran successfully gui_test/settings_menu/test_snmp_alerts_sub_menu.robot
    - Ran successfully lib/gui_resource.robot

Change-Id: I7b5e3bd18eb56d1b6ef85d45db519b7e27cdeffe
Signed-off-by: Megha G N <Megha.G.N@ibm.com>
diff --git a/gui/gui_test/settings_menu/test_snmp_alerts_sub_menu.robot b/gui/gui_test/settings_menu/test_snmp_alerts_sub_menu.robot
index 52ba780..59376db 100644
--- a/gui/gui_test/settings_menu/test_snmp_alerts_sub_menu.robot
+++ b/gui/gui_test/settings_menu/test_snmp_alerts_sub_menu.robot
@@ -2,9 +2,9 @@
 
 Documentation   Test OpenBMC GUI "SNMP Alerts" sub-menu of "Settings".
 
-Resource        ../../lib/gui_resource.robot
-Resource        ../../../lib/snmp/resource.robot
 Resource        ../../../lib/snmp/redfish_snmp_utils.robot
+Resource        ../../../lib/snmp/resource.robot
+Resource        ../../lib/gui_resource.robot
 
 Suite Setup     Suite Setup Execution
 Suite Teardown  Close Browser
@@ -27,6 +27,7 @@
 ${snmp_page_heading}                              SNMP alerts
 ${invalid_port_error}                             Value must be between 0 – 65535
 ${invalid_destination_error}                      Error in adding SNMP alert destination
+${invalid_ip_error}                               Field required
 
 
 *** Test Cases ***
@@ -115,10 +116,10 @@
     ${SNMP_MGR1_IP}     ${alpha_port}            ${invalid_port_error}
     ${SNMP_MGR1_IP}     ${negative_port}         ${invalid_port_error}
     ${SNMP_MGR1_IP}     ${alphanumeric_port}     ${invalid_port_error}
+    ${empty_ip}         ${NON_DEFAULT_PORT1}     ${invalid_ip_error}
     ${out_of_range_ip}  ${NON_DEFAULT_PORT1}     ${invalid_destination_error}
     ${alpha_ip}         ${NON_DEFAULT_PORT1}     ${invalid_destination_error}
     ${negative_ip}      ${NON_DEFAULT_PORT1}     ${invalid_destination_error}
-    ${empty_ip}         ${NON_DEFAULT_PORT1}     ${invalid_destination_error}
     ${less_octet_ip}    ${NON_DEFAULT_PORT1}     ${invalid_destination_error}
 
 
@@ -245,8 +246,7 @@
 
     [Documentation]  Configure SNMP manager on BMC with invalid setting via GUI and verify.
     [Arguments]  ${snmp_manager_ip}  ${snmp_manager_port}  ${expected_error}
-    [Teardown]  Run Keyword If  '${expected_error}' == '${invalid_port_error}'
-    ...  Click Element  ${xpath_cancel_button}
+    [Teardown]  Close Add SNMP Alerts Destination Window  ${expected_error}
 
     # Description of argument(s):
     # snmp_manager_ip     SNMP manager IP address.
@@ -309,3 +309,16 @@
     ${snmp_trap}=  Split String  ${trap_info}  \t
 
     Verify SNMP Trap  ${snmp_trap}  ${expected_error}
+
+
+Close Add SNMP Alerts Destination Window
+    [Documentation]  Close Add SNMP Alerts Destination window.
+    [Arguments]  ${expected_error}=${invalid_port_error}
+
+    # Description of argument(s):
+    # expected_error  Expected error on SNMP alerts page.
+
+    Run Keyword If  '${expected_error}' == '${invalid_port_error}'
+    ...  Click Element  ${xpath_cancel_button}
+    ...  ELSE IF  '${expected_error}' == '${invalid_ip_error}'
+    ...  Click Element  ${xpath_cancel_button}
diff --git a/gui/lib/gui_resource.robot b/gui/lib/gui_resource.robot
index 308762a..08ac09e 100644
--- a/gui/lib/gui_resource.robot
+++ b/gui/lib/gui_resource.robot
@@ -150,6 +150,6 @@
     Click Element  ${xpath_operations_menu}
     Click Element  ${xpath_reboot_bmc_sub_menu}
     Click Button  ${xpath_reboot_bmc_button}
-    Click Button  ${xpath_confirm_bmc_reboot}
+    Wait Until Keyword Succeeds  30 sec  10 sec  Click Button  ${xpath_confirm_bmc_reboot}
     Wait Until Keyword Succeeds  2 min  10 sec  Is BMC Unpingable
     Wait For Host To Ping  ${OPENBMC_HOST}  1 min