Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / libraries / YangmanKeywords.robot
1 *** Settings ***
2 Documentation     A resource file containing all global keywords to help
3 ...               Yangman GUI and functional testing.
4 Library           Collections
5 Library           Selenium2Library    timeout=30    implicit_wait=30    run_on_failure=Selenium2Library.Log Source
6 Resource          ../variables/Variables.robot
7 Resource          GUIKeywords.robot
8 Resource          ../variables/YangmanGUIVariables.robot
9
10 *** Keywords ***
11 Open DLUX And Login And Navigate To Yangman URL
12     [Documentation]    Launches DLUX page using PhantomJS, or Xvfb, or real browser and navigates to yangman url.
13     GUIKeywords.Open Or Launch DLUX Page And Log In To DLUX
14     GUIKeywords.Navigate To URL    ${YANGMAN_SUBMENU_URL}
15
16 Return List Of Operation IDs
17     [Documentation]    Returns list of IDs of Get, Put, Post and Delete options in expanded operation select menu.
18     ${list}=    BuiltIn.Create List    ${GET_OPTION}    ${PUT_OPTION}    ${POST_OPTION}    ${DELETE_OPTION}
19     [Return]    ${list}
20
21 Return List Of Operation Names
22     [Documentation]    Returns list of operations names.
23     ${list}=    BuiltIn.Create List    GET    PUT    POST    DELETE
24     [Return]    ${list}
25
26 Expand Operation Select Menu
27     [Documentation]    Clicks operation select menu to expand it.
28     GUIKeywords.Patient Click    ${OPERATION_SELECT_INPUT}    ${OPERATION_SELECT_MENU_EXPANDED}
29
30 Exit Opened Application Dialog
31     [Documentation]    Closes opened/ expanded dialogs/ menus by clicking the backdrop.
32     Selenium2Library.Click Element    ${SELECT_BACKDROP}
33
34 Select Operation
35     [Arguments]    ${operation_id}
36     [Documentation]    Selects chosen operation from expanded operation select menu.
37     ${status}=    BuiltIn.Run Keyword And Return Status    GUIKeywords.Page Should Contain Element With Wait    ${OPERATION_SELECT_MENU_EXPANDED}
38     BuiltIn.Run Keyword If    "${status}"=="False"    Expand Operation Select Menu    ${OPERATION_SELECT_INPUT}
39     GUIKeywords.Focus And Click Element    ${operation_id}
40
41 Verify Selected Operation Is Displayed
42     [Arguments]    ${selected_operation_name}
43     [Documentation]    Verifies that the selected operation is now displayed in collapsed operation select menu.
44     ${selected_operation_xpath}=    BuiltIn.Set Variable    ${OPERATION_SELECT_INPUT}//span/div[contains(text(), "${selected_operation_name}")]
45     GUIKeywords.Page Should Contain Element With Wait    ${selected_operation_xpath}
46
47 Select Operation And Verify Operation Has Been Selected
48     [Arguments]    ${operation_id}    ${selected_operation_name}
49     [Documentation]    Selects chosen operation from expanded operation select menu and verifies the operation has been selected.
50     ${status}=    BuiltIn.Run Keyword And Return Status    GUIKeywords.Page Should Contain Element With Wait    ${OPERATION_SELECT_MENU_EXPANDED}
51     BuiltIn.Run Keyword If    "${status}"=="False"    Expand Operation Select Menu    ${OPERATION_SELECT_INPUT}
52     ${selected_operation_xpath}=    BuiltIn.Set Variable    ${OPERATION_SELECT_INPUT}//span/div[contains(text(), "${selected_operation_name}")]
53     GUIKeywords.Patient Click    ${operation_id}    ${selected_operation_xpath}
54
55 Expand Operation Select Menu And Select Operation
56     [Arguments]    ${operation_id}    ${selected_operation_name}
57     [Documentation]    Expands operation select menu and select operation provided as an argument.
58     Expand Operation Select Menu
59     Select Operation And Verify Operation Has Been Selected    ${operation_id}    ${selected_operation_name}
60
61 Send Request
62     [Documentation]    Clicks Send request button and waits until progression bar disappears.
63     Selenium2Library.Click Element    ${SEND_BUTTON}
64     Selenium2Library.Wait Until Page Contains Element    ${HEADER_LINEAR_PROGRESSION_BAR_HIDDEN}
65
66 Verify Request Status Code Matches Desired Code
67     [Arguments]    ${desired_code_regexp}
68     [Documentation]    Verifies that execution status code matches regexp provided as an argument.
69     ${request_status}=    BuiltIn.Wait Until Keyword Succeeds    30 s    5 s    Selenium2Library.Get Text    ${STATUS_VALUE}
70     BuiltIn.Should Match Regexp    ${request_status}    ${desired_code_regexp}
71
72 Verify Request Execution Time Is Present
73     [Documentation]    Verifies that execution time value is present.
74     ${time_value}=    BuiltIn.Wait Until Keyword Succeeds    30 s    5 s    Selenium2Library.Get Text    ${TIME_VALUE}
75     BuiltIn.Should Contain    ${time_value}    ${MILLISECONDS_LABEL}
76
77 Verify Request Execution Time Is Threedots
78     [Documentation]    Verifies that execution time value is threedots.
79     ${time_value}=    BuiltIn.Wait Until Keyword Succeeds    30 s    5 s    Selenium2Library.Get Text    ${TIME_VALUE}
80     BuiltIn.Should Contain    ${time_value}    ${THREE_DOTS_DEFAULT_STATUS_AND_TIME}
81
82 Send Request And Verify Request Status Code Matches Desired Code
83     [Arguments]    ${desired_code_regexp}
84     [Documentation]    Sends request and verifies that execution status code matches regexp provided as an argument.
85     Send Request
86     Verify Request Status Code Matches Desired Code    ${desired_code_regexp}
87     Verify Request Execution Time Is Present
88
89 Execute Chosen Operation From Form
90     [Arguments]    ${operation_id}    ${selected_operation_name}    ${selected_true_false}
91     [Documentation]    Selects operation, selects or unselects fill form with received data after execution checkbox.
92     Expand Operation Select Menu And Select Operation    ${operation_id}    ${selected_operation_name}
93     Select Fill Form With Received Data After Execution Checkbox    ${selected_true_false}
94     Send Request
95
96 Execute Chosen Operation From Form And Check Status Code
97     [Arguments]    ${operation_id}    ${selected_operation_name}    ${selected_true_false}    ${desired_code_regexp}
98     [Documentation]    Selects operation, selects or unselects fill form with received data after execution checkbox and
99     ...    verifies that execution status matches regexp provided as an argument.
100     Expand Operation Select Menu And Select Operation    ${operation_id}    ${selected_operation_name}
101     Select Fill Form With Received Data After Execution Checkbox    ${selected_true_false}
102     Send Request
103     BuiltIn.Run Keyword If    "${desired_code_regexp}"=="${THREE_DOTS_DEFAULT_STATUS_AND_TIME}"    BuiltIn.Run Keywords    Verify Request Status Code Matches Desired Code    ${THREE_DOTS_DEFAULT_STATUS_AND_TIME}
104     ...    AND    Verify Request Execution Time Is Threedots
105     BuiltIn.Run Keyword If    "${desired_code_regexp}"!="${THREE_DOTS_DEFAULT_STATUS_AND_TIME}"    BuiltIn.Run Keywords    Verify Request Status Code Matches Desired Code    ${desired_code_regexp}
106     ...    AND    Verify Request Execution Time Is Present
107
108 Return Labelled Api Path Input
109     [Arguments]    ${branch_label_without_curly_braces_part}
110     [Documentation]    Returns Xpath of labelled API path input field.
111     ${labelled_api_path_input}=    BuiltIn.Set Variable    ${API_PATH}//span[contains(text(), "/${branch_label_without_curly_braces_part}")]//parent::md-input-container//following-sibling::md-input-container[last()]/input
112     [Return]    ${labelled_api_path_input}
113
114 Verify Yangman Home Page Elements
115     [Documentation]    Verifies presence of Yangman home page elements.
116     Selenium2Library.Wait Until Page Contains Element    ${YANGMAN_LOGO}
117     Selenium2Library.Log Location
118     Modules Tab Is Selected
119     Selenium2Library.Page Should Contain Element    ${TOGGLE_MENU_BUTTON}
120     Selenium2Library.Page Should Contain Element    ${LOGOUT_BUTTON}
121     Verify Selected Operation Is Displayed    GET
122     Selenium2Library.Page Should Contain Element    ${REQUEST_URL_INPUT}
123     Selenium2Library.Page Should Contain Element    ${SEND_BUTTON}
124     Selenium2Library.Page Should Contain Element    ${SAVE_BUTTON}
125     Selenium2Library.Page Should Contain Element    ${PARAMETERS_BUTTON}
126     Selenium2Library.Page Should Contain Element    ${FORM_RADIOBUTTON_UNSELECTED}
127     Selenium2Library.Page Should Contain Element    ${JSON_RADIOBUTTON_SELECTED}
128     Selenium2Library.Page Should Contain Element    ${SHOW_SENT_DATA_CHECKBOX_UNSELECTED}
129     Selenium2Library.Page Should Contain Element    ${SHOW_RECEIVED_DATA_CHECKBOX_SELECTED}
130     Selenium2Library.Page Should Contain Element    ${RECEIVED_DATA_CODE_MIRROR_DISPLAYED}
131     Selenium2Library.Page Should Contain Element    ${RECEIVED_DATA_ENLARGE_FONT_SIZE_BUTTON}
132     Selenium2Library.Page Should Contain Element    ${RECEIVED_DATA_REDUCE_FONT_SIZE_BUTTON}
133     Selenium2Library.Page Should Not Contain Element    ${SENT_DATA_CODE_MIRROR_DISPLAYED}
134
135 Select Form View
136     [Documentation]    Click Form radiobutton to display form view.
137     ${status}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Page Should Contain Element    ${FORM_RADIOBUTTON_SELECTED}
138     BuiltIn.Run Keyword If    "${status}"=="False"    GUIKeywords.Patient Click    ${FORM_RADIOBUTTON_UNSELECTED}    ${FORM_RADIOBUTTON_SELECTED}
139
140 Select Json View
141     [Documentation]    Click Json radiobutton to display json view.
142     ${status}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Page Should Contain Element    ${JSON_RADIOBUTTON_SELECTED}
143     BuiltIn.Run Keyword If    "${status}"=="False"    GUIKeywords.Patient Click    ${JSON_RADIOBUTTON_UNSELECTED}    ${JSON_RADIOBUTTON_SELECTED}
144
145 Modules Tab Is Selected
146     [Documentation]    Verifies that module tab is selected and history and collection tabs are unselected.
147     Selenium2Library.Page Should Contain Element    ${MODULES_TAB_SELECTED}
148     Selenium2Library.Page Should Contain Element    ${MODULE_SEARCH_INPUT}
149     Selenium2Library.Page Should Contain Element    ${HISTORY_TAB_UNSELECTED}
150     Selenium2Library.Page Should Contain Element    ${COLLECTIONS_TAB_UNSELECTED}
151
152 Return Number Of Modules Loaded
153     [Arguments]    ${module_xpath}
154     [Documentation]    Returns number of modules loaded in Modules tab.
155     ${number_of_modules}=    Selenium2Library.Get Matching Xpath Count    ${module_xpath}
156     [Return]    ${number_of_modules}
157
158 Verify Any Module Is Loaded
159     [Documentation]    Verifies that at least one module has been loaded in Modules tab.
160     ${number_of__modules_loaded}=    Return Number Of Modules Loaded    ${MODULE_LIST_ITEM}
161     BuiltIn.Should Be True    ${number_of_modules_loaded}>0
162
163 Return Module List Indexed Module
164     [Arguments]    ${index}
165     [Documentation]    Returns indexed Xpath of the module. ${index} is a number.
166     ${module_index}=    BuiltIn.Set Variable    ${MODULE_ID_LABEL}${index}
167     ${module_list_item_indexed}=    BuiltIn.Set Variable    ${MODULE_TAB_CONTENT}//md-list-item[@id="${module_index}"]//div[@class="pointer title layout-align-center-center layout-row"]
168     [Return]    ${module_list_item_indexed}
169
170 Return Indexed Module Operations Label
171     [Arguments]    ${index}
172     [Documentation]    Returns Xpath of the indexed module's operations item in Modules tab.
173     ${module_list_item_indexed}=    Return Module List Indexed Module    ${index}
174     ${indexed_module_operations_label}=    BuiltIn.Set Variable    ${module_list_item_indexed}//following-sibling::md-list[@aria-hidden="false"]//p[contains(., "${OPERATIONS_LABEL}")]
175     [Return]    ${indexed_module_operations_label}
176
177 Return Indexed Module Operational Label
178     [Arguments]    ${index}
179     [Documentation]    Returns Xpath of the indexed module`s operational in Modules tab.
180     ${module_list_item_indexed}=    Return Module List Indexed Module    ${index}
181     ${indexed_module_operational_label}=    BuiltIn.Set Variable    ${module_list_item_indexed}//following-sibling::md-list[@aria-hidden="false"]//p[contains(., "${OPERATIONAL_LABEL}")]
182     [Return]    ${indexed_module_operational_label}
183
184 Return Indexed Module Config Label
185     [Arguments]    ${index}
186     [Documentation]    Returns Xpath of the indexed module`s config in Modules tab.
187     ${module_list_item_indexed}=    Return Module List Indexed Module    ${index}
188     ${indexed_module_config_label}=    BuiltIn.Set Variable    ${module_list_item_indexed}//following-sibling::md-list[@aria-hidden="false"]//p[contains(., "${CONFIG_LABEL}")]
189     [Return]    ${indexed_module_config_label}
190
191 Click Indexed Module Operations To Load Module Detail Operations Tab
192     [Arguments]    ${index}
193     [Documentation]    Clicks indexed module`s operations to load module detail operations tab.
194     ${indexed_module_operations}=    Return Indexed Module Operations Label    ${index}
195     Selenium2Library.Wait Until Page Contains Element    ${indexed_module_operations}
196     GUIKeywords.Focus And Click Element    ${indexed_module_operations}
197     Selenium2Library.Wait Until Page Contains Element    ${MODULE_DETAIL_OPERATIONS_TAB_SELECTED}
198
199 Click Indexed Module Operational To Load Module Detail Operational Tab
200     [Arguments]    ${index}
201     [Documentation]    Clicks indexed module`s operational to load module detail operational tab.
202     ${indexed_module_operational}=    Return Indexed Module Operational Label    ${index}
203     Selenium2Library.Wait Until Page Contains Element    ${indexed_module_operational}
204     GUIKeywords.Focus And Click Element    ${indexed_module_operational}
205     Selenium2Library.Wait Until Page Contains Element    ${MODULE_DETAIL_OPERATIONAL_TAB_SELECTED}
206
207 Click Indexed Module Config To Load Module Detail Config Tab
208     [Arguments]    ${index}
209     [Documentation]    Clicks indexed module`s config to load module detail config tab.
210     ${indexed_module_config}=    Return Indexed Module Config Label    ${index}
211     Selenium2Library.Wait Until Page Contains Element    ${indexed_module_config}
212     GUIKeywords.Focus And Click Element    ${indexed_module_config}
213     Selenium2Library.Wait Until Page Contains Element    ${MODULE_DETAIL_CONFIG_TAB_SELECTED}
214
215 Return Module ID Index From Module Name
216     [Arguments]    ${module_name}
217     [Documentation]    Returns number - module id index from module name.
218     ${testing_module_xpath}=    BuiltIn.Set Variable    ${MODULE_TAB_CONTENT}//p[contains(., "${module_name}")]//ancestor::md-list-item[contains(@id, "${MODULE_ID_LABEL}")]
219     ${module_id}=    Selenium2Library.Get Element Attribute    ${testing_module_xpath}@id
220     ${module_id_index}=    String.Fetch From Right    ${module_id}    ${MODULE_ID_LABEL}
221     [Return]    ${module_id_index}
222
223 Return Indexed Module From Module Name
224     [Arguments]    ${module_name}
225     [Documentation]    Returns indexed Xpath of the module from the module`s name.
226     ${module_id_index}=    Return Module ID Index From Module Name    ${module_name}
227     ${module_list_item_indexed}=    Return Module List Indexed Module    ${module_id_index}
228     [Return]    ${module_list_item_indexed}
229
230 Return Module List Item Collapsed Indexed
231     [Arguments]    ${index}
232     [Documentation]    Returns Xpath of collapsed indexed module.
233     ${indexed_module}=    Return Module List Indexed Module    ${index}
234     ${module_list_item_collapsed_indexed}=    BuiltIn.Set Variable    ${indexed_module}//following-sibling::md-list[@aria-hidden="true"]
235     [Return]    ${module_list_item_collapsed_indexed}
236
237 Return Module List Item Expanded Indexed
238     [Arguments]    ${index}
239     [Documentation]    Returns Xpath of expanded indexed module.
240     ${indexed_module}=    Return Module List Indexed Module    ${index}
241     ${module_list_item_expanded_indexed}=    BuiltIn.Set Variable    ${indexed_module}//following-sibling::md-list[@aria-hidden="false"]
242     [Return]    ${module_list_item_expanded_indexed}
243
244 Return Indexed Module Expander Icon
245     [Arguments]    ${index}
246     [Documentation]    Returns xpath of indexed module expander icon.
247     ${indexed_module}=    Return Module List Indexed Module    ${index}
248     ${indexed_module_expander_icon}=    BuiltIn.Set Variable    ${indexed_module}/md-icon
249     [Return]    ${indexed_module_expander_icon}
250
251 Expand Module
252     [Arguments]    ${module_name}    ${module_id_index}
253     [Documentation]    Clicks module list item in modules tab to expand the item and display its operations/ operational/ config items.
254     ...    Arguments are either module name, or module id index, that is a number, or ${EMPTY}, if the option is not used.
255     ${module_list_item_indexed}=    BuiltIn.Run Keyword If    "${module_name}"!= "${EMPTY}"    Return Indexed Module From Module Name    ${module_name}
256     ${module_list_item_indexed}=    BuiltIn.Run Keyword If    "${module_id_index}"!= "${EMPTY}"    Return Module List Indexed Module    ${module_id_index}
257     ${module_list_item_expanded_indexed}=    BuiltIn.Set Variable    ${module_list_item_indexed}//following-sibling::md-list[@aria-hidden="false"]
258     GUIKeywords.Mouse Down And Mouse Up Click Element    ${module_list_item_indexed}
259     Selenium2Library.Wait Until Page Contains Element    ${module_list_item_expanded_indexed}
260
261 Expand Module And Click Module Operational Item
262     [Arguments]    ${module_name}    ${module_id_index}
263     [Documentation]    Clicks module list item in modules tab and then clicks its operational item to load operational tab in module detail.
264     ...    Arguments are either module name, or module id index, that is a number, or ${EMPTY}, if the option is not used.
265     Expand Module    ${module_name}    ${module_id_index}
266     Click Indexed Module Operational To Load Module Detail Operational Tab    ${module_id_index}
267
268 Expand Module And Click Module Config Item
269     [Arguments]    ${module_name}    ${module_id_index}
270     [Documentation]    Clicks module list item in modules tab and then clicks its config item to load operational tab in module detail.
271     ...    Arguments are either module name, or module id index, that is a number, or ${EMPTY}, if the option is not used.
272     Expand Module    ${module_name}    ${module_id_index}
273     Click Indexed Module Config To Load Module Detail Config Tab    ${module_id_index}
274
275 Navigate From Yangman Submenu To Testing Module Operational Tab
276     [Arguments]    ${testing_module_name}
277     [Documentation]    Navigates from loaded Yangman URL to testing module detail operational tab.
278     ${module_id_index}=    YangmanKeywords.Return Module ID Index From Module Name    ${testing_module_name}
279     Selenium2Library.Wait Until Page Does Not Contain Element    ${MODULES_WERE_LOADED_ALERT}
280     Expand Module And Click Module Operational Item    ${EMPTY}    ${module_id_index}
281
282 Navigate From Yangman Submenu To Testing Module Config Tab
283     [Arguments]    ${testing_module_name}
284     [Documentation]    Navigates from loaded Yangman URL to testing module detail config tab.
285     ${module_id_index}=    YangmanKeywords.Return Module ID Index From Module Name    ${testing_module_name}
286     Selenium2Library.Wait Until Page Does Not Contain Element    ${MODULES_WERE_LOADED_ALERT}
287     Expand Module And Click Module Config Item    ${EMPTY}    ${module_id_index}
288
289 Compose Branch Id
290     [Arguments]    ${index}
291     [Documentation]    Composes and returns string - branch id in the format branch-${index}.
292     BuiltIn.Return From Keyword    ${BRANCH_ID_LABEL}${index}
293
294 Toggle Module Detail To Modules Or History Or Collections Tab
295     [Documentation]    Click toggle module detail button to toggle from module detail to modules or history or collections tab.
296     Selenium2Library.Wait Until Element Is Visible    ${TOGGLE_MODULE_DETAIL_BUTTON_LEFT}
297     GUIKeywords.Focus And Click Element    ${TOGGLE_MODULE_DETAIL_BUTTON_LEFT}
298
299 Select Module Detail Operational Tab
300     [Documentation]    Selects operational tab in module detail.
301     ${status}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Page Should Contain Element    ${MODULE_DETAIL_OPERATIONAL_TAB_SELECTED}
302     BuiltIn.Run Keyword If    "${status}"=="False"    Selenium2Library.Click Element    ${MODULE_DETAIL_OPERATIONAL_TAB_DESELECTED}
303     Selenium2Library.Wait Until Page Contains Element    ${MODULE_DETAIL_OPERATIONAL_TAB_SELECTED}
304
305 Select Module Detail Config Tab
306     [Documentation]    Selects config tab in module detail.
307     ${status}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Page Should Contain Element    ${MODULE_DETAIL_CONFIG_TAB_SELECTED}
308     BuiltIn.Run Keyword If    "${status}"=="False"    Selenium2Library.Click Element    ${MODULE_DETAIL_CONFIG_TAB_DESELECTED}
309     Selenium2Library.Wait Until Page Contains Element    ${MODULE_DETAIL_CONFIG_TAB_SELECTED}
310
311 Expand All Branches In Module Detail Content Active Tab
312     [Documentation]    Expands all branches in module detail active operations or operational or config tab.
313     Selenium2Library.Wait Until Element Is Visible    ${MODULE_DETAIL_EXPAND_BRANCH_BUTTON}
314     FOR    ${i}    IN RANGE    1    1000
315         ${count}=    Selenium2Library.Get Matching Xpath Count    ${MODULE_DETAIL_EXPAND_BRANCH_BUTTON}
316         BuiltIn.Exit For Loop If    ${count}==0
317         BuiltIn.Wait Until Keyword Succeeds    30 s    5 s    GUIKeywords.Focus And Click Element    ${MODULE_DETAIL_EXPAND_BRANCH_BUTTON}
318     END
319     Selenium2Library.Wait Until Page Does Not Contain Element    ${MODULE_DETAIL_EXPAND_BRANCH_BUTTON}
320
321 Collapse All Branches In Module Detail Content Active Tab
322     [Documentation]    Collapses all branches in module detail active operations or operational or config tab.
323     Selenium2Library.Wait Until Element Is Visible    ${MODULE_DETAIL_COLLAPSE_BRANCH_BUTTON}
324     FOR    ${i}    IN RANGE    1    1000
325         ${count}=    Selenium2Library.Get Matching Xpath Count    ${MODULE_DETAIL_COLLAPSE_BRANCH_BUTTON}
326         BuiltIn.Exit For Loop If    ${count}==0
327         BuiltIn.Wait Until Keyword Succeeds    30 s    5 s    GUIKeywords.Focus And Click Element    ${MODULE_DETAIL_COLLAPSE_BRANCH_BUTTON}
328     END
329     Selenium2Library.Wait Until Page Does Not Contain Element    ${MODULE_DETAIL_COLLAPSE_BRANCH_BUTTON}
330
331 Return Module Detail Labelled Branch Xpath
332     [Arguments]    ${branch_label}
333     [Documentation]    Returns xpath of module detail labelled branch.
334     ${labelled_branch_xpath}=    BuiltIn.Set Variable    ${MODULE_DETAIL_BRANCH}//span[contains(@class, "indented tree-label ng-binding flex") and contains(text(), "${branch_label}")]
335     [Return]    ${labelled_branch_xpath}
336
337 Return Module Detail Branch ID From Branch Label
338     [Arguments]    ${branch_label}
339     [Documentation]    Returns string - module detail branch id in the format branch-${index}.
340     ${labelled_branch_xpath}=    Return Module Detail Labelled Branch Xpath    ${branch_label}
341     ${branch_id}=    Selenium2Library.Get Element Attribute    ${labelled_branch_xpath}//ancestor::md-list-item[contains(@id, "${BRANCH_ID_LABEL}")]@id
342     [Return]    ${branch_id}
343
344 Return Module Detail Branch Indexed
345     [Arguments]    ${branch_id}
346     [Documentation]    Returns indexed Xpath of the module detail branch. Argument is ${branch_id} in the form "branch-"${index}"".
347     ${module_detail_branch_indexed}=    BuiltIn.Set Variable    ${MODULE_DETAIL_ACTIVE_TAB_CONTENT}//md-list-item[contains(@id, "${branch_id}")]
348     [Return]    ${module_detail_branch_indexed}
349
350 Return Indexed Branch Label
351     [Arguments]    ${module_detail_branch_indexed}
352     [Documentation]    Returns string - label of indexed branch in module detail.
353     ${branch_label}=    Selenium2Library.Get Text    ${module_detail_branch_indexed}//span[@class="indented tree-label ng-binding flex"]
354     [Return]    ${branch_label}
355
356 Return Branch Label Without Curly Braces Part
357     [Arguments]    ${branch_label}
358     [Documentation]    Returns string - part of label of indexed branch in module detail without curly braces part.
359     ${branch_label_without_curly_braces_part}=    String.Fetch From Left    ${branch_label}    ${SPACE}
360     [Return]    ${branch_label_without_curly_braces_part}
361
362 Return Branch Label Curly Braces Part Without Braces
363     [Arguments]    ${branch_label}
364     [Documentation]    Returns string - curly braces part of label of indexed branch in module detail without curly braces.
365     ${branch_label_curly_braces_part}=    String.Fetch From Right    ${branch_label}    ${SPACE}
366     ${branch_label_curly_braces_part}=    String.Strip String    ${branch_label_curly_braces_part}    characters={}
367     [Return]    ${branch_label_curly_braces_part}
368
369 Return Labelled Branch Toggle Button
370     [Arguments]    ${labelled_branch_xpath}
371     [Documentation]    Returns xpath of toggle button of labelled branch in module detail.
372     ${labelled_branch_toggle_button}=    BuiltIn.Set Variable    ${labelled_branch_xpath}//preceding-sibling::md-icon[contains(@id, "toggle-branch-")]
373     [Return]    ${labelled_branch_toggle_button}
374
375 Return Branch Toggle Button From Branch Label And Click
376     [Arguments]    ${branch_label}
377     [Documentation]    Returns xpath toggle button of labelled branch in module detail and clicks it.
378     ${labelled_branch_xpath}=    Return Module Detail Labelled Branch Xpath    ${branch_label}
379     ${labelled_branch_toggle_button}=    Return Labelled Branch Toggle Button    ${labelled_branch_xpath}
380     Selenium2Library.Page Should Contain Element    ${labelled_branch_toggle_button}
381     Selenium2Library.Click Element    ${labelled_branch_toggle_button}
382
383 Click Module Detail Branch Indexed
384     [Arguments]    ${module_detail_branch_indexed}
385     [Documentation]    Click indexed branch in module detail.
386     Selenium2Library.Page Should Contain Element    ${module_detail_branch_indexed}
387     GUIKeywords.Mouse Down And Mouse Up Click Element    ${module_detail_branch_indexed}
388
389 Return And Click Module Detail Branch Indexed
390     [Arguments]    ${branch_label}
391     [Documentation]    Returns and click Click indexed branch in module detail.
392     ${branch_id}=    Return Module Detail Branch ID From Branch Label    ${branch_label}
393     ${module_detail_branch_indexed}=    Return Module Detail Branch Indexed    ${branch_id}
394     Click Module Detail Branch Indexed    ${module_detail_branch_indexed}
395
396 Verify Module Detail Branch Is List Branch
397     [Arguments]    ${module_detail_branch_indexed}
398     [Documentation]    Returns status "True" if module detail branch is a list branch and "False" if module detail branch is not a list brnach.
399     ${branch_label}=    Return Indexed Branch Label    ${module_detail_branch_indexed}
400     ${branch_is_list_evaluation}=    BuiltIn.Run Keyword And Return Status    BuiltIn.Should Contain    ${branch_label}    {
401     [Return]    ${branch_is_list_evaluation}
402
403 Return Form Top Element Label
404     [Documentation]    Returns string - form top element label.
405     ${form_top_element_label}=    Selenium2Library.Get Text    ${FORM_TOP_ELEMENT_LABEL_XPATH}
406     [Return]    ${form_top_element_label}
407
408 Return Form Top Element Labelled
409     [Arguments]    ${label}
410     [Documentation]    Returns xpath of form top element with label.
411     ${form_top_element_labelled}=    BuiltIn.Set Variable    ${FORM_TOP_ELEMENT_POINTER}//span[contains(@class, "ng-binding ng-scope") and contains(text(), "${label}")]
412     [Return]    ${form_top_element_labelled}
413
414 Return Form List Item With Index Or Key
415     [Arguments]    ${branch_label}    ${branch_label_curly_braces_part}    ${index_or_key}
416     [Documentation]    Returns string - catenated branch label and index, in the form "label [${index_or_key}]" or "label <${branch_label_curly_braces_part}:${index_or_key}>".
417     ${branch_label_without_curly_braces_part}=    Return Branch Label Without Curly Braces Part    ${branch_label}
418     ${key_part}=    BuiltIn.Set Variable    <${branch_label_curly_braces_part}:${index_or_key}>
419     ${list_item_with_index_or_key}=    BuiltIn.Set Variable If    "${branch_label_curly_braces_part}"=="${EMPTY}"    ${FORM_TOP_ELEMENT_LIST_ITEM_LABEL}[contains(text(), "${branch_label_without_curly_braces_part}") and contains(text(), "[${index_or_key}]")]    ${FORM_TOP_ELEMENT_LIST_ITEM_LABEL}[contains(text(), "${branch_label_without_curly_braces_part}") and contains(text(), "${key_part}")]
420     [Return]    ${list_item_with_index_or_key}
421
422 Click Form List Item With Index Or Key
423     [Arguments]    ${branch_label}    ${id/ref/prefix_part}    ${index/key}
424     [Documentation]    Clicks form list item with given index or key is visible.
425     ${list_item_with_index_or_key}=    Return Form List Item With Index Or Key    ${branch_label}    ${id/ref/prefix_part}    ${index/key}
426     Selenium2Library.Click Element    ${list_item_with_index_or_key}
427
428 Verify List Item With Index Or Key Is Visible
429     [Arguments]    ${branch_label}    ${branch_label_curly_braces_part}    ${index_or_key}
430     [Documentation]    Verifies that form list item with given index or key is visible.
431     ${list_item_with_index_or_key}=    Return Form List Item With Index Or Key    ${branch_label}    ${branch_label_curly_braces_part}    ${index_or_key}
432     Selenium2Library.Wait Until Element Is Visible    ${list_item_with_index_or_key}
433
434 Load And Expand Network Topology In Form
435     [Documentation]    Loads and expands network-topology top element container.
436     Select Form View
437     YangmanKeywords.Return And Click Module Detail Branch Indexed    ${Network_Topology_Branch_Label}
438     Selenium2Library.Page Should Contain Element    ${FORM_TOP_ELEMENT_CONTAINER}
439     Selenium2Library.Click Element    ${FORM_TOP_ELEMENT_POINTER}
440
441 Load Topology Topology Id Node In Form
442     [Documentation]    Expands network-topology branch in testing module detail and clicks topology {topology-id} branch to load topology list node in form.
443     Select Form View
444     ${topology_topology_id_branch}=    Return Module Detail Labelled Branch Xpath    ${TOPOLOGY_TOPOLOGY_ID_LABEL}
445     ${status}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Element Should Be Visible    ${topology_topology_id_branch}
446     BuiltIn.Run Keyword If    "${status}"=="False"    Return Branch Toggle Button From Branch Label And Click    ${NETWORK_TOPOLOGY_LABEL}
447     YangmanKeywords.Return Branch Toggle Button From Branch Label And Click    ${TOPOLOGY_TOPOLOGY_ID_LABEL}
448     Verify List Item With Index Or Key Is Visible    ${TOPOLOGY_TOPOLOGY_ID_LABEL}    ${EMPTY}    0
449
450 Load Node Node Id Node In Form
451     [Documentation]    Expands network-topology branch in testing module detail and clicks topology {topology-id} branch to load topology list node in form.
452     Select Form View
453     ${node_node_id_branch}=    Return Module Detail Labelled Branch Xpath    ${NODE_NODE_ID_LABEL}
454     ${node_branch_is_visible}=    BuiltIn.Run Keyword And Return Status    Selenium2Library.Element Should Be Visible    ${node_node_id_branch}
455     BuiltIn.Run Keyword If    "${node_branch_is_visible}"=="False"    Run Keywords    Load Topology Topology Id Node In Form
456     ...    AND    Return Branch Toggle Button From Branch Label And Click    ${TOPOLOGY_TOPOLOGY_ID_LABEL}
457     YangmanKeywords.Return And Click Module Detail Branch Indexed    ${NODE_NODE_ID_LABEL}
458     Verify List Item With Index Or Key Is Visible    ${NODE_NODE_ID_LABEL}    ${EMPTY}    0
459
460 Return Labelled Element Yangmenu
461     [Arguments]    ${label}
462     [Documentation]    Returns xpath of labelled element yangmenu in form.
463     ${form_top_element_labelled}=    Return Form Top Element Labelled    ${label}
464     ${form_labelled_element_yangmenu}=    BuiltIn.Set Variable    ${form_top_element_labelled}//following::yang-form-menu
465     [Return]    ${form_labelled_element_yangmenu}
466
467 Return And Click Labelled Element Yangmenu
468     [Arguments]    ${label}
469     [Documentation]    Returns xpath of labelled element yangmenu in form and clicks the yangmenu.
470     ${form_labelled_element_yangmenu}=    Return Labelled Element Yangmenu    ${label}
471     Selenium2Library.Element Should Be Visible    ${form_labelled_element_yangmenu}
472     GUIKeywords.Mouse Down And Mouse Up Click Element    ${form_labelled_element_yangmenu}
473
474 Return Labelled Element Show Previous Item Arrow
475     [Arguments]    ${label}
476     [Documentation]    Returns xpath of labelled element show previous list item icon in form.
477     ${form_top_element_labelled}=    Return Form Top Element Labelled    ${label}
478     ${labelled_show_previous_item_arrow}=    BuiltIn.Set Variable    ${form_top_element_labelled}//following::md-prev-button[@aria-label="Previous Page"]
479     [Return]    ${labelled_show_previous_item_arrow}
480
481 Return Labelled Element Show Next Item Arrow
482     [Arguments]    ${label}
483     [Documentation]    Returns xpath of labelled element show next list item icon.
484     ${form_top_element_labelled}=    Return Form Top Element Labelled    ${label}
485     ${labelled_show_next_item_arrow}=    BuiltIn.Set Variable    ${form_top_element_labelled}//following::md-next-button[@aria-label="Next Page"]
486     [Return]    ${labelled_show_next_item_arrow}
487
488 Return Labelled Form Input Field
489     [Arguments]    ${branch_label_curly_braces_part}
490     [Documentation]    Returns xpath of labelled form input field.
491     ${labelled_input_field}=    BuiltIn.Set Variable    ${FORM_CONTENT}//span[contains(@class, "ng-binding ng-scope") and contains(text(), "${branch_label_curly_braces_part}")]//following::input
492     [Return]    ${labelled_input_field}
493
494 Return Labelled Form Select
495     [Arguments]    ${branch_label_curly_braces_part}
496     [Documentation]    Returns labelled form input field.
497     ${labelled_select}=    BuiltIn.Set Variable    ${FORM_CONTENT}//span[contains(@class, "ng-binding ng-scope") and contains(text(), "${branch_label_curly_braces_part}")]//following::md-select
498     [Return]    ${labelled_select}
499
500 Input Text To Labelled Form Input Field
501     [Arguments]    ${branch_label_curly_braces_part}    ${text}
502     [Documentation]    Returns labelled form input field and inputs the text provided as an argument into it.
503     ${labelled_input_field}=    Return Labelled Form Input Field    ${branch_label_curly_braces_part}
504     Selenium2Library.Input Text    ${labelled_input_field}    ${text}
505
506 Verify Form Contains Error Message
507     [Arguments]    ${error_message}
508     [Documentation]    Verifies that the form contains error message that is provided as an argument.
509     ${form_error_message}=    BuiltIn.Set Variable    //p[contains(@id, "form-error-message") and contains (text(), "${error_message}")]
510     Selenium2Library.Page Should Contain Element    ${form_error_message}
511
512 Verify No Data Are Displayed In Code Mirror Code
513     [Arguments]    ${code_mirror_code}
514     [Documentation]    Verifies that there are no data displayed in either sent or received data code mirror.
515     ...    Value for ${code_mirror_code} is either ${SENT_DATA_CODE_MIRROR_CODE} or ${RECEIVED_DATA_CODE_MIRROR_CODE}.
516     ${number_of_lines_in_code_mirror}=    Selenium2Library.Get Matching Xpath Count    ${code_mirror_code}/div
517     BuiltIn.Should Be Equal    ${number_of_lines_in_code_mirror}    1
518
519 Verify Sent Data CM Is Displayed
520     [Documentation]    Verifies that sent data code mirror is displayed.
521     Selenium2Library.Wait Until Element Is Visible    ${SENT_DATA_CODE_MIRROR_DISPLAYED}
522
523 Verify Sent Data CM Is Not Displayed
524     [Documentation]    Verifies that sent data code mirror is not displayed.
525     Selenium2Library.Wait Until Element Is Not Visible    ${SENT_DATA_CODE_MIRROR_DISPLAYED}
526
527 Verify Received Data CM Is Displayed
528     [Documentation]    Verifies that received data code mirror is displayed.
529     Selenium2Library.Wait Until Element Is Visible    ${RECEIVED_DATA_CODE_MIRROR_DISPLAYED}
530
531 Verify Received Data CM Is Not Displayed
532     [Documentation]    Verifies that received data code mirror is not displayed.
533     Selenium2Library.Wait Until Element Is Not Visible    ${RECEIVED_DATA_CODE_MIRROR_DISPLAYED}