GUI:Test case to move from manual to ntp-2 loops

Changes:
  - Added test case "Verify Moving From Manual To NTP"
Tested:
  - Ran the test case from sandbox successfully

Change-Id: If08ec476e9842c96c47dcfc6a8f2af106712877b
Signed-off-by: sarandev3 <saranyad@in.ibm.com>
diff --git a/gui/gui_test/settings_menu/test_date_and_time_sub_menu.robot b/gui/gui_test/settings_menu/test_date_and_time_sub_menu.robot
index 6de04e9..1b5ccd9 100644
--- a/gui/gui_test/settings_menu/test_date_and_time_sub_menu.robot
+++ b/gui/gui_test/settings_menu/test_date_and_time_sub_menu.robot
@@ -20,6 +20,7 @@
 ${xpath_ntp_server3}             //input[@data-test-id="dateTime-input-ntpServer3"]
 ${xpath_select_save_settings}    //button[@data-test-id="dateTime-button-saveSettings"]
 ${xpath_invalid_format_message}  //*[contains(text(), "Invalid format")]
+${LOOP_COUNT}                    2
 
 *** Test Cases ***
 
@@ -186,7 +187,7 @@
 
 
 Verify Changing BMC Time From NTP To Manual
-    [Documentation]  Verify that BMC time can be changed from NPT to
+    [Documentation]  Verify that BMC time can be changed from NTP to
     ...  manual time via GUI.
     [Tags]  Verify_Changing_BMC_Time_From_NTP_To_Manual
     [Setup]  Setup To Power Off And Navigate
@@ -220,28 +221,14 @@
     Sleep  15
 
 
-Verify Changing BMC Time From Manual To NTP
-    [Documentation]  Verify BMC time syncing with NTP server time
-    ...  from manual time.
-    [Tags]  Verify_Changing_BMC_Time_From_Manual_To_NTP
+Verify Moving From Manual To NTP
+    [Documentation]  Verify switching between manual mode and NTP mode.
+    [Tags]  Verify_Moving_From_Manual_To_NTP
     [Setup]  Setup To Power Off And Navigate
+    [Template]  Switch From Manual To NTP
 
-    # Add Manual date and time for BMC to sync.
-    Set Manual Date and Time Via GUI
-
-    # Set BMC date time to sync with NTP server.
-    Click Element At Coordinates  ${xpath_select_ntp}  0  0
-    Input Text  ${xpath_ntp_server1}  216.239.35.0
-    Click Element  ${xpath_select_save_settings}
-
-    Wait Until Element Is Visible   ${xpath_success_message}  timeout=60
-    ${cli_date_time}=  CLI Get BMC DateTime
-    ${ntp_date}=  Convert Date  ${cli_date_time}  result_format=%Y-%m-%d
-    ${ntp_time}=  Convert Date  ${cli_date_time}  result_format=%H:%M
-    Wait Until Page Contains  ${ntp_date}   timeout=60s
-    Page Should Contain   ${ntp_time}
-
-    Wait Until Element Is Not Visible   ${xpath_success_message}  timeout=60
+    # loop_count
+    ${LOOP_COUNT}
 
 
 *** Keywords ***
@@ -290,3 +277,31 @@
     # Wait for changes to take effect.
     Wait Until Element Is Enabled  ${xpath_select_ntp}  timeout=30s
 
+Switch From Manual To NTP
+    [Documentation]  Verify switching from manual mode to NTP mode.
+    [Arguments]  ${loop_count}=${LOOP_COUNT}
+
+    # Description of argument(s):
+    # loop_count        Number of loops to move from manual to NTP.
+
+    FOR  ${x}  IN RANGE  ${loop_count}
+       Set Manual Date and Time Via GUI
+       # Set BMC date time to sync with NTP server.
+       Click Element At Coordinates  ${xpath_select_ntp}  0  0
+       Input Text  ${xpath_ntp_server1}  216.239.35.0
+       Click Element  ${xpath_select_save_settings}
+
+       # Wait until saved successfully message is visible.
+       Wait Until Element Is Visible  ${xpath_success_message}  timeout=60
+
+       ${cli_date_time}=  CLI Get BMC DateTime
+       ${ntp_date}=  Convert Date  ${cli_date_time}  result_format=%Y-%m-%d
+       ${ntp_time}=  Convert Date  ${cli_date_time}  result_format=%H:%M
+       Wait Until Page Contains  ${ntp_date}   timeout=60s
+       Page Should Contain  ${ntp_time}
+
+       Wait Until Element Is Not Visible   ${xpath_success_message}  timeout=60
+       Log  "Completed Loop for ${x} time"
+    END
+
+