Update vid tests to take into account the new selenium lib
[integration/csit.git] / tests / vid / resources / keywords / scaleout_vid_keywords.robot
1 *** Settings ***
2 Documentation     Collection of util keywords for managing SO simulator
3 Library       SeleniumLibrary
4 Library       RequestsLibrary
5 Library       OperatingSystem
6 Library       Collections
7 Library       json
8 Resource      ../../../common.robot
9
10
11 *** Keywords ***
12 Setup Expected Data In SO Simulator
13     [Documentation]    Setup data to be returned by simulator
14     [Arguments]     ${expectedResponseFilePath}   ${simulatorBaseUrl}  ${simulatorPutEndpoint}
15     ${expectedDataToReturn}=  json_from_file  ${expectedResponseFilePath}
16     ${headers}=    Create Dictionary    Content-Type=application/json
17     ${session}=  Create Session  so_simulator  ${simulatorBaseUrl}
18     ${resp}=    Put Request  so_simulator       uri=/${simulatorPutEndpoint}  data=${expectedDataToReturn}   headers=${headers}
19     Should Be Equal As Strings      ${resp.status_code}     200
20     Log to console    Successfully initialized so-simulator: status code ${resp.status_code}
21
22
23 Send Post request from VID FE
24     [Documentation]    Imitates VID UI. This keyword is designed for imitating calls from VID UI to VID BE
25     [Arguments]    ${vidBaseUrl}  ${endpoint}  ${requestFilePath}  ${expectedResponseFilePath}  ${cookie}
26     ${vidRequest}=  json_from_file  ${requestFilePath}
27     ${headers}=  Create Dictionary     Content-Type=application/json  Cookie=${cookie}
28     ${session}=  Create Session  vid  ${vidBaseUrl}
29     ${resp}=  Post Request  vid  uri=/${endpoint}  data=${vidRequest}  headers=${headers}
30     Should Be Equal As Strings  ${resp.status_code}     200
31     Log to console  ${resp.content}
32     [Return]  ${resp}
33
34
35 Login to VID Internally
36     [Arguments]     ${url}  ${username}    ${password}
37     [Documentation]  Login using Autn
38     Open browser  ${url}  chrome
39     Input Text   id=loginId    ${username}
40     Input Password  id=password  ${password}
41     Click Element  id=loginBtn
42     ${cookie}     Get Cookie    JSESSIONID
43     [Return]  JSESSIONID=${cookie.value}