Remove code for backuprestore
[integration/test.git] / csit / libraries / GUIKeywords.robot
index 8b36382113cf64ea86068f2a599e0052fd558004..f15933d36088115251235d1620d6ed2e60c59f32 100644 (file)
@@ -1,57 +1,60 @@
 *** Settings ***
-Documentation     A resource file containing all global
-...               elements (Variables, keywords) to help
-...               DLUX csit testing.
-Library           OperatingSystem
-Library           Process
-Library           Selenium2Library    timeout=30    implicit_wait=30    run_on_failure=Selenium2Library.Log Source
-Resource          ../variables/Variables.robot
-Resource          Utils.robot
+Documentation       A resource file containing all global
+...                 elements (Variables, keywords) to help
+...                 DLUX csit testing.
+
+Library             OperatingSystem
+Library             Process
+Library             Selenium2Library    timeout=30    implicit_wait=30    run_on_failure=Selenium2Library.Log Source
+Resource            ../variables/Variables.robot
+Resource            Utils.robot
+
 
 *** Variables ***
-${BROWSER}        phantomjs
-${BASE_URL}       http://${ODL_SYSTEM_IP}:${RESTCONFPORT}/index.html
-${LOGIN_URL}      ${BASE_URL}#/login
-${XVFB_PORT}      99
-${LOGGED_URL}     ${BASE_URL}#/topology
-${LOGIN_USERNAME}    admin
-${LOGIN_PASSWORD}    admin
-${INVALID_USER}    invaliduser
-${INVALID_PWD}    invalidpwd
+${BROWSER}                          phantomjs
+${BASE_URL}                         http://${ODL_SYSTEM_IP}:${RESTCONFPORT}/index.html
+${LOGIN_URL}                        ${BASE_URL}#/login
+${XVFB_PORT}                        99
+${LOGGED_URL}                       ${BASE_URL}#/topology
+${LOGIN_USERNAME}                   admin
+${LOGIN_PASSWORD}                   admin
+${INVALID_USER}                     invaliduser
+${INVALID_PWD}                      invalidpwd
 # Login page
-${OPENDAYLIGHT_IMAGE}    //img[@alt='OpenDayLight']
-${LOGIN_USERNAME_INPUT_FIELD}    //form/fieldset/div/input[@name='username']
-${LOGIN_PASSWORD_INPUT_FIELD}    //form/fieldset/div[2]/input[@name='password']
-${REMEMBER_ME_CHECKBOX}    //div[@class="checkbox"]
-${LOGIN_BUTTON}    //fieldset/button
-${PLEASE_SIGN_IN_PANEL}    //div/h3[contains(text(),"${PLEASE_SIGN_IN_MSG}")]
-${PLEASE_SIGN_IN_MSG}    Please Sign In
-${LOGIN_ERROR_MSG}    Unable to login
+${OPENDAYLIGHT_IMAGE}               //img[@alt='OpenDayLight']
+${LOGIN_USERNAME_INPUT_FIELD}       //form/fieldset/div/input[@name='username']
+${LOGIN_PASSWORD_INPUT_FIELD}       //form/fieldset/div[2]/input[@name='password']
+${REMEMBER_ME_CHECKBOX}             //div[@class="checkbox"]
+${LOGIN_BUTTON}                     //fieldset/button
+${PLEASE_SIGN_IN_PANEL}             //div/h3[contains(text(),"${PLEASE_SIGN_IN_MSG}")]
+${PLEASE_SIGN_IN_MSG}               Please Sign In
+${LOGIN_ERROR_MSG}                  Unable to login
 # DLUX Home page
-${TOPOLOGY_SUBMENU}    //a[@href='#/topology']
-${NODES_SUBMENU}    //a[@href='#/node/index')]
-${YANG_UI_SUBMENU}    //a[@href='#/yangui/index']
-${YANG_VISUALIZER_SUBMENU}    //a[@href='#/yangvisualizer/index']
-${YANGMAN_SUBMENU}    //a[@href='#/yangman/index']
+${TOPOLOGY_SUBMENU}                 //a[@href='#/topology']
+${NODES_SUBMENU}                    //a[@href='#/node/index')]
+${YANG_UI_SUBMENU}                  //a[@href='#/yangui/index']
+${YANG_VISUALIZER_SUBMENU}          //a[@href='#/yangvisualizer/index']
+${YANGMAN_SUBMENU}                  //a[@href='#/yangman/index']
 # Topology Submenu
