GUI: TFTP Code update: Phase -1

Contains following test cases:
 - Verify Scroll Down Link
 - Verify BMC Firmware Download
 - Verify PNOR Firmware Download

Resolves openbmc/openbmc-test-automation#1399

Change-Id: I9cc33db5e8639ced711b2d2125ee33c3debf976e
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/gui/obmc_gui/test/server_config/test_obmc_gui_firmware_update.robot b/gui/obmc_gui/test/server_config/test_obmc_gui_firmware_update.robot
index 79d6192..431de5e 100644
--- a/gui/obmc_gui/test/server_config/test_obmc_gui_firmware_update.robot
+++ b/gui/obmc_gui/test/server_config/test_obmc_gui_firmware_update.robot
@@ -3,15 +3,22 @@
 Documentation  Test Open BMC GUI server configuration firmware update.
 
 Resource        ../../lib/resource.robot
+Resource        ../../../../lib/logging_utils.robot
 
 Suite Setup     Launch Browser And Login OpenBMC GUI
 Suite Teardown  Logout And Close Browser
 Test Setup      Test Setup Execution
+Test Teardown   Run Keyword If Test Failed  Re-Launch GUI on Failure
 
 *** Variables ***
 ${xpath_select_server_config}   //*[@id="nav__top-level"]/li[4]/button
 ${xpath_select_firmware}        //a[@href='#/configuration/firmware']
 ${xpath_choose_file_button}     //*[@id="firmware__upload-form"]/div[1]/label/span[1]
+${xpath_scroll_down}            //a[@href='/html/body/main/div[2]/p[2]/a']
+${xpath_tftp_server_ip}         //*[@id="tftp-ip"]
+${xpath_tftp_filename}          //*[@id="tftp-file-name"]
+${xpath_download_firmware}      //*[@id="firmware__upload-form"]/div[2]/fieldset/div[1]/div[3]/input
+${xpath_download_progress}      //*[@id="firmware__upload-form"]/div[2]/fieldset/div[2]
 
 *** Test Cases ***
 
@@ -23,6 +30,16 @@
     Wait Until Page Contains  Firmware
     Page Should contain  Manage BMC and server firmware
 
+
+Verify Scroll Down Link
+    [Documentation]  Verify scroll down link works.
+    [Tags]  Verify_Scroll_Down_Link
+
+    Page Should Contain Element  ${xpath_scroll_down}
+    Click Element  ${xpath_scroll_down}
+    Page Should Contain Element  ${xpath_choose_file_button}
+
+
 Verify Choose File Button Click
     [Documentation]  Verify choose file button is clickable.
     [Tags]  Verify_Choose_File_Button_Click
@@ -31,11 +48,62 @@
     Page Should Contain Element  ${xpath_choose_file_button}
     Click Element  ${xpath_choose_file_button}
 
+Verify BMC Firmware Download
+    # BMC Firmware File Path located at TFTP server.
+    ${BMC_IMAGE_FILE_PATH}
+    [Template]  Upload Firmware using TFTP Server
+    [Documentation]  Verify BMC image is download from TFTP server.
+    [Tags]  Verify_BMC_Firmware_Download
+
+
+Verify Host Firmware Download
+    # Host Firmware File Path located at TFTP server.
+    ${PNOR_IMAGE_FILE_PATH}
+    [Template]  Upload Firmware using TFTP Server
+    [Documentation]  Verify Host image is download from TFTP server.
+    [Tags]  Verify_HOST_Firmware_Download
+
+
 *** Keywords ***
 
 Test Setup Execution
    [Documentation]  Do test case setup tasks.
 
+    Delete All Error Logs
     Click Element  ${xpath_select_server_config}
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
     Click Element  ${xpath_select_firmware}
+
+Upload Firmware using TFTP Server
+    [Documentation]  Upload firmware using TFTP server.
+    [Arguments]  ${firmware_file_name}
+
+    Page Should Contain Button  ${xpath_download_firmware}
+    Page Should Contain Element  ${xpath_tftp_server_ip}
+    Page Should Contain Element  ${xpath_tftp_filename}
+
+    Input Text  ${xpath_tftp_server_ip}  ${TFTP_SERVER}
+    Input Text  ${xpath_tftp_filename}  ${firmware_file_name}
+    Click Button  ${xpath_download_firmware}
+    Sleep  180s
+    Wait Until Page Does Not Contain Element  ${xpath_download_progress}
+
+    # ${message}=  Handle Alert  timeout=300s
+    # Didn't work so commenting out currently.
+    # Alert not getting captured.
+    # TODO: Issue https://github.com/openbmc/openbmc-test-automation/issues/1412
+
+    Check No Error Log Exist
+
+Check No Error Log Exist
+    [Documentation]  No error log should be logged.
+
+    ${resp}=  OpenBMC Get Request  ${BMC_LOGGING_ENTRY}/list  quiet=${1}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
+    ...  msg=Codeupdate Failed with error.
+
+Re-Launch GUI on Failure
+    [Documentation]  On failure of test case, close and re-launch GUI.
+
+    Logout And Close Browser
+    Launch Browser And Login OpenBMC GUI