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