-${TOPOLOGY_SUBMENU_URL}    ${BASE_URL}#/topology
-${RELOAD_BUTTON}    //button[@ng-click='createTopology()']
-${CONTROLS_TEXT}    //div[@class="col-md-2"]/h3
+${TOPOLOGY_SUBMENU_URL}             ${BASE_URL}#/topology
+${RELOAD_BUTTON}                    //button[@ng-click='createTopology()']
+${CONTROLS_TEXT}                    //div[@class="col-md-2"]/h3
 # Nodes Submenu
-${NODES_SUBMENU_URL}    ${BASE_URL}#/node/index
+${NODES_SUBMENU_URL}                ${BASE_URL}#/node/index
 # Yang UI Submenu
-${YANG_UI_SUBMENU_URL}    ${BASE_URL}#/yangui/index
+${YANG_UI_SUBMENU_URL}              ${BASE_URL}#/yangui/index
 # Yang Visualizer Submenu
-${YANG_VISUALIZER_SUBMENU_URL}    ${BASE_URL}#/yangvisualizer/index
+${YANG_VISUALIZER_SUBMENU_URL}      ${BASE_URL}#/yangvisualizer/index
 # Yangman Submenu
-${YANGMAN_SUBMENU_URL}    ${BASE_URL}#/yangman/index
+${YANGMAN_SUBMENU_URL}              ${BASE_URL}#/yangman/index
 # Failback variables
-${USE_XVFB}       True
-${BROWSER_NAME}    phantomjs-1.9.8-linux-x86_64
-${BROWSER_EXT}    tar.bz2
-${BROWSER_FILE_NAME}    ${BROWSER_NAME}.${BROWSER_EXT}
-${BROWSER_URL}    https://bitbucket.org/ariya/phantomjs/downloads/${BROWSER_FILE_NAME}
-${BROWSER_PATH_EXECUTABLE}    ${BROWSER_NAME}/bin/phantomjs
+${USE_XVFB}                         True
+${BROWSER_NAME}                     phantomjs-1.9.8-linux-x86_64
+${BROWSER_EXT}                      tar.bz2
+${BROWSER_FILE_NAME}                ${BROWSER_NAME}.${BROWSER_EXT}
+${BROWSER_URL}                      https://bitbucket.org/ariya/phantomjs/downloads/${BROWSER_FILE_NAME}
+${BROWSER_PATH_EXECUTABLE}          ${BROWSER_NAME}/bin/phantomjs
+
 
 *** Keywords ***
 Check If Phantom Is Downloaded
@@ -60,7 +63,7 @@ Check If Phantom Is Downloaded
     ...    verification if there is one containing the word 'phantomjs'. Result is that the PhantomJS
     ...    compressed file is downloaded and uncompressed locally related to the path of the running script.
     ${installed}=    OperatingSystem.Run    ls -d */ | grep -m 1 phantomjs
-    [Return]    ${installed}
+    RETURN    ${installed}
 
 Download PhantomJS
     [Documentation]    Downloads and uncompress the headless browser PhantomJS.
@@ -70,13 +73,13 @@ Download PhantomJS
 Get Headless Browser Path
     [Documentation]    Returns the path of the executable headless browser.
     ${is_downloaded}=    Check If Phantom Is Downloaded
-    BuiltIn.Run Keyword If    "${is_downloaded}"=="${EMPTY}"    Download PhantomJS
+    IF    "${is_downloaded}"=="${EMPTY}"    Download PhantomJS
     ${path}=    BuiltIn.Set Variable    ${EXECDIR}/${BROWSER_PATH_EXECUTABLE}
