Showing
1 changed file
with
570 additions
and
0 deletions
publicbid_common.robot
0 → 100644
1 | +*** Settings *** | |
2 | + | |
3 | +Library Selenium2Library | |
4 | +Library String | |
5 | +Library Collections | |
6 | +Library playtender_service.py | |
7 | +Resource playtender_variables.robot | |
8 | + | |
9 | +*** Variables *** | |
10 | + | |
11 | +${broker} = playtender | |
12 | +${broker_username} = | |
13 | +${broker_baseurl} = | |
14 | +${broker_browser} = | |
15 | +${broker_language_code} = uk | |
16 | +${test_role} = | |
17 | +${is_test_role_owner} = | |
18 | + | |
19 | +@{browser_default_size} = ${1200} ${1000} | |
20 | +@{browser_default_position} = ${0} ${0} | |
21 | + | |
22 | +${popup_transaction_time} = 600ms | |
23 | + | |
24 | +*** Keywords *** | |
25 | + | |
26 | +init environment | |
27 | + [Arguments] ${username} | |
28 | + [Documentation] ініціює необхідні глобальні змінні | |
29 | + | |
30 | + set global variable ${broker_username} ${username} | |
31 | + set global variable ${broker_baseurl} ${BROKERS['${broker}'].basepage} | |
32 | + set global variable ${broker_browser} ${USERS.users['${broker_username}'].browser} | |
33 | + set global variable ${test_role} ${ROLE} | |
34 | + ${is_test_role_owner} = set variable if '${test_role}' == 'tender_owner' ${True} ${False} | |
35 | + set global variable ${is_test_role_owner} ${is_test_role_owner} | |
36 | + | |
37 | + register keyword to run on failure __private__handle_keyword_failure | |
38 | + | |
39 | +set site language by code | |
40 | + [Arguments] ${language_code} | |
41 | + [Documentation] змінити мову сайту | |
42 | + | |
43 | + ${is_equal} = __private__check_site_language_code ${language_code} | |
44 | + run keyword if ${is_equal} == ${False} __private__open_site_language_dropdown_and_select_language_by_code ${language_code} | |
45 | + | |
46 | +login to site | |
47 | + [Arguments] ${user_data} | |
48 | + [Documentation] авторизувати вказаного користувача, масив повинен містити login, password | |
49 | + | |
50 | +# click visible element ${login_popup_open_locator} | |
51 | +# wait until popup is visible | |
52 | + open popup by btn locator ${login_popup_open_locator} | |
53 | + input text to visible input ${login_popup_login_input_locator} ${user_data['login']} | |
54 | + input text to visible input ${login_popup_password_input_locator} ${user_data['password']} | |
55 | + click visible element ${login_popup_submit_btn_locator} | |
56 | + wait until page contains element ${user_logged_checker_element_locator} 30s User can not login | |
57 | + | |
58 | +fill item form in opened popup | |
59 | + [Arguments] ${data} | |
60 | + [Documentation] заповнює відкриту форму згідно вказаних даних | |
61 | + | |
62 | + ${description} = get from dictionary by keys ${data} description | |
63 | + run keyword if condition is not none ${description} input text to visible input ${item_form_popup_description_input_locator} ${description} | |
64 | + ${description_ru} = get from dictionary by keys ${data} description_ru | |
65 | + run keyword if condition is not none ${description_ru} input text to exist visible input ${item_form_popup_description_ru_input_locator} ${description_ru} | |
66 | + ${description_en} = get from dictionary by keys ${data} description_en | |
67 | + run keyword if condition is not none ${description_en} input text to exist visible input ${item_form_popup_description_en_input_locator} ${description_en} | |
68 | + ${quantity} = get from dictionary by keys ${data} quantity | |
69 | + run keyword and ignore error run keyword if condition is not none ${quantity} input number3 to visible input ${item_form_popup_quantity_input_locator} ${quantity} | |
70 | + ${unit} = get from dictionary by keys ${data} unit name | |
71 | + run keyword if condition is not none ${unit} select from visible list by label ${item_form_popup_unit_input_locator} ${unit} | |
72 | + ${classification} = get from dictionary by keys ${data} classification | |
73 | + run keyword if condition is not none ${classification} run keyword if '${mode}' not in 'framework_selection' select classification by code attributes ${item_form_popup_classification_edit_btn_locator} ${classification} | |
74 | + ${additional_classifications} = get from dictionary by keys ${data} additionalClassifications | |
75 | + run keyword if condition is not none ${additional_classifications} run keyword if '${mode}' not in 'framework_selection' select classification by array of code attributes ${item_form_popup_additional_classification_edit_btn_locator} ${additional_classifications} | |
76 | + | |
77 | +get value by locator on opened page | |
78 | + [Arguments] ${locator} ${type}=${None} | |
79 | + [Documentation] отримує значення з відповідного локатору і якщо потрібно перетворює до відповідного типу | |
80 | + | |
81 | + capture page screenshot | |
82 | + Run Keyword And Ignore Error __private__set_element_visible_in_browser_area ${locator} | |
83 | + ${value} = get value by locator ${locator} | |
84 | + ${value} = convert to specified type ${value} ${type} | |
85 | + [Return] ${value} | |
86 | + | |
87 | +get field_value by field_name on opened page | |
88 | + [Arguments] ${field_name} | |
89 | + [Documentation] повертає інформацію з відкритої сторінки, користуючись назвою поля ${field_name}. | |
90 | + ... для назви поля повинен бути вказаний відповідний локатор (!вкінці змінної повинно бути слово locator), | |
91 | + ... і якщо потрібно тип поля окремою змінною (!locator замінюється на type) зі значенням [string,integer,float] | |
92 | + | |
93 | + ${field_name_prepared} = replace string ${field_name} .[ _ | |
94 | + ${field_name_prepared} = replace string ${field_name_prepared} ]. _ | |
95 | + ${field_name_prepared} = replace string ${field_name_prepared} . _ | |
96 | + ${field_name_prepared} = replace string ${field_name_prepared} [ _ | |
97 | + ${field_name_prepared} = replace string ${field_name_prepared} ] _ | |
98 | + ${field_locator_variable_name} = set variable ${field_name_prepared}_locator | |
99 | + ${field_type_variable_name} = set variable ${field_name_prepared}_type | |
100 | + ${field_type_variable_exists} = run keyword and return status variable should exist ${${field_type_variable_name}} | |
101 | + ${field_type} = set variable if ${field_type_variable_exists} == ${True} ${${field_type_variable_name}} ${None} | |
102 | + ${field_locator} = set variable ${${field_locator_variable_name}} | |
103 | + ${field_value} = get value by locator on opened page ${field_locator} ${field_type} | |
104 | + [Return] ${field_value} | |
105 | + | |
106 | +######################################################################################################################## | |
107 | +#################################################### COMMON HELPERS #################################################### | |
108 | +######################################################################################################################## | |
109 | + | |
110 | +click visible element | |
111 | + [Arguments] ${locator} | |
112 | + [Documentation] перевіряє видимість і клікає по елементу | |
113 | + | |
114 | + __private__set_element_visible_in_browser_area ${locator} | |
115 | + click element ${locator} | |
116 | + | |
117 | +click visible element and wait until page contains element | |
118 | + [Arguments] ${locator} ${checker_element_locator} ${waiting_timeout}=30s ${waiting_error}=Another element was not shown after clicking on specific element | |
119 | + [Documentation] перевіряє видимість і клікає по елементу | |
120 | + | |
121 | + click visible element ${locator} | |
122 | + wait until page contains element ${checker_element_locator} ${waiting_timeout} ${waiting_error} | |
123 | + | |
124 | +click removing form item and wait success result | |
125 | + [Arguments] ${locator} | |
126 | + [Documentation] натискає кнопку видалення, очікує успішне повідомлення і закриває повідомлення | |
127 | + | |
128 | + click visible element ${locator} | |
129 | + wait until alert is visible | |
130 | + click visible element ${alert_confirm_btn_locator} | |
131 | + wait until page does not contain element ${alert_confirm_btn_locator} | |
132 | + | |
133 | +click removing form feature and wait success result | |
134 | + [Arguments] ${locator} | |
135 | + [Documentation] натискає кнопку видалення нецінового критерію, очікує успішне повідомлення і закриває повідомлення, а потім закриває вікно нецінового критерію | |
136 | + | |
137 | + js click element ${locator} | |
138 | + wait until alert is visible | |
139 | + click visible element ${alert_confirm_btn_locator} | |
140 | + wait until page does not contain element ${alert_confirm_btn_locator} | |
141 | + submit current visible popup | |
142 | + | |
143 | +input text to visible input | |
144 | + [Arguments] ${locator} ${text} | |
145 | + [Documentation] перевіряє чи елемент видимий у вікні браузера, після чого заповнює його | |
146 | + | |
147 | + __private__set_element_visible_in_browser_area ${locator} | |
148 | + input text ${locator} ${text} | |
149 | + | |
150 | +input text to visible input and press enter | |
151 | + [Arguments] ${locator} ${text} | |
152 | + [Documentation] перевіряє чи елемент видимий у вікні браузера, після чого заповнює його і імітує натиснення кнопки Enter | |
153 | + | |
154 | + input text to visible input ${locator} ${text} | |
155 | + press key ${locator} \\13 | |
156 | + | |
157 | +input text to exist visible input | |
158 | + [Arguments] ${locator} ${text} | |
159 | + [Documentation] перевіряє чи елемент існує і видимий у вікні браузера, після чого заповнює його | |
160 | + | |
161 | + ${input_exists} = get is element exist ${locator} | |
162 | + run keyword if ${input_exists} == ${True} input text to visible input ${locator} ${text} | |
163 | + ... ELSE __private__log input ${locator} does not exist | |
164 | + | |
165 | +input date to input | |
166 | + [Arguments] ${locator} ${isodate} ${format}=%d.%m.%Y | |
167 | + | |
168 | + ${date} = isodate format ${isodate} ${format} | |
169 | + input text to hidden input ${locator} ${date} | |
170 | + | |
171 | +input datetime to input | |
172 | + [Arguments] ${locator} ${isodate} ${format}=%d.%m.%Y %H:%M | |
173 | + | |
174 | + input date to input ${locator} ${isodate} ${format} | |
175 | + | |
176 | +input date to visible input | |
177 | + [Arguments] ${locator} ${isodate} ${format}=%d.%m.%Y | |
178 | + [Documentation] перевіряє чи елемент видимий у вікні браузера, після чого заповнює його відформатовоною датою | |
179 | + | |
180 | + __private__set_element_visible_in_browser_area ${locator} | |
181 | + input date to input ${locator} ${isodate} ${format} | |
182 | + | |
183 | +input datetime to visible input | |
184 | + [Arguments] ${locator} ${isodate} ${format}=%d.%m.%Y %H:%M | |
185 | + [Documentation] перевіряє чи елемент видимий у вікні браузера, після чого заповнює його відформатовоною датою | |
186 | + | |
187 | + input date to visible input ${locator} ${isodate} ${format} | |
188 | + | |
189 | +input datetime to exist visible input | |
190 | + [Arguments] ${locator} ${isodate} ${format}=%d.%m.%Y %H:%M | |
191 | + [Documentation] перевіряє чи елемент видимий у вікні браузера, після чого заповнює його відформатовоною датою | |
192 | + | |
193 | + ${input_exists} = get is element exist ${locator} | |
194 | + run keyword if ${input_exists} == ${True} input date to visible input ${locator} ${isodate} ${format} | |
195 | + ... ELSE __private__log input ${locator} does not exist | |
196 | + | |
197 | +input number to visible input | |
198 | + [Arguments] ${locator} ${number} | |
199 | + [Documentation] робить елемент видимим, число перетворює в строку і записує в поле | |
200 | + | |
201 | + ${number} = convert float to string ${number} | |
202 | + input text to visible input ${locator} ${number} | |
203 | + | |
204 | +input number3 to visible input | |
205 | + [Arguments] ${locator} ${number} | |
206 | + [Documentation] робить елемент видимим, число перетворює в строку і записує в поле | |
207 | + | |
208 | + ${number} = convert_float_to_string_3f ${number} | |
209 | + input text to visible input ${locator} ${number} | |
210 | + | |
211 | +input number to exist visible input | |
212 | + [Arguments] ${locator} ${text} | |
213 | + [Documentation] перевіряє чи елемент існує і видимий у вікні браузера, після чого заповнює його | |
214 | + | |
215 | + ${input_exists} = get is element exist ${locator} | |
216 | + run keyword if ${input_exists} == ${True} input number to visible input ${locator} ${text} | |
217 | + ... ELSE __private__log input ${locator} does not exist | |
218 | + | |
219 | +input month.year of date to visible input | |
220 | + [Arguments] ${locator} ${isodate} | |
221 | + [Documentation] робить елемент видимим, витягує місяць.рік і записує в поле | |
222 | + | |
223 | + ${value} = isodate format ${isodate} %m.%Y | |
224 | + input text to visible input ${locator} ${value} | |
225 | + | |
226 | +input to search form and wait results | |
227 | + [Arguments] ${query_input_locator} ${query} ${result_locator_tpl} | |
228 | + [Documentation] заповнює форму і очікує результат по шаблону селектора | |
229 | + | |
230 | + input text to visible input and press enter ${query_input_locator} ${query} | |
231 | + ${result_locator} = replace string ${result_locator_tpl} %query% ${query} | |
232 | + wait until page contains search ${result_locator} | |
233 | +# wait until page contains element with reloading ${result_locator} | |
234 | + | |
235 | +select from visible list by value | |
236 | + [Arguments] ${locator} ${value} | |
237 | + [Documentation] робить елемент видимим, після чого заповнює його | |
238 | + | |
239 | + __private__set_element_visible_in_browser_area ${locator} | |
240 | + select from list by value ${locator} ${value} | |
241 | + trigger input change event ${locator} | |
242 | + | |
243 | +select from visible list by label | |
244 | + [Arguments] ${locator} ${label} | |
245 | + [Documentation] робить елемент видимим, після чого заповнює його | |
246 | + | |
247 | + __private__set_element_visible_in_browser_area ${locator} | |
248 | + select from hidden list by label ${locator} ${label} | |
249 | + trigger input change event ${locator} | |
250 | + | |
251 | +select from visible list by year of date | |
252 | + [Arguments] ${locator} ${isodate} | |
253 | + [Documentation] робить елемент видимим, витягує рік і обирає в списку | |
254 | + | |
255 | + ${value} = isodate format ${isodate} %Y | |
256 | + select from visible list by value ${locator} ${value} | |
257 | + | |
258 | +select classification by code attributes | |
259 | + [Arguments] ${btn_locator} ${code_attributes} | |
260 | + [Documentation] натискає кнопку відкриття попапу класифікатора і чекає поки він відмалюється, шукає відповідний код і закриває попап | |
261 | + | |
262 | + ${code_attributes_array} = create list ${code_attributes} | |
263 | + select classification by array of code attributes ${btn_locator} ${code_attributes_array} | |
264 | + | |
265 | +select classification by array of code attributes | |
266 | + [Arguments] ${btn_locator} ${code_attributes_array} ${include_schemes}=${None} ${exclude_schemes}=${None} | |
267 | + [Documentation] натискає кнопку відкриття попапу класифікатора і чекає поки він відмалюється, шукає відповідні коди і закриває попап | |
268 | + | |
269 | + ${include_schemes_is_none}= get variable is none ${include_schemes} | |
270 | + ${exclude_schemes_is_none}= get variable is none ${exclude_schemes} | |
271 | + | |
272 | + open popup by btn locator ${btn_locator} ${classification_popup_opened_content_locator} | |
273 | + Capture Page Screenshot | |
274 | + :FOR ${code_attributes} IN @{code_attributes_array} | |
275 | + \ ${disabled} = set variable if ${include_schemes_is_none} == ${False} and '${code_attributes['scheme']}' not in ${include_schemes} ${True} ${False} | |
276 | + \ Capture Page Screenshot | |
277 | + \ ${disabled} = set variable if ${exclude_schemes_is_none} == ${False} and '${code_attributes['scheme']}' in ${exclude_schemes} ${True} ${disabled} | |
278 | + \ Capture Page Screenshot | |
279 | + \ run keyword if ${disabled} == ${False} __private__select_classification_code_in_opened_popup ${code_attributes['id']} ${code_attributes['scheme']} | |
280 | + \ Capture Page Screenshot | |
281 | + Capture Page Screenshot | |
282 | + submit current visible popup | |
283 | + | |
284 | +open site page and wait content element | |
285 | + [Arguments] ${url} ${waiting_timeout}=5s ${waiting_error}=Opening page fails | |
286 | + [Documentation] переходить по посиланню і чекає контенту сторінки | |
287 | + | |
288 | + go to ${url} | |
289 | + wait until page contains element ${page_content_locator} ${waiting_timeout} ${waiting_error} | |
290 | + | |
291 | +open page and wait element by locator | |
292 | + [Arguments] ${url} ${waiting_element_locator} ${waiting_timeout}=5s ${waiting_error}=Opened page does not have specified element locator | |
293 | + [Documentation] переходить по посиланню і чекає поки елемент не буде знайдений на сторінці | |
294 | + | |
295 | + go to ${url} | |
296 | + wait until page contains element ${waiting_element_locator} ${waiting_timeout} ${waiting_error} | |
297 | + | |
298 | +open popup by btn locator | |
299 | + [Arguments] ${btn_locator} ${popup_locator}=${None} | |
300 | + [Documentation] натискає кнопку відкриття попапу і чекає поки він відмалюється | |
301 | + | |
302 | + click visible element ${btn_locator} | |
303 | + ${result} = run keyword and return status wait until popup is visible ${popup_locator} | |
304 | + run keyword if ${result} == ${False} js click element ${btn_locator} | |
305 | + run keyword if ${result} == ${False} wait until popup is visible ${popup_locator} | |
306 | + | |
307 | +submit current visible popup | |
308 | + [Documentation] натискає кнопку сабміту в поточному попапі і чекає поки він закриється | |
309 | + | |
310 | + ${popup_last_id} = __private__get_element_attribute ${popup_opened_last_locator} id | |
311 | + click visible element ${popup_opened_last_submit_btn_locator} | |
312 | + sleep ${popup_transaction_time} | |
313 | + ${popup_last_locator} = set variable id=${popup_last_id} | |
314 | + ${popup_exists} = get is element exist ${popup_last_locator} | |
315 | + return from keyword if ${popup_exists} == ${False} | |
316 | + wait until page does not contain element ${popup_last_locator} 30s Current popup was not hidden | |
317 | + | |
318 | +submit form and check result | |
319 | + [Arguments] ${submit_btn_locator} ${wait_msg}=${None} ${wait_element_locator}=${None} ${sign_is}=${None} | |
320 | + [Documentation] сабмітить форму і чекає повідомлення (якщо задано) + елемент (якщо задано) | |
321 | + | |
322 | + click visible element ${submit_btn_locator} | |
323 | + run keyword and ignore error run keyword if condition is not none ${wait_msg} wait until element is visible ${tender_cpv_form_submit_success_msg} 5 | |
324 | +# run keyword and ignore error Wait Until Page Contains ${tender_cpv_form_submit_success_msg} 60 | |
325 | + Capture Page Screenshot | |
326 | + run keyword and ignore error execute javascript ${tender_cpv_js_submit_btn_locator} | |
327 | + Capture Page Screenshot | |
328 | + run keyword and ignore error run keyword if '${mode}' in 'reporting' close sync alert ${tender_form_submit_reporting_success_msg} | |
329 | + run keyword and ignore error run keyword if condition is not none ${wait_msg} Wait Until Page Contains ${wait_msg} 60 | |
330 | + run keyword and ignore error run keyword if condition is not none ${wait_msg} wait until alert is visible ${wait_msg} | |
331 | + run keyword and ignore error run keyword if condition is not none ${wait_msg} close current visible alert | |
332 | + | |
333 | +#cat проба | |
334 | + run keyword and ignore error run keyword if not ${sign_is} Load Sign | |
335 | + run keyword and ignore error close current visible alert | |
336 | + run keyword and ignore error run keyword if condition is not none ${wait_element_locator} wait until element is visible ${wait_element_locator} 60 | |
337 | + run keyword and ignore error run keyword if condition is not none ${wait_element_locator} wait until page contains element ${wait_element_locator} 60s Element was not shown after form submitting | |
338 | + | |
339 | +close sync alert | |
340 | + [Arguments] ${wait_msg}=${None} | |
341 | + [Documentation] чекає поки попап не стане видимим на сторінці | |
342 | + | |
343 | + ${status}= run keyword if '${mode}' in 'openeu open_competitive_dialogue openua_defense open_esco open_framework' Run Keyword And Return Status Page Should Contain ${wait_msg} | |
344 | + run keyword and ignore error run keyword if ${status} and '${mode}' in 'openeu open_competitive_dialogue openua_defense open_esco open_framework' Wait Until Page Contains ${wait_msg} 60 | |
345 | + run keyword and ignore error run keyword if ${status} and '${mode}' in 'openeu open_competitive_dialogue openua_defense open_esco open_framework' wait until alert is visible ${wait_msg} | |
346 | + run keyword and ignore error run keyword if ${status} and '${mode}' in 'openeu open_competitive_dialogue openua_defense open_esco open_framework' close current visible alert | |
347 | + | |
348 | + | |
349 | +wait until popup is visible | |
350 | + [Arguments] ${popup_locator}=${None} ${waiting_timeout}=30s ${waiting_error}=Opened popup still not visible | |
351 | + [Documentation] чекає поки попап не стане видимим на сторінці | |
352 | + | |
353 | + ${popup_locator_is_none} = get variable is none ${popup_locator} | |
354 | + ${popup_locator} = set variable if ${popup_locator_is_none} == ${False} ${popup_locator} ${popup_opened_content_locator} | |
355 | + ${status} = run keyword and return status wait until element is visible ${popup_locator} ${waiting_timeout} ${waiting_error} | |
356 | + # trying to prevent "StaleElementReferenceException: Message: stale element reference: element is not attached to the page document" error | |
357 | + run keyword if ${status} == ${False} sleep 1 | |
358 | + run keyword if ${status} == ${False} wait until element is visible ${popup_locator} 1 ${waiting_error} | |
359 | + | |
360 | +wait until alert is visible | |
361 | + [Arguments] ${message}=${None} | |
362 | + [Documentation] чекає поки не з'явиться алерт | |
363 | + | |
364 | + ${message_is_none} = get variable is none ${message} | |
365 | + ${message} = convert to string ${message} | |
366 | + ${alert_message_locator} = replace string ${alert_message_contains_text_locator_tpl} %text% ${message} | |
367 | + run keyword if ${message_is_none} == ${True} wait until page contains element ${alert_opened_locator} 60s Alert was not shown | |
368 | + run keyword if ${message_is_none} == ${False} wait until page contains element ${alert_message_locator} 60s Alert was not shown | |
369 | + | |
370 | + # wait for ending animation | |
371 | + sleep 500ms | |
372 | + | |
373 | +close current visible alert | |
374 | + [Documentation] закриває поточний alert | |
375 | + | |
376 | + click visible element ${alert_opened_close_btn_locator} | |
377 | + | |
378 | + # wait for ending animation | |
379 | + sleep 500ms | |
380 | + | |
381 | +wait until page contains search | |
382 | + [Arguments] ${locator} ${retry}=5m ${retry_interval}=2s | |
383 | + [Documentation] чекає поки елемент не з'явиться на сторінці з перезапуском пошуку | |
384 | + | |
385 | + ${result} = get is element exist ${locator} | |
386 | + capture page screenshot | |
387 | + run keyword if ${result} == ${False} wait until keyword succeeds ${retry} ${retry_interval} reload page and fail if element does not exist on search ${locator} | |
388 | + | |
389 | +wait until page contains element with reloading | |
390 | + [Arguments] ${locator} ${retry}=5m ${retry_interval}=2s | |
391 | + [Documentation] чекає поки елемент не з'явиться на сторінці з перезавантаженням сторінки | |
392 | + | |
393 | + ${result} = get is element exist ${locator} | |
394 | + run keyword if ${result} == ${False} wait until keyword succeeds ${retry} ${retry_interval} reload page and fail if element does not exist ${locator} | |
395 | + | |
396 | +wait until page does not contain element with reloading | |
397 | + [Arguments] ${locator} ${retry}=5m ${retry_interval}=2s | |
398 | + [Documentation] чекає поки елемент не пропаде зі сторінки з перезавантаженням сторінки | |
399 | + | |
400 | + ${result} = get is element exist ${locator} | |
401 | + run keyword if ${result} == ${True} wait until keyword succeeds ${retry} ${retry_interval} reload page and fail if element exists ${locator} | |
402 | + capture page screenshot | |
403 | + | |
404 | +wait until tab content is visible | |
405 | + [Arguments] ${tab_link} ${waiting_timeout}=30s ${waiting_error}=Opened tab still not visible | |
406 | + [Documentation] чекає поки контент вказаного табу не буде видимим | |
407 | + | |
408 | + ${tab_link_href} = __private__get_element_attribute ${tab_link} href | |
409 | + ${tab_content_locator} = set variable jquery=${tab_link_href} | |
410 | + wait until element is visible ${tab_content_locator} ${waiting_timeout} ${waiting_error} | |
411 | + | |
412 | +reload page and fail if element exists | |
413 | + [Arguments] ${locator} | |
414 | + [Documentation] перезавантажує сторінку і фейлить тест якщо елемент присутній | |
415 | + | |
416 | + capture page screenshot | |
417 | + reload page | |
418 | + capture page screenshot | |
419 | + ${exists} = get is element exist ${locator} | |
420 | + run keyword if ${exists} == ${True} fail | |
421 | + | |
422 | +reload page and fail if element does not exist | |
423 | + [Arguments] ${locator} | |
424 | + [Documentation] перезавантажує сторінку і фейлить тест якщо елемент відсутній | |
425 | + | |
426 | + reload page | |
427 | + capture page screenshot | |
428 | + ${exists} = get is element exist ${locator} | |
429 | + run keyword if ${exists} == ${False} fail | |
430 | + | |
431 | +reload page and fail if element does not exist on search | |
432 | + [Arguments] ${locator} | |
433 | + [Documentation] перезавантажує сторінку і фейлить тест якщо елемент відсутній в пошуку | |
434 | + | |
435 | + click visible element ${tender_form_search_btn_locator} | |
436 | + ${exists} = get is element exist ${locator} | |
437 | + run keyword if ${exists} == ${False} fail | |
438 | + | |
439 | +get is 404 page | |
440 | + [Documentation] перевіряє чи поточна сторінка з 404 помилкою | |
441 | + | |
442 | + ${exists} = get is element exist ${error_page_404_checker_element_locator} | |
443 | + [Return] ${exists} | |
444 | + | |
445 | +wait until 404 page disappears | |
446 | + [Arguments] ${retry}=5m ${retry_interval}=2s | |
447 | + [Documentation] оновлює сторінку і чекає поки не пропаде 404 помилка | |
448 | + | |
449 | + ${result} = get is 404 page | |
450 | + run keyword if ${result} == ${True} wait until keyword succeeds ${retry} ${retry_interval} reload page and fail if element exists ${error_page_404_checker_element_locator} | |
451 | + | |
452 | +######################################################################################################################## | |
453 | +################################################### PRIVATE KEYWORDS ################################################### | |
454 | +######################################################################################################################## | |
455 | + | |
456 | +__private__handle_keyword_failure | |
457 | + [Documentation] обробка падіння тесту, збір можливої інформації для аналізу проблеми | |
458 | + | |
459 | + capture page screenshot | |
460 | + ${form_errors} = __private__get_all_form_errors | |
461 | + log dictionary ${form_errors} | |
462 | + | |
463 | +__private__get_all_form_errors | |
464 | + [Documentation] збирає всі помилки форм на сторінці | |
465 | + | |
466 | + ${errors} = execute javascript | |
467 | + ... var errors = {}; | |
468 | + ... $('.has-error .help-block-error').each(function () { | |
469 | + ... var cssClass = $(this).attr('class'), text = $(this).text(); | |
470 | + ... cssClass = cssClass.replace("help-block-error", ""); | |
471 | + ... cssClass = cssClass.replace("help-block", ""); | |
472 | + ... errors[cssClass] = text; | |
473 | + ... }); | |
474 | + ... return errors; | |
475 | + [Return] ${errors} | |
476 | + | |
477 | +__private__log | |
478 | + [Arguments] ${msg} | |
479 | + [Documentation] пише в логи | |
480 | + | |
481 | + log ${msg} | |
482 | + log to console ${msg} | |
483 | + | |
484 | +__private__get_element_attribute | |
485 | + [Arguments] ${locator} ${attribute} | |
486 | + [Documentation] повертає значення атрибуту для вказаного елементу | |
487 | + | |
488 | + ${value} = get element attribute ${locator}@${attribute} | |
489 | + [Return] ${value} | |
490 | + | |
491 | +__private__set_element_visible_in_browser_area | |
492 | + [Arguments] ${locator} | |
493 | + [Documentation] робить елемент видимим у вікні браузера | |
494 | + | |
495 | + set element scroll into view ${locator} | |
496 | + | |
497 | +__private__get_site_language_code | |
498 | + [Documentation] повертає код поточної мови сайта | |
499 | + | |
500 | + ${current_language_code} = __private__get_element_attribute ${language_selector_active_element_locator} ${language_selector_active_element_code_attribute_name} | |
501 | + [Return] ${current_language_code} | |
502 | + | |
503 | +__private__check_site_language_code | |
504 | + [Arguments] ${language_code} | |
505 | + [Documentation] повертає чи поточна мова сайту відповідає вказаній | |
506 | + | |
507 | + ${current_language_code} = __private__get_site_language_code | |
508 | + ${is_equal} = set variable if "${current_language_code}" == "${language_code}" ${True} ${False} | |
509 | + [Return] ${is_equal} | |
510 | + | |
511 | +__private__open_site_language_dropdown_and_select_language_by_code | |
512 | + [Arguments] ${language_code} | |
513 | + [Documentation] відкриває випадаючий список мов, обрає потрібну, чекає перезавантаження сторінки | |
514 | + | |
515 | + click visible element ${language_selector_open_element_locator} | |
516 | + ${language_selector_list_element_locator} = replace string ${language_selector_list_element_locator_tpl} %code% ${language_code} | |
517 | + click element ${language_selector_list_element_locator} | |
518 | + ${language_selector_active_element_locator} = replace string ${language_selector_active_element_by_code_locator_tpl} %code% ${language_code} | |
519 | + wait until page contains element ${language_selector_active_element_locator} 30s Language have not changed | |
520 | + | |
521 | +__private__select_classification_code_in_opened_popup | |
522 | + [Arguments] ${code} ${scheme}=${None} | |
523 | + [Documentation] в поточний попап з класифікатором перемикає схему, шукає заданий код в полі пошуку і обирає його | |
524 | + | |
525 | + # check scheme | |
526 | + ${scheme_is_none} = get variable is none ${scheme} | |
527 | + ${scheme} = convert to string ${scheme} | |
528 | + run keyword if ${scheme_is_none} == ${False} and '${scheme}' not in ${site_allowed_schemes} __private__log Scheme "${scheme}" is needed to implement. | |
529 | + return from keyword if ${scheme_is_none} == ${False} and '${scheme}' not in ${site_allowed_schemes} | |
530 | + ${scheme_tab_locator} = replace string ${classification_popup_scheme_tab_locator_tpl} %scheme% ${scheme} | |
531 | + ${scheme_tab_exists} = get is element exist ${scheme_tab_locator} | |
532 | + run keyword if ${scheme_tab_exists} == ${True} click visible element ${scheme_tab_locator} | |
533 | + run keyword if ${scheme_tab_exists} == ${True} wait until tab content is visible ${scheme_tab_locator} | |
534 | + ... ELSE __private__log Classification scheme tab ${scheme} does not exist | |
535 | + # seraching code | |
536 | + input text to visible input and press enter ${classification_popup_search_input_locator} ${code} | |
537 | + ${code} = convert to string ${code} | |
538 | + ${code_item_locator} = replace string ${classification_popup_serach_item_locator_tpl} %code% ${code} | |
539 | + wait until page contains element ${code_item_locator} 90s Specified classification code was not found | |
540 | + click visible element ${code_item_locator} | |
541 | + | |
542 | +Load Sign | |
543 | + run keyword and ignore error click visible element ${plan_form_ecp_btn_locator} | |
544 | + ${loadingfakeKey} = Run keyword And Return Status Wait Until Page Contains Це фейкове накладання ЕЦП 30 | |
545 | + run keyword and ignore error Run Keyword If ${loadingfakeKey} == True submit form and check result id=SignDataButton ${qualification_ecp_form_submit_success_msg} | |
546 | + ${loadingKey} = Run keyword And Return Status Wait Until Page Contains Серійний номер 30 | |
547 | + Run Keyword If ${loadingfakeKey} == True Fail Далі не ходити | |
548 | + Run Keyword If ${loadingKey} == False Load Sign Data | |
549 | + Wait Until Page Contains Серійний номер 60 | |
550 | + submit form and check result id=SignDataButton ${qualification_ecp_form_submit_success_msg} | |
551 | + | |
552 | +Load Sign Data | |
553 | + Wait Until Page Contains Element id=CAsServersSelect 60 | |
554 | + Select From List By Label id=CAsServersSelect Тестовий ЦСК АТ "ІІТ" | |
555 | + Wait Until Page Contains Element id=PKeyFileName 60 | |
556 | + Choose File id=PKeyFileInput ${CURDIR}/Key-6.dat | |
557 | + Wait Until Page Contains Element id=PKeyPassword 60 | |
558 | + Input Text id=PKeyPassword 12345677 | |
559 | + Wait Until Page Contains Element id=PKeyReadButton 60 | |
560 | + Click Element id=PKeyReadButton | |
561 | + | |
562 | +GetDictionaryKeyExist | |
563 | + [Arguments] ${Dictionary Name} ${Key} | |
564 | + Run Keyword And Return Status Dictionary Should Contain Key ${Dictionary Name} ${Key} | |
565 | + | |
566 | +GetValueFromDictionaryByKey [Arguments] ${Dictionary Name} ${Key} | |
567 | + ${KeyIsPresent}= Run Keyword And Return Status Dictionary Should Contain Key ${Dictionary Name} ${Key} | |
568 | + ${Value}= Run Keyword If ${KeyIsPresent} Get From Dictionary ${Dictionary Name} ${Key} | |
569 | + Return From Keyword ${Value} | |
570 | + | ... | ... |
Please
register
or
login
to post a comment