Added new SNMP testcase

Changes :
    - Configure SNMP Manager With Hostname Via GUI AND Verify
    - Removed "Add DNS Servers And Verify" keyword from test_network_sub_menu.robot
      and added in lib file gui_resource.robot

Tested:
    - Ran successfully test_snmp_alerts_sub_menu.robot

Change-Id: Ib6e90c8ae45d1185631416e83144d739f0d8c38a
Signed-off-by: Megha G N <Megha.G.N@ibm.com>
diff --git a/gui/data/gui_variables.py b/gui/data/gui_variables.py
index 107885e..8d15e39 100644
--- a/gui/data/gui_variables.py
+++ b/gui/data/gui_variables.py
@@ -71,6 +71,14 @@
     xpath_power_restore_policy_sub_menu = (
         "//*[@data-test-id='nav-item-power-restore-policy']"
     )
+    xpath_static_dns = "//h2[text()='Static DNS']"
+    xpath_dns_servers_toggle = (
+        "//*[@data-test-id='networkSettings-switch-useDns']"
+    )
+    xpath_add_dns_ip_address_button = (
+        "//button[contains(text(),'Add IP address')]"
+    )
+    xpath_input_static_dns = "//*[@id='staticDns']"
 
     # Security and access menu
     xpath_secuity_and_accesss_menu = (
diff --git a/gui/gui_test/settings_menu/test_network_sub_menu.robot b/gui/gui_test/settings_menu/test_network_sub_menu.robot
index 87a865b..8cc9905 100644
--- a/gui/gui_test/settings_menu/test_network_sub_menu.robot
+++ b/gui/gui_test/settings_menu/test_network_sub_menu.robot
@@ -15,18 +15,14 @@
 ${xpath_interface_settings}              //h2[text()="Interface settings"]
 ${xpath_network_settings}                //h2[text()="Network settings"]
 ${xpath_static_ipv4}                     //h2[text()="IPv4"]
-${xpath_static_dns}                      //h2[text()="Static DNS"]
 ${xpath_domain_name_toggle}              //*[@data-test-id="networkSettings-switch-useDomainName"]
-${xpath_dns_servers_toggle}              //*[@data-test-id="networkSettings-switch-useDns"]
 ${xpath_ntp_servers_toggle}              //*[@data-test-id="networkSettings-switch-useNtp"]
 ${xpath_add_static_ipv4_address_button}  //button[contains(text(),"Add static IPv4 address")]
-${xpath_add_dns_ip_address_button}       //button[contains(text(),"Add IP address")]
 ${xpath_hostname}                        //*[@title="Edit hostname"]
 ${xpath_hostname_input}                  //*[@id="hostname"]
 ${xpath_input_ip_address}                //*[@id="ipAddress"]
 ${xpath_input_gateway}                   //*[@id="gateway"]
 ${xpath_input_subnetmask}                //*[@id="subnetMask"]
-${xpath_input_static_dns}                //*[@id="staticDns"]
 ${xpath_cancel_button}                   //button[contains(text(),'Cancel')]
 ${xpath_delete_dns_server}               //*[@title="Delete DNS address"]
 ${xpath_save_button}                     //button[contains(text(),'Save')]
@@ -205,34 +201,6 @@
     Set Suite Variable  ${default_gateway}
 
 
-Add DNS Servers And Verify
-    [Documentation]  Login to GUI Network page,add DNS server on BMC
-    ...  and verify it via BMC CLI.
-    [Arguments]  ${dns_server}   ${expected_status}=Valid format
-
-    # Description of the argument(s):
-    # dns_server           A list of static name server IPs to be
-    #                      configured on the BMC.
-    # expected_status      Expected status while adding DNS server address
-    # ...                  (e.g. Invalid format / Field required).
-
-    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=15sec
-
-    Click Button  ${xpath_add_dns_ip_address_button}
-    Input Text  ${xpath_input_static_dns}  ${dns_server}
-    Click Button  ${xpath_add_button}
-    Run keyword if  '${expected_status}' != 'Valid format'
-    ...  Run keywords  Page Should Contain  ${expected_status}  AND  Return From Keyword
-
-    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=10sec
-    Wait Until Page Contains  ${dns_server}  timeout=40sec
-
-    # Check if newly added DNS server is configured on BMC.
-    ${cli_name_servers}=  CLI Get Nameservers
-    ${cmd_status}=  Run Keyword And Return Status
-    ...  List Should Contain Sub List  ${cli_name_servers}  ${dns_server}
-
-
 Delete DNS Servers And Verify
     [Documentation]  Login to GUI Network page,delete static name servers
     ...  and verify that page does not reflect static name servers.
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 59376db..5276700 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
@@ -5,6 +5,7 @@
 Resource        ../../../lib/snmp/redfish_snmp_utils.robot
 Resource        ../../../lib/snmp/resource.robot
 Resource        ../../lib/gui_resource.robot
+Resource        ../../lib/bmc_network_utils.robot
 
 Suite Setup     Suite Setup Execution
 Suite Teardown  Close Browser
@@ -28,6 +29,7 @@
 ${invalid_port_error}                             Value must be between 0 – 65535
 ${invalid_destination_error}                      Error in adding SNMP alert destination
 ${invalid_ip_error}                               Field required
+${dns_server}                                     10.10.10.10
 
 
 *** Test Cases ***
@@ -196,6 +198,21 @@
     ${CMD_INFORMATIONAL_ERROR}  ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}
 
 
+Configure SNMP Manager By Its Hostname Via GUI AND Verify
+    [Documentation]  Login GUI SNMP alerts page and add SNMP manager with its hostname
+    ...  via GUI and verify.
+    [Tags]  Configure_SNMP_Manager_By_Its_Hostname_Via_GUI_And_Verify
+
+    Set DNS Server IP
+
+    # Navigate to SNMP page and configure SNMP manager.
+    Click Element  ${xpath_snmp_alerts_sub_menu}
+    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  snmp-alerts
+
+    Configure SNMP Manager Via GUI  ${SNMP_HOSTNAME}  ${SNMP_DEFAULT_PORT}
+    Wait Until Page Contains  ${HOSTNAME}  timeout=15s
+
+
 *** Keywords ***
 
 Suite Setup Execution
@@ -322,3 +339,12 @@
     ...  Click Element  ${xpath_cancel_button}
     ...  ELSE IF  '${expected_error}' == '${invalid_ip_error}'
     ...  Click Element  ${xpath_cancel_button}
+
+
+Set DNS Server IP
+    [Documentation]  Add static DNS IP.
+    
+    Click Element  ${xpath_network_sub_menu}
+    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  network
+
+    Add DNS Servers And Verify  ${dns_server}
diff --git a/gui/lib/gui_resource.robot b/gui/lib/gui_resource.robot
index 08ac09e..bf08b7e 100644
--- a/gui/lib/gui_resource.robot
+++ b/gui/lib/gui_resource.robot
@@ -153,3 +153,31 @@
     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
+
+
+Add DNS Servers And Verify
+    [Documentation]  Login to GUI Network page,add DNS server on BMC
+    ...  and verify it via BMC CLI.
+    [Arguments]  ${dns_server}   ${expected_status}=Valid format
+
+    # Description of the argument(s):
+    # dns_server           A list of static name server IPs to be
+    #                      configured on the BMC.
+    # expected_status      Expected status while adding DNS server address
+    #                      (e.g. Invalid format / Field required).
+
+    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=15sec
+
+    Click Button  ${xpath_add_dns_ip_address_button}
+    Input Text  ${xpath_input_static_dns}  ${dns_server}
+    Click Button  ${xpath_add_button}
+    Run keyword if  '${expected_status}' != 'Valid format'
+    ...  Run keywords  Page Should Contain  ${expected_status}  AND  Return From Keyword
+
+    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=10sec
+    Wait Until Page Contains  ${dns_server}  timeout=40sec
+
+    # Check if newly added DNS server is configured on BMC.
+    ${cli_name_servers}=  CLI Get Nameservers
+    ${cmd_status}=  Run Keyword And Return Status
+    ...  List Should Contain Sub List  ${cli_name_servers}  ${dns_server}