-    [Return]    ${path}
+    RETURN    ${path}
 
 Open Headless Browser
-    [Arguments]    ${url}
     [Documentation]    Failback browser, download and use the WebKit headless browser PhantomJS.
+    [Arguments]    ${url}
     BuiltIn.Log    \n Using failback browser    console=yes
     BuiltIn.Set Global Variable    ${USE_XVFB}    False
     ${executable_path}=    Get Headless Browser Path
@@ -84,8 +87,8 @@ Open Headless Browser
     Selenium2Library.Go To    ${url}
 
 Set Display Port
-    [Arguments]    ${port}=${XVFB_PORT}
     [Documentation]    Sets the environment variable used by xvfb and the browser.
+    [Arguments]    ${port}=${XVFB_PORT}
     OperatingSystem.Set Environment Variable    DISPLAY    :${port}
 
 Open Virtual Display
@@ -93,12 +96,12 @@ Open Virtual Display
     Process.Start Process    Xvfb    :${XVFB_PORT}    -ac    -screen    0    1280x1024x16
     ...    alias=xvfb
     ${display}=    OperatingSystem.Get Environment Variable    DISPLAY    ${EMPTY}
-    BuiltIn.Run Keyword Unless    "${display}"==":${XVFB_PORT}"    Set Display Port
+    IF    "${display}"!=":${XVFB_PORT}"    Set Display Port
 
 Close DLUX And Terminate XVFB Process If Running
     [Documentation]    Closes all browser instances and terminates Xvfb if the process is running.
     Selenium2Library.Close All Browsers
-    BuiltIn.Run Keyword If    ${USE_XVFB}    Terminate Process    xvfb
+    IF    ${USE_XVFB}    Terminate Process    xvfb
 
 Launch DLUX
     [Documentation]    Launches with a delay to let the page load. If it cannot run the default browser, it will download
@@ -110,12 +113,12 @@ Launch DLUX
     ...    3. Go to DLUX login URL and wait until the HTML page contains a specific element.
     ${status}=    BuiltIn.Run Keyword And Return Status    Run Keywords    Open Virtual Display
     ...    AND    Selenium2Library.Open Browser    ${LOGIN_URL}    ${BROWSER}
-    BuiltIn.Run Keyword Unless    ${status}    Open Headless Browser    ${LOGIN_URL}
+    IF    not ${status}    Open Headless Browser    ${LOGIN_URL}
     Selenium2Library.Wait Until Page Contains Element    css=div.container
 
 Open DLUX Login Page
-    [Arguments]    ${LOGIN URL}
     [Documentation]    Loads DLUX login page.
+    [Arguments]    ${LOGIN URL}
     Selenium2Library.Open Browser    ${LOGIN_URL}    ${BROWSER}
     Selenium2Library.Maximize Browser Window
     Selenium2Library.Wait Until Page Contains Element    ${PLEASE_SIGN_IN_PANEL}
@@ -129,8 +132,8 @@ Verify Elements Of DLUX Login Page
     Selenium2Library.Page Should Contain Element    ${LOGIN_BUTTON}
 
 Log In To DLUX
-    [Arguments]    ${username}    ${password}
     [Documentation]    Inserts username and password and logs in DLUX.
+    [Arguments]    ${username}    ${password}
     Selenium2Library.Focus    ${LOGIN_USERNAME_INPUT_FIELD}
     Selenium2Library.Input Text    ${LOGIN_USERNAME_INPUT_FIELD}    ${username}
     Selenium2Library.Focus    ${LOGIN_PASSWORD_INPUT_FIELD}
@@ -138,8 +141,8 @@ Log In To DLUX
     Focus And Click Element    ${LOGIN_BUTTON}
 
 Log In To DLUX With Invalid Credentials
-    [Arguments]    ${username}    ${password}
     [Documentation]    Tries to log in to DLUX with invalid credentials and verifies occurence of the error message.
+    [Arguments]    ${username}    ${password}
     Selenium2Library.Focus    ${LOGIN_USERNAME_INPUT_FIELD}
     Selenium2Library.Input Text    ${LOGIN_USERNAME_INPUT_FIELD}    ${username}
     Selenium2Library.Focus    ${LOGIN_PASSWORD_INPUT_FIELD}
@@ -151,7 +154,7 @@ Log In To DLUX With Invalid Credentials
 Open Or Launch DLUX
     [Documentation]    Tries to open Dlux login page. If it fails, then launches Dlux using xvfb or headless browser.
     ${status}=    BuiltIn.Run Keyword And Return Status    Open DLUX Login Page    ${LOGIN_URL}
-    BuiltIn.Run Keyword If    "${status}"=="False"    Launch DLUX
+    IF    "${status}"=="False"    Launch DLUX
     Verify Elements Of DLUX Login Page
 
 Open Or Launch DLUX Page And Log In To DLUX
@@ -160,22 +163,22 @@ Open Or Launch DLUX Page And Log In To DLUX
     Log In To DLUX    ${LOGIN_USERNAME}    ${LOGIN_PASSWORD}
 
 Navigate To URL
-    [Arguments]    ${url}
     [Documentation]    Goes to the defined URL provided in an argument.
+    [Arguments]    ${url}
     ${status}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Location Should Be    ${url}
-    BuiltIn.Run Keyword Unless    ${status}    Selenium2Library.Go To    ${url}
+    IF    not ${status}    Selenium2Library.Go To    ${url}
 
 Focus And Click Element
-    [Arguments]    ${element}
     [Documentation]    Clicks the element with previous element visibility check and element focus.
+    [Arguments]    ${element}
     Selenium2Library.Wait Until Element Is Visible    ${element}
     Selenium2Library.Focus    ${element}
     Selenium2Library.Mouse Over    ${element}
     Selenium2Library.Click Element    ${element}
 
 Mouse Down And Mouse Up Click Element
-    [Arguments]    ${element}
     [Documentation]    Clicks the element by imitating mouse left button click down and click up.
+    [Arguments]    ${element}
     Selenium2Library.Wait Until Page Contains Element    ${element}
     Selenium2Library.Focus    ${element}
     Selenium2Library.Mouse Over    ${element}
@@ -183,20 +186,25 @@ Mouse Down And Mouse Up Click Element
     Selenium2Library.Mouse Up    ${element}
 
 Page Should Contain Element With Wait
-    [Arguments]    ${element}
     [Documentation]    Similar to Selenium2Library.Wait Until Page Contains Element but returns web page source code when fails.
+    [Arguments]    ${element}
     BuiltIn.Wait Until Keyword Succeeds    1 min    5 sec    Selenium2Library.Page Should Contain Element    ${element}
 
 Helper Click
-    [Arguments]    ${element_to_be_clicked}    ${element_to_be_checked}
     [Documentation]    Clicks the ${element_to_be_clicked} and verifies that page contains ${element_to_be_checked}.
+    [Arguments]    ${element_to_be_clicked}    ${element_to_be_checked}
     Selenium2Library.Focus    ${element_to_be_clicked}
     Selenium2Library.Click Element    ${element_to_be_clicked}
     Selenium2Library.Wait Until Page Contains Element    ${element_to_be_checked}
 
 Patient Click
-    [Arguments]    ${element_to_be_clicked}    ${element_to_be_checked}
     [Documentation]    Combines clicking ${element_to_be_clicked} and checking that ${element_to_be_checked} is visible with
     ...    BuiltIn.Wait Until Keyword Succeeds keyword in order to secure reliable execution of Selenium2Library.Click Element
     ...    keyword in AngularJS webapp.
-    BuiltIn.Wait Until Keyword Succeeds    1 min    5 sec    Helper Click    ${element_to_be_clicked}    ${element_to_be_checked}
+    [Arguments]    ${element_to_be_clicked}    ${element_to_be_checked}
+    BuiltIn.Wait Until Keyword Succeeds
+    ...    1 min
+    ...    5 sec
+    ...    Helper Click
+    ...    ${element_to_be_clicked}
+    ...    ${element_to_be_checked}