├── .editorconfig
├── .gitignore
├── CODE_OF_CONDUCT.md
├── Jenkinsfile
├── LICENSE
├── README.md
├── bin
└── release
├── build-logic
├── build.gradle.kts
├── settings.gradle.kts
└── src
│ └── main
│ └── kotlin
│ └── kotlin-library-convention.gradle.kts
├── build.gradle.kts
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── renovate.json
├── settings.gradle.kts
├── src
├── main
│ ├── kotlin
│ │ └── com
│ │ │ └── iodesystems
│ │ │ └── selenium
│ │ │ ├── el
│ │ │ ├── El.kt
│ │ │ ├── IEl.kt
│ │ │ └── IElExtensions.kt
│ │ │ ├── exceptions
│ │ │ ├── RetryException.kt
│ │ │ └── SearchNotFoundException.kt
│ │ │ └── jQuery.kt
│ └── resources
│ │ ├── jquery-3.7.1.slim.min.js
│ │ └── selenium-jquery-helpers.js
└── test
│ └── kotlin
│ └── com
│ └── iodesystems
│ └── selenium
│ └── jQueryTest.kt
└── versions.properties
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_size = 2
7 | indent_style = space
8 | insert_final_newline = true
9 | max_line_length = 120
10 | tab_width = 2
11 | trim_trailing_whitespace = true
12 | ij_continuation_indent_size = 8
13 | ij_formatter_off_tag = @formatter:off
14 | ij_formatter_on_tag = @formatter:on
15 | ij_formatter_tags_enabled = true
16 | ij_smart_tabs = false
17 | ij_visual_guides = 80
18 | ij_wrap_on_typing = false
19 |
20 | [*.css]
21 | ij_visual_guides = none
22 | ij_css_align_closing_brace_with_properties = false
23 | ij_css_blank_lines_around_nested_selector = 1
24 | ij_css_blank_lines_between_blocks = 1
25 | ij_css_block_comment_add_space = false
26 | ij_css_brace_placement = end_of_line
27 | ij_css_enforce_quotes_on_format = false
28 | ij_css_hex_color_long_format = false
29 | ij_css_hex_color_lower_case = false
30 | ij_css_hex_color_short_format = false
31 | ij_css_hex_color_upper_case = false
32 | ij_css_keep_blank_lines_in_code = 2
33 | ij_css_keep_indents_on_empty_lines = false
34 | ij_css_keep_single_line_blocks = false
35 | ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow
36 | ij_css_space_after_colon = true
37 | ij_css_space_before_opening_brace = true
38 | ij_css_use_double_quotes = true
39 | ij_css_value_alignment = do_not_align
40 |
41 | [*.csv]
42 | indent_style = tab
43 | ij_visual_guides = none
44 | ij_csv_keep_indents_on_empty_lines = true
45 | ij_csv_wrap_long_lines = false
46 |
47 | [.editorconfig]
48 | ij_visual_guides = none
49 | ij_editorconfig_align_group_field_declarations = false
50 | ij_editorconfig_space_after_colon = false
51 | ij_editorconfig_space_after_comma = true
52 | ij_editorconfig_space_before_colon = false
53 | ij_editorconfig_space_before_comma = false
54 | ij_editorconfig_spaces_around_assignment_operators = true
55 |
56 | [{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,phpunit.xml.dist}]
57 | indent_size = 2
58 | tab_width = 2
59 | ij_continuation_indent_size = 4
60 | ij_visual_guides = none
61 | ij_xml_align_attributes = true
62 | ij_xml_align_text = false
63 | ij_xml_attribute_wrap = normal
64 | ij_xml_block_comment_add_space = false
65 | ij_xml_block_comment_at_first_column = true
66 | ij_xml_keep_blank_lines = 2
67 | ij_xml_keep_indents_on_empty_lines = false
68 | ij_xml_keep_line_breaks = true
69 | ij_xml_keep_line_breaks_in_text = true
70 | ij_xml_keep_whitespaces = false
71 | ij_xml_keep_whitespaces_around_cdata = preserve
72 | ij_xml_keep_whitespaces_inside_cdata = false
73 | ij_xml_line_comment_at_first_column = true
74 | ij_xml_space_after_tag_name = false
75 | ij_xml_space_around_equals_in_attribute = false
76 | ij_xml_space_inside_empty_tag = false
77 | ij_xml_text_wrap = normal
78 |
79 | [{*.ats,*.cts,*.mts,*.ts}]
80 | indent_size = 2
81 | ij_continuation_indent_size = 2
82 | ij_visual_guides = none
83 | ij_typescript_align_imports = false
84 | ij_typescript_align_multiline_array_initializer_expression = false
85 | ij_typescript_align_multiline_binary_operation = false
86 | ij_typescript_align_multiline_chained_methods = false
87 | ij_typescript_align_multiline_extends_list = false
88 | ij_typescript_align_multiline_for = false
89 | ij_typescript_align_multiline_parameters = false
90 | ij_typescript_align_multiline_parameters_in_calls = false
91 | ij_typescript_align_multiline_ternary_operation = false
92 | ij_typescript_align_object_properties = 0
93 | ij_typescript_align_union_types = false
94 | ij_typescript_align_var_statements = 0
95 | ij_typescript_array_initializer_new_line_after_left_brace = false
96 | ij_typescript_array_initializer_right_brace_on_new_line = false
97 | ij_typescript_array_initializer_wrap = off
98 | ij_typescript_assignment_wrap = off
99 | ij_typescript_binary_operation_sign_on_next_line = false
100 | ij_typescript_binary_operation_wrap = off
101 | ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/**
102 | ij_typescript_blank_lines_after_imports = 1
103 | ij_typescript_blank_lines_around_class = 1
104 | ij_typescript_blank_lines_around_field = 0
105 | ij_typescript_blank_lines_around_field_in_interface = 0
106 | ij_typescript_blank_lines_around_function = 1
107 | ij_typescript_blank_lines_around_method = 1
108 | ij_typescript_blank_lines_around_method_in_interface = 1
109 | ij_typescript_block_brace_style = end_of_line
110 | ij_typescript_block_comment_add_space = false
111 | ij_typescript_block_comment_at_first_column = true
112 | ij_typescript_call_parameters_new_line_after_left_paren = false
113 | ij_typescript_call_parameters_right_paren_on_new_line = false
114 | ij_typescript_call_parameters_wrap = off
115 | ij_typescript_catch_on_new_line = false
116 | ij_typescript_chained_call_dot_on_new_line = true
117 | ij_typescript_class_brace_style = end_of_line
118 | ij_typescript_comma_on_new_line = false
119 | ij_typescript_do_while_brace_force = never
120 | ij_typescript_else_on_new_line = false
121 | ij_typescript_enforce_trailing_comma = keep
122 | ij_typescript_enum_constants_wrap = on_every_item
123 | ij_typescript_extends_keyword_wrap = off
124 | ij_typescript_extends_list_wrap = off
125 | ij_typescript_field_prefix = _
126 | ij_typescript_file_name_style = relaxed
127 | ij_typescript_finally_on_new_line = false
128 | ij_typescript_for_brace_force = never
129 | ij_typescript_for_statement_new_line_after_left_paren = false
130 | ij_typescript_for_statement_right_paren_on_new_line = false
131 | ij_typescript_for_statement_wrap = off
132 | ij_typescript_force_quote_style = true
133 | ij_typescript_force_semicolon_style = true
134 | ij_typescript_function_expression_brace_style = end_of_line
135 | ij_typescript_if_brace_force = never
136 | ij_typescript_import_merge_members = global
137 | ij_typescript_import_prefer_absolute_path = global
138 | ij_typescript_import_sort_members = true
139 | ij_typescript_import_sort_module_name = false
140 | ij_typescript_import_use_node_resolution = true
141 | ij_typescript_imports_wrap = on_every_item
142 | ij_typescript_indent_case_from_switch = false
143 | ij_typescript_indent_chained_calls = true
144 | ij_typescript_indent_package_children = 0
145 | ij_typescript_jsdoc_include_types = false
146 | ij_typescript_jsx_attribute_value = braces
147 | ij_typescript_keep_blank_lines_in_code = 2
148 | ij_typescript_keep_first_column_comment = true
149 | ij_typescript_keep_indents_on_empty_lines = false
150 | ij_typescript_keep_line_breaks = true
151 | ij_typescript_keep_simple_blocks_in_one_line = false
152 | ij_typescript_keep_simple_methods_in_one_line = false
153 | ij_typescript_line_comment_add_space = true
154 | ij_typescript_line_comment_at_first_column = false
155 | ij_typescript_method_brace_style = end_of_line
156 | ij_typescript_method_call_chain_wrap = off
157 | ij_typescript_method_parameters_new_line_after_left_paren = false
158 | ij_typescript_method_parameters_right_paren_on_new_line = false
159 | ij_typescript_method_parameters_wrap = off
160 | ij_typescript_object_literal_wrap = on_every_item
161 | ij_typescript_object_types_wrap = on_every_item
162 | ij_typescript_parentheses_expression_new_line_after_left_paren = false
163 | ij_typescript_parentheses_expression_right_paren_on_new_line = false
164 | ij_typescript_place_assignment_sign_on_next_line = false
165 | ij_typescript_prefer_as_type_cast = false
166 | ij_typescript_prefer_explicit_types_function_expression_returns = false
167 | ij_typescript_prefer_explicit_types_function_returns = false
168 | ij_typescript_prefer_explicit_types_vars_fields = false
169 | ij_typescript_prefer_parameters_wrap = false
170 | ij_typescript_reformat_c_style_comments = false
171 | ij_typescript_space_after_colon = true
172 | ij_typescript_space_after_comma = true
173 | ij_typescript_space_after_dots_in_rest_parameter = false
174 | ij_typescript_space_after_generator_mult = true
175 | ij_typescript_space_after_property_colon = true
176 | ij_typescript_space_after_quest = true
177 | ij_typescript_space_after_type_colon = true
178 | ij_typescript_space_after_unary_not = false
179 | ij_typescript_space_before_async_arrow_lparen = true
180 | ij_typescript_space_before_catch_keyword = true
181 | ij_typescript_space_before_catch_left_brace = true
182 | ij_typescript_space_before_catch_parentheses = true
183 | ij_typescript_space_before_class_lbrace = true
184 | ij_typescript_space_before_class_left_brace = true
185 | ij_typescript_space_before_colon = true
186 | ij_typescript_space_before_comma = false
187 | ij_typescript_space_before_do_left_brace = true
188 | ij_typescript_space_before_else_keyword = true
189 | ij_typescript_space_before_else_left_brace = true
190 | ij_typescript_space_before_finally_keyword = true
191 | ij_typescript_space_before_finally_left_brace = true
192 | ij_typescript_space_before_for_left_brace = true
193 | ij_typescript_space_before_for_parentheses = true
194 | ij_typescript_space_before_for_semicolon = false
195 | ij_typescript_space_before_function_left_parenth = true
196 | ij_typescript_space_before_generator_mult = false
197 | ij_typescript_space_before_if_left_brace = true
198 | ij_typescript_space_before_if_parentheses = true
199 | ij_typescript_space_before_method_call_parentheses = false
200 | ij_typescript_space_before_method_left_brace = true
201 | ij_typescript_space_before_method_parentheses = false
202 | ij_typescript_space_before_property_colon = false
203 | ij_typescript_space_before_quest = true
204 | ij_typescript_space_before_switch_left_brace = true
205 | ij_typescript_space_before_switch_parentheses = true
206 | ij_typescript_space_before_try_left_brace = true
207 | ij_typescript_space_before_type_colon = false
208 | ij_typescript_space_before_unary_not = false
209 | ij_typescript_space_before_while_keyword = true
210 | ij_typescript_space_before_while_left_brace = true
211 | ij_typescript_space_before_while_parentheses = true
212 | ij_typescript_spaces_around_additive_operators = true
213 | ij_typescript_spaces_around_arrow_function_operator = true
214 | ij_typescript_spaces_around_assignment_operators = true
215 | ij_typescript_spaces_around_bitwise_operators = true
216 | ij_typescript_spaces_around_equality_operators = true
217 | ij_typescript_spaces_around_logical_operators = true
218 | ij_typescript_spaces_around_multiplicative_operators = true
219 | ij_typescript_spaces_around_relational_operators = true
220 | ij_typescript_spaces_around_shift_operators = true
221 | ij_typescript_spaces_around_unary_operator = false
222 | ij_typescript_spaces_within_array_initializer_brackets = false
223 | ij_typescript_spaces_within_brackets = false
224 | ij_typescript_spaces_within_catch_parentheses = false
225 | ij_typescript_spaces_within_for_parentheses = false
226 | ij_typescript_spaces_within_if_parentheses = false
227 | ij_typescript_spaces_within_imports = false
228 | ij_typescript_spaces_within_interpolation_expressions = false
229 | ij_typescript_spaces_within_method_call_parentheses = false
230 | ij_typescript_spaces_within_method_parentheses = false
231 | ij_typescript_spaces_within_object_literal_braces = false
232 | ij_typescript_spaces_within_object_type_braces = true
233 | ij_typescript_spaces_within_parentheses = false
234 | ij_typescript_spaces_within_switch_parentheses = false
235 | ij_typescript_spaces_within_type_assertion = false
236 | ij_typescript_spaces_within_union_types = true
237 | ij_typescript_spaces_within_while_parentheses = false
238 | ij_typescript_special_else_if_treatment = true
239 | ij_typescript_ternary_operation_signs_on_next_line = false
240 | ij_typescript_ternary_operation_wrap = off
241 | ij_typescript_union_types_wrap = on_every_item
242 | ij_typescript_use_chained_calls_group_indents = false
243 | ij_typescript_use_double_quotes = true
244 | ij_typescript_use_explicit_js_extension = auto
245 | ij_typescript_use_path_mapping = always
246 | ij_typescript_use_public_modifier = false
247 | ij_typescript_use_semicolon_after_statement = false
248 | ij_typescript_var_declaration_wrap = normal
249 | ij_typescript_while_brace_force = never
250 | ij_typescript_while_on_new_line = false
251 | ij_typescript_wrap_comments = false
252 |
253 | [{*.cjs,*.js}]
254 | indent_size = 2
255 | ij_continuation_indent_size = 2
256 | ij_visual_guides = none
257 | ij_javascript_align_imports = false
258 | ij_javascript_align_multiline_array_initializer_expression = false
259 | ij_javascript_align_multiline_binary_operation = false
260 | ij_javascript_align_multiline_chained_methods = false
261 | ij_javascript_align_multiline_extends_list = false
262 | ij_javascript_align_multiline_for = false
263 | ij_javascript_align_multiline_parameters = false
264 | ij_javascript_align_multiline_parameters_in_calls = false
265 | ij_javascript_align_multiline_ternary_operation = false
266 | ij_javascript_align_object_properties = 0
267 | ij_javascript_align_union_types = false
268 | ij_javascript_align_var_statements = 0
269 | ij_javascript_array_initializer_new_line_after_left_brace = false
270 | ij_javascript_array_initializer_right_brace_on_new_line = false
271 | ij_javascript_array_initializer_wrap = off
272 | ij_javascript_assignment_wrap = off
273 | ij_javascript_binary_operation_sign_on_next_line = false
274 | ij_javascript_binary_operation_wrap = off
275 | ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/**
276 | ij_javascript_blank_lines_after_imports = 1
277 | ij_javascript_blank_lines_around_class = 1
278 | ij_javascript_blank_lines_around_field = 0
279 | ij_javascript_blank_lines_around_function = 1
280 | ij_javascript_blank_lines_around_method = 1
281 | ij_javascript_block_brace_style = end_of_line
282 | ij_javascript_block_comment_add_space = false
283 | ij_javascript_block_comment_at_first_column = true
284 | ij_javascript_call_parameters_new_line_after_left_paren = false
285 | ij_javascript_call_parameters_right_paren_on_new_line = false
286 | ij_javascript_call_parameters_wrap = off
287 | ij_javascript_catch_on_new_line = false
288 | ij_javascript_chained_call_dot_on_new_line = true
289 | ij_javascript_class_brace_style = end_of_line
290 | ij_javascript_comma_on_new_line = false
291 | ij_javascript_do_while_brace_force = never
292 | ij_javascript_else_on_new_line = false
293 | ij_javascript_enforce_trailing_comma = keep
294 | ij_javascript_extends_keyword_wrap = off
295 | ij_javascript_extends_list_wrap = off
296 | ij_javascript_field_prefix = _
297 | ij_javascript_file_name_style = relaxed
298 | ij_javascript_finally_on_new_line = false
299 | ij_javascript_for_brace_force = never
300 | ij_javascript_for_statement_new_line_after_left_paren = false
301 | ij_javascript_for_statement_right_paren_on_new_line = false
302 | ij_javascript_for_statement_wrap = off
303 | ij_javascript_force_quote_style = true
304 | ij_javascript_force_semicolon_style = true
305 | ij_javascript_function_expression_brace_style = end_of_line
306 | ij_javascript_if_brace_force = never
307 | ij_javascript_import_merge_members = global
308 | ij_javascript_import_prefer_absolute_path = global
309 | ij_javascript_import_sort_members = true
310 | ij_javascript_import_sort_module_name = false
311 | ij_javascript_import_use_node_resolution = true
312 | ij_javascript_imports_wrap = on_every_item
313 | ij_javascript_indent_case_from_switch = false
314 | ij_javascript_indent_chained_calls = true
315 | ij_javascript_indent_package_children = 0
316 | ij_javascript_jsx_attribute_value = braces
317 | ij_javascript_keep_blank_lines_in_code = 2
318 | ij_javascript_keep_first_column_comment = true
319 | ij_javascript_keep_indents_on_empty_lines = false
320 | ij_javascript_keep_line_breaks = true
321 | ij_javascript_keep_simple_blocks_in_one_line = false
322 | ij_javascript_keep_simple_methods_in_one_line = false
323 | ij_javascript_line_comment_add_space = true
324 | ij_javascript_line_comment_at_first_column = false
325 | ij_javascript_method_brace_style = end_of_line
326 | ij_javascript_method_call_chain_wrap = off
327 | ij_javascript_method_parameters_new_line_after_left_paren = false
328 | ij_javascript_method_parameters_right_paren_on_new_line = false
329 | ij_javascript_method_parameters_wrap = off
330 | ij_javascript_object_literal_wrap = on_every_item
331 | ij_javascript_object_types_wrap = on_every_item
332 | ij_javascript_parentheses_expression_new_line_after_left_paren = false
333 | ij_javascript_parentheses_expression_right_paren_on_new_line = false
334 | ij_javascript_place_assignment_sign_on_next_line = false
335 | ij_javascript_prefer_as_type_cast = false
336 | ij_javascript_prefer_explicit_types_function_expression_returns = false
337 | ij_javascript_prefer_explicit_types_function_returns = false
338 | ij_javascript_prefer_explicit_types_vars_fields = false
339 | ij_javascript_prefer_parameters_wrap = false
340 | ij_javascript_reformat_c_style_comments = false
341 | ij_javascript_space_after_colon = true
342 | ij_javascript_space_after_comma = true
343 | ij_javascript_space_after_dots_in_rest_parameter = false
344 | ij_javascript_space_after_generator_mult = true
345 | ij_javascript_space_after_property_colon = true
346 | ij_javascript_space_after_quest = true
347 | ij_javascript_space_after_type_colon = true
348 | ij_javascript_space_after_unary_not = false
349 | ij_javascript_space_before_async_arrow_lparen = true
350 | ij_javascript_space_before_catch_keyword = true
351 | ij_javascript_space_before_catch_left_brace = true
352 | ij_javascript_space_before_catch_parentheses = true
353 | ij_javascript_space_before_class_lbrace = true
354 | ij_javascript_space_before_class_left_brace = true
355 | ij_javascript_space_before_colon = true
356 | ij_javascript_space_before_comma = false
357 | ij_javascript_space_before_do_left_brace = true
358 | ij_javascript_space_before_else_keyword = true
359 | ij_javascript_space_before_else_left_brace = true
360 | ij_javascript_space_before_finally_keyword = true
361 | ij_javascript_space_before_finally_left_brace = true
362 | ij_javascript_space_before_for_left_brace = true
363 | ij_javascript_space_before_for_parentheses = true
364 | ij_javascript_space_before_for_semicolon = false
365 | ij_javascript_space_before_function_left_parenth = true
366 | ij_javascript_space_before_generator_mult = false
367 | ij_javascript_space_before_if_left_brace = true
368 | ij_javascript_space_before_if_parentheses = true
369 | ij_javascript_space_before_method_call_parentheses = false
370 | ij_javascript_space_before_method_left_brace = true
371 | ij_javascript_space_before_method_parentheses = false
372 | ij_javascript_space_before_property_colon = false
373 | ij_javascript_space_before_quest = true
374 | ij_javascript_space_before_switch_left_brace = true
375 | ij_javascript_space_before_switch_parentheses = true
376 | ij_javascript_space_before_try_left_brace = true
377 | ij_javascript_space_before_type_colon = false
378 | ij_javascript_space_before_unary_not = false
379 | ij_javascript_space_before_while_keyword = true
380 | ij_javascript_space_before_while_left_brace = true
381 | ij_javascript_space_before_while_parentheses = true
382 | ij_javascript_spaces_around_additive_operators = true
383 | ij_javascript_spaces_around_arrow_function_operator = true
384 | ij_javascript_spaces_around_assignment_operators = true
385 | ij_javascript_spaces_around_bitwise_operators = true
386 | ij_javascript_spaces_around_equality_operators = true
387 | ij_javascript_spaces_around_logical_operators = true
388 | ij_javascript_spaces_around_multiplicative_operators = true
389 | ij_javascript_spaces_around_relational_operators = true
390 | ij_javascript_spaces_around_shift_operators = true
391 | ij_javascript_spaces_around_unary_operator = false
392 | ij_javascript_spaces_within_array_initializer_brackets = false
393 | ij_javascript_spaces_within_brackets = false
394 | ij_javascript_spaces_within_catch_parentheses = false
395 | ij_javascript_spaces_within_for_parentheses = false
396 | ij_javascript_spaces_within_if_parentheses = false
397 | ij_javascript_spaces_within_imports = false
398 | ij_javascript_spaces_within_interpolation_expressions = false
399 | ij_javascript_spaces_within_method_call_parentheses = false
400 | ij_javascript_spaces_within_method_parentheses = false
401 | ij_javascript_spaces_within_object_literal_braces = false
402 | ij_javascript_spaces_within_object_type_braces = true
403 | ij_javascript_spaces_within_parentheses = false
404 | ij_javascript_spaces_within_switch_parentheses = false
405 | ij_javascript_spaces_within_type_assertion = false
406 | ij_javascript_spaces_within_union_types = true
407 | ij_javascript_spaces_within_while_parentheses = false
408 | ij_javascript_special_else_if_treatment = true
409 | ij_javascript_ternary_operation_signs_on_next_line = false
410 | ij_javascript_ternary_operation_wrap = off
411 | ij_javascript_union_types_wrap = on_every_item
412 | ij_javascript_use_chained_calls_group_indents = false
413 | ij_javascript_use_double_quotes = true
414 | ij_javascript_use_explicit_js_extension = auto
415 | ij_javascript_use_path_mapping = always
416 | ij_javascript_use_public_modifier = false
417 | ij_javascript_use_semicolon_after_statement = false
418 | ij_javascript_var_declaration_wrap = normal
419 | ij_javascript_while_brace_force = never
420 | ij_javascript_while_on_new_line = false
421 | ij_javascript_wrap_comments = false
422 |
423 | [{*.htm,*.html,*.sht,*.shtm,*.shtml}]
424 | ij_visual_guides = none
425 | ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
426 | ij_html_align_attributes = true
427 | ij_html_align_text = false
428 | ij_html_attribute_wrap = normal
429 | ij_html_block_comment_add_space = false
430 | ij_html_block_comment_at_first_column = true
431 | ij_html_do_not_align_children_of_min_lines = 0
432 | ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p
433 | ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot
434 | ij_html_enforce_quotes = false
435 | ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var
436 | ij_html_keep_blank_lines = 2
437 | ij_html_keep_indents_on_empty_lines = false
438 | ij_html_keep_line_breaks = true
439 | ij_html_keep_line_breaks_in_text = true
440 | ij_html_keep_whitespaces = false
441 | ij_html_keep_whitespaces_inside = span,pre,textarea
442 | ij_html_line_comment_at_first_column = true
443 | ij_html_new_line_after_last_attribute = never
444 | ij_html_new_line_before_first_attribute = never
445 | ij_html_quote_style = double
446 | ij_html_remove_new_line_before_tags = br
447 | ij_html_space_after_tag_name = false
448 | ij_html_space_around_equality_in_attribute = false
449 | ij_html_space_inside_empty_tag = false
450 | ij_html_text_wrap = normal
451 |
452 | [{*.kt,*.kts}]
453 | indent_size = 2
454 | tab_width = 2
455 | ij_continuation_indent_size = 4
456 | ij_visual_guides = none
457 | ij_kotlin_align_in_columns_case_branch = false
458 | ij_kotlin_align_multiline_binary_operation = false
459 | ij_kotlin_align_multiline_extends_list = false
460 | ij_kotlin_align_multiline_method_parentheses = false
461 | ij_kotlin_align_multiline_parameters = true
462 | ij_kotlin_align_multiline_parameters_in_calls = false
463 | ij_kotlin_allow_trailing_comma = false
464 | ij_kotlin_allow_trailing_comma_on_call_site = false
465 | ij_kotlin_assignment_wrap = normal
466 | ij_kotlin_blank_lines_after_class_header = 0
467 | ij_kotlin_blank_lines_around_block_when_branches = 0
468 | ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
469 | ij_kotlin_block_comment_add_space = false
470 | ij_kotlin_block_comment_at_first_column = true
471 | ij_kotlin_call_parameters_new_line_after_left_paren = true
472 | ij_kotlin_call_parameters_right_paren_on_new_line = true
473 | ij_kotlin_call_parameters_wrap = on_every_item
474 | ij_kotlin_catch_on_new_line = false
475 | ij_kotlin_class_annotation_wrap = split_into_lines
476 | ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
477 | ij_kotlin_continuation_indent_for_chained_calls = false
478 | ij_kotlin_continuation_indent_for_expression_bodies = false
479 | ij_kotlin_continuation_indent_in_argument_lists = false
480 | ij_kotlin_continuation_indent_in_elvis = false
481 | ij_kotlin_continuation_indent_in_if_conditions = false
482 | ij_kotlin_continuation_indent_in_parameter_lists = false
483 | ij_kotlin_continuation_indent_in_supertype_lists = false
484 | ij_kotlin_else_on_new_line = false
485 | ij_kotlin_enum_constants_wrap = off
486 | ij_kotlin_extends_list_wrap = normal
487 | ij_kotlin_field_annotation_wrap = split_into_lines
488 | ij_kotlin_finally_on_new_line = false
489 | ij_kotlin_if_rparen_on_new_line = true
490 | ij_kotlin_import_nested_classes = false
491 | ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
492 | ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
493 | ij_kotlin_keep_blank_lines_before_right_brace = 2
494 | ij_kotlin_keep_blank_lines_in_code = 2
495 | ij_kotlin_keep_blank_lines_in_declarations = 2
496 | ij_kotlin_keep_first_column_comment = true
497 | ij_kotlin_keep_indents_on_empty_lines = false
498 | ij_kotlin_keep_line_breaks = true
499 | ij_kotlin_lbrace_on_next_line = false
500 | ij_kotlin_line_break_after_multiline_when_entry = true
501 | ij_kotlin_line_comment_add_space = false
502 | ij_kotlin_line_comment_add_space_on_reformat = false
503 | ij_kotlin_line_comment_at_first_column = true
504 | ij_kotlin_method_annotation_wrap = split_into_lines
505 | ij_kotlin_method_call_chain_wrap = normal
506 | ij_kotlin_method_parameters_new_line_after_left_paren = true
507 | ij_kotlin_method_parameters_right_paren_on_new_line = true
508 | ij_kotlin_method_parameters_wrap = on_every_item
509 | ij_kotlin_name_count_to_use_star_import = 5
510 | ij_kotlin_name_count_to_use_star_import_for_members = 3
511 | ij_kotlin_packages_to_use_import_on_demand = java.util.*,kotlinx.android.synthetic.**,io.ktor.**
512 | ij_kotlin_parameter_annotation_wrap = off
513 | ij_kotlin_space_after_comma = true
514 | ij_kotlin_space_after_extend_colon = true
515 | ij_kotlin_space_after_type_colon = true
516 | ij_kotlin_space_before_catch_parentheses = true
517 | ij_kotlin_space_before_comma = false
518 | ij_kotlin_space_before_extend_colon = true
519 | ij_kotlin_space_before_for_parentheses = true
520 | ij_kotlin_space_before_if_parentheses = true
521 | ij_kotlin_space_before_lambda_arrow = true
522 | ij_kotlin_space_before_type_colon = false
523 | ij_kotlin_space_before_when_parentheses = true
524 | ij_kotlin_space_before_while_parentheses = true
525 | ij_kotlin_spaces_around_additive_operators = true
526 | ij_kotlin_spaces_around_assignment_operators = true
527 | ij_kotlin_spaces_around_equality_operators = true
528 | ij_kotlin_spaces_around_function_type_arrow = true
529 | ij_kotlin_spaces_around_logical_operators = true
530 | ij_kotlin_spaces_around_multiplicative_operators = true
531 | ij_kotlin_spaces_around_range = false
532 | ij_kotlin_spaces_around_relational_operators = true
533 | ij_kotlin_spaces_around_unary_operator = false
534 | ij_kotlin_spaces_around_when_arrow = true
535 | ij_kotlin_variable_annotation_wrap = off
536 | ij_kotlin_while_on_new_line = false
537 | ij_kotlin_wrap_elvis_expressions = 1
538 | ij_kotlin_wrap_expression_body_functions = 1
539 | ij_kotlin_wrap_first_method_in_call_chain = false
540 |
541 | [{*.markdown,*.md}]
542 | ij_visual_guides = none
543 | ij_markdown_force_one_space_after_blockquote_symbol = true
544 | ij_markdown_force_one_space_after_header_symbol = true
545 | ij_markdown_force_one_space_after_list_bullet = true
546 | ij_markdown_force_one_space_between_words = true
547 | ij_markdown_format_tables = true
548 | ij_markdown_insert_quote_arrows_on_wrap = true
549 | ij_markdown_keep_indents_on_empty_lines = false
550 | ij_markdown_keep_line_breaks_inside_text_blocks = true
551 | ij_markdown_max_lines_around_block_elements = 1
552 | ij_markdown_max_lines_around_header = 1
553 | ij_markdown_max_lines_between_paragraphs = 1
554 | ij_markdown_min_lines_around_block_elements = 1
555 | ij_markdown_min_lines_around_header = 1
556 | ij_markdown_min_lines_between_paragraphs = 1
557 | ij_markdown_wrap_text_if_long = true
558 | ij_markdown_wrap_text_inside_blockquotes = true
559 |
560 | [{*.properties,spring.handlers,spring.schemas}]
561 | ij_visual_guides = none
562 | ij_properties_align_group_field_declarations = false
563 | ij_properties_keep_blank_lines = false
564 | ij_properties_key_value_delimiter = equals
565 | ij_properties_spaces_around_key_value_delimiter = false
566 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle/
2 | build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 | !**/src/main/**/build/
5 | !**/src/test/**/build/
6 |
7 | ### IntelliJ IDEA ###
8 | .idea/
9 | *.iws
10 | *.iml
11 | *.ipr
12 | out/
13 | !**/src/main/**/out/
14 | !**/src/test/**/out/
15 |
16 | ### VS Code ###
17 | .vscode/
18 |
19 | ### Mac OS ###
20 | .DS_Store
21 | .kotlin
22 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | .
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent any
3 | stages {
4 | stage('Build Parameters') {
5 | when {
6 | branch "main"
7 | }
8 | steps {
9 | script {
10 | properties([parameters([
11 | booleanParam(defaultValue: false,
12 | description: 'Release',
13 | name: 'RELEASE'),
14 | stringParam(defaultValue: 'auto',
15 | description: 'Version, "auto" for automatic versioning, or specify a version number (e.g. 1.0.0)',
16 | name: 'VERSION'),
17 | ])])
18 | }
19 | }
20 | }
21 |
22 | // When building on the main branch, we want to deploy the project to the
23 | // repository to expose the artifact to other projects
24 | stage('Deploy Project') {
25 | when {
26 | branch "main"
27 | }
28 | steps {
29 | sh 'bin/mvn clean deploy --no-transfer-progress --update-snapshots'
30 | }
31 | }
32 |
33 | // When building on a branch other than main, we intend to build the project
34 | // but not deploy it to the repository. Since it is not mainline yet.
35 | stage('Build Project') {
36 | when {
37 | not { branch "main" }
38 | }
39 | steps {
40 | sh 'bin/mvn clean package --no-transfer-progress --update-snapshots'
41 | }
42 | }
43 |
44 | stage('Release') {
45 | when {
46 | branch "main"
47 | expression {
48 | return params.RELEASE == true
49 | }
50 | }
51 | steps {
52 | sh "bin/dev release '$VERSION'"
53 | }
54 | }
55 | }
56 | post {
57 | always {
58 | junit allowEmptyResults: true,
59 | testResults: 'test-results.xml'
60 | archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Carl Taylor
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Selenium jQuery
2 | ====================================
3 | Working with selenium's selector api is a huge pain in the ass.
4 |
5 | What technology likes to fix bad web-centric apis for the most developer centric ergonomics? JQUERY!
6 |
7 | The technology from the 90s is still saving us from bad design today!
8 |
9 | ```xml
10 |
11 | com.iodesystems.selenium-jquery
12 | selenium-jquery
13 | 2.1.3
14 |
15 | ```
16 |
17 | Overview
18 | ------------------------------------
19 | `SeleniumJQuery` rides on `Selenium`'s `RemoteWebDriver` api and automagically installs `jQuery` in
20 | websites to make automation and testing a breeze.
21 |
22 | Combined with `kotlin`'s DSL utilities, `PageObject` design goes to it's well deserved grave.
23 |
24 | Example
25 | ------------------------------------
26 |
27 | Check out `jQueryTest.kt` for an example of how to bootstrap the `jQuery` object
28 | using `webdrivermanager`:
29 | ```xml
30 |
31 | io.github.bonigarcia
32 | webdrivermanager
33 | 5.3.2
34 | test
35 |
36 | ```
37 |
38 | Creating the driver and `jQuery` instance:
39 | ```kotlin
40 | // Use WebDriverManager to ensure full selenium protocol compatibility for performance
41 | WebDriverManager.chromedriver().setup()
42 | // Silence as much noise as possible
43 | val chromeDriverService: ChromeDriverService = ChromeDriverService.Builder()
44 | .withSilent(true)
45 | .build()
46 | chromeDriverService.sendOutputTo(NullOutputStream.NULL_OUTPUT_STREAM)
47 |
48 | var options = ChromeOptions()
49 | // Disable attempts to save things to the profile
50 | options.setExperimentalOption(
51 | "prefs", mapOf(
52 | "autofill.profile_enabled" to false
53 | )
54 | )
55 | // Don't show popup notifications
56 | options.addArguments("--disable-notifications")
57 | // Ignore prompts
58 | options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.DISMISS)
59 | // Don't bother waiting for the entire dom to load, if you can do your thang already
60 | options.setPageLoadStrategy(PageLoadStrategy.EAGER)
61 | if (headless) {
62 | options = options
63 | .addArguments("--headless")
64 | .addArguments("window-size=1920,1080")
65 | }
66 | val driver = ChromeDriver(chromeDriverService, options)
67 | // Set some sane amount of timeout so tests don't hang on issues
68 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5))
69 | ```
70 |
71 | Using the `jQuery` object:
72 | ```kotlin
73 | jq.page("http://google.com") {
74 | find("input[name='q']").sendKeys("hello world", 30)
75 | find("input[value='Google Search']").first().click()
76 | find("#result-stats").visible()
77 | }
78 | ```
79 |
80 | Nested objects, parent and child traversals:
81 | ```kotlin
82 | jq.page("http://some-page.com") {
83 | frame("#frame-id") {
84 | find(".hidden-in-frame").parent(".most-recent-parent-containing") {
85 | find(".child-of-that-parent")
86 | }
87 | }
88 | find(".a"){
89 | // Hierarchy can be nested as far as you like
90 | find(".b"){
91 | // Reroot breaks out of hierarchy
92 | reroot("body").exists()
93 | }
94 | }
95 | }
96 | ```
97 |
98 | More aggressive testing for difficult controls:
99 | ```kotlin
100 | // Not direct clicking due to bubbling? FORCE IT!
101 | find(".weird-control").clickForce()
102 | // Controlled text input masking things all weird? Put a delay in it!
103 | find(".text-settling-input").clear().sendKeys("important", delayMilis = 100)
104 | ```
105 |
106 | Extension
107 | ------------------------------------
108 | I'll admit, `SeleniumJQuery` doesn't have it all, pull requests are welcome, however, it's super easy to
109 | extend the `IEl` object with `kotlin`'s extension functions:
110 |
111 | ```kotlin
112 | // Some examples for the Mui framework and general time savers:
113 | fun jQuery.IEl.inputLabeled(label: String) =
114 | find(".MuiInputBase-formControl")
115 | .contains(label)
116 | .find(":input:first")
117 | fun jQuery.IEl.buttonLabeled(label: String) =
118 | find("button")
119 | .contains(label)
120 | .enabled()
121 | fun jQuery.IEl.linkWithText(text: String) =
122 | find("a")
123 | .contains(text)
124 | fun jQuery.IEl.buttonWithIcon(icon: String) =
125 | find("svg[data-testid='$icon']")
126 | .parent("button")
127 | ```
128 |
129 | Custom domain objects are also a breeze:
130 | ```kotlin
131 | // Page Object DSL
132 | data class Dialog(val el:IEl) : IEl by el {
133 | fun password(password:String) = inputLabeled("Password").first().sendKeys(password)
134 | fun submit() = find("button[type=submit]").click()
135 | }
136 | // Bootstrap extension:
137 | fun jQuery.IEl.dialog(
138 | label: String,
139 | fn: Dialog.()->T
140 | ) {
141 | val el = find(".dialog-container").contains(label)
142 | return fn(Dialog(el))
143 | }
144 | // Usage:
145 | ...
146 | jq.page{
147 | dialog("Enter Password"){
148 | password("super secure!") // DSL
149 | submit() // DSL
150 | gone() // EL method: Wait until dialog disappears
151 | }
152 | }
153 | ...
154 | ```
155 |
--------------------------------------------------------------------------------
/bin/release:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | gradle releaseStripSnapshotCommitAndTag && \
3 | (gradle releasePublish || gradle releaseRevert) && \
4 | gradle releasePrepareNextDevelopmentIteration
5 |
--------------------------------------------------------------------------------
/build-logic/build.gradle.kts:
--------------------------------------------------------------------------------
1 | repositories {
2 | mavenLocal()
3 | mavenCentral()
4 | gradlePluginPortal()
5 | }
6 |
7 | plugins {
8 | `kotlin-dsl`
9 | alias(libs.plugins.gradle.nexus.publish)
10 | }
11 |
12 | dependencies {
13 | implementation(libs.kotlin.gradle.plugin)
14 | implementation(libs.dokka.gradle.plugin)
15 | compileOnly(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
16 | }
17 |
--------------------------------------------------------------------------------
/build-logic/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | versionCatalogs {
3 | create("libs") {
4 | from(files("../gradle/libs.versions.toml"))
5 | }
6 | }
7 | }
8 |
9 | rootProject.name = "build-logic"
10 |
--------------------------------------------------------------------------------
/build-logic/src/main/kotlin/kotlin-library-convention.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.gradle.accessors.dm.LibrariesForLibs
2 |
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | gradlePluginPortal()
7 | }
8 |
9 | plugins {
10 | kotlin("jvm") apply false
11 | `java-library`
12 | `maven-publish`
13 | signing
14 | id("org.jetbrains.dokka")
15 | id("io.github.gradle-nexus.publish-plugin")
16 | }
17 |
18 | val libs = the()
19 |
20 | repositories {
21 | mavenCentral()
22 | }
23 |
24 | kotlin {
25 | jvmToolchain(21)
26 | }
27 |
28 | tasks.withType().configureEach {
29 | compilerOptions {
30 | jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
31 | freeCompilerArgs.add("-Xjsr305=strict")
32 | }
33 | }
34 |
35 | publishing {
36 | publications {
37 | create("mavenJava") {
38 | from(components["java"])
39 | pom {
40 | name.set(project.name)
41 | description.set(project.description)
42 | url.set("http://nthalk.github.io/SeleniumJQuery/")
43 | licenses {
44 | license {
45 | name.set("MIT License")
46 | url.set("http://www.opensource.org/licenses/mit-license.php")
47 | }
48 | }
49 | developers {
50 | developer {
51 | id.set("nthalk")
52 | name.set("Carl Taylor")
53 | email.set("carl@etaylor.me")
54 | roles.add("owner")
55 | roles.add("developer")
56 | timezone.set("-8")
57 | }
58 | }
59 | scm {
60 | connection.set("scm:git:git@github.com:Nthalk/SeleniumJQuery.git")
61 | developerConnection.set("scm:git:git@github.com:Nthalk/SeleniumJQuery.git")
62 | url.set("http://nthalk.github.io/SeleniumJQuery/")
63 | tag.set("selenium-jquery-2.0.0")
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
70 | signing {
71 | sign(publishing.publications["mavenJava"])
72 | }
73 |
74 | dokka {
75 | moduleName.set(rootProject.name)
76 | dokkaSourceSets.main {
77 | includes.from("README.md")
78 | sourceLink {
79 | localDirectory.set(file("src/main/kotlin"))
80 | remoteUrl("https://github.com/IodeSystems/SeleniumJQuery/blob/main/src/main/kotlin")
81 | remoteLineSuffix.set("#L")
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3 | import java.time.Duration
4 |
5 | group = "com.iodesystems.selenium-jquery"
6 | version = "4.1.4-SNAPSHOT"
7 | description =
8 | "SeleniumJQuery is a tool for writing more effective Selenium tests with the power of jQuery selectors and Kotlin's expressiveness"
9 |
10 | repositories {
11 | mavenLocal()
12 | mavenCentral()
13 | gradlePluginPortal()
14 | }
15 |
16 | plugins {
17 | kotlin("jvm")
18 | `java-library`
19 | `maven-publish`
20 | signing
21 | id("org.jetbrains.dokka-javadoc")
22 | id("io.github.gradle-nexus.publish-plugin")
23 | }
24 |
25 | repositories {
26 | mavenCentral()
27 | }
28 |
29 | kotlin {
30 | jvmToolchain(21)
31 | }
32 |
33 | tasks.withType().configureEach {
34 | compilerOptions {
35 | jvmTarget.set(JvmTarget.JVM_21)
36 | freeCompilerArgs.add("-Xjsr305=strict")
37 | }
38 | }
39 |
40 | val javadocJar: TaskProvider by tasks.registering(Jar::class) {
41 | dependsOn(tasks.dokkaGeneratePublicationJavadoc)
42 | archiveClassifier.set("javadoc")
43 | from(tasks.dokkaGeneratePublicationJavadoc.get().outputDirectory)
44 | }
45 | publishing {
46 | publications {
47 | create("mavenJava") {
48 | from(components["java"])
49 | artifact(javadocJar)
50 | artifact(tasks.kotlinSourcesJar) {
51 | classifier = "sources"
52 | }
53 | pom {
54 | name.set(project.name)
55 | description.set(project.description)
56 | url.set("http://nthalk.github.io/SeleniumJQuery/")
57 | licenses {
58 | license {
59 | name.set("MIT License")
60 | url.set("http://www.opensource.org/licenses/mit-license.php")
61 | }
62 | }
63 | developers {
64 | developer {
65 | id.set("nthalk")
66 | name.set("Carl Taylor")
67 | email.set("carl@etaylor.me")
68 | roles.add("owner")
69 | roles.add("developer")
70 | timezone.set("-8")
71 | }
72 | }
73 | scm {
74 | connection.set("scm:git:git@github.com:Nthalk/SeleniumJQuery.git")
75 | developerConnection.set("scm:git:git@github.com:Nthalk/SeleniumJQuery.git")
76 | url.set("http://nthalk.github.io/SeleniumJQuery/")
77 | tag.set("selenium-jquery-2.0.0")
78 | }
79 | }
80 | }
81 | }
82 | }
83 |
84 | nexusPublishing {
85 | transitionCheckOptions {
86 | maxRetries.set(300)
87 | delayBetween.set(Duration.ofSeconds(10))
88 | }
89 | repositories {
90 | sonatype {
91 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
92 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
93 | }
94 | }
95 | }
96 |
97 | dependencies {
98 | implementation(Kotlin.stdlib.jdk8)
99 | implementation(libs.selenium.remote.driver)
100 | implementation(libs.selenium.support)
101 |
102 | testImplementation(Kotlin.test.junit)
103 | testImplementation(libs.junit)
104 | testImplementation(libs.selenium.chrome.driver)
105 | testImplementation(libs.webdrivermanager) {
106 | exclude(group = "com.fasterxml.jackson.core", module = "jackson-databind")
107 | exclude(group = "org.bouncycastle", module = "bcprov-jdk15on")
108 | exclude(group = "commons-io", module = "commons-io")
109 | }
110 | testImplementation(libs.commons.io)
111 | testImplementation(libs.bcprov.jdk18on)
112 | testImplementation(libs.jackson.databind)
113 | }
114 |
115 | signing {
116 | useGpgCmd()
117 | sign(publishing.publications)
118 | }
119 |
120 | tasks.register("releaseStripSnapshotCommitAndTag") {
121 | group = "release"
122 | doLast {
123 | val status = "git status --porcelain".bash().trim()
124 | if (status.isNotEmpty()) {
125 | throw GradleException("There are changes in the working directory:\n$status")
126 | }
127 | val oldVersion = version.toString()
128 | val newVersion = oldVersion.removeSuffix("-SNAPSHOT")
129 | writeVersion(newVersion)
130 | "git add build.gradle.kts".bash()
131 | "git commit -m 'Release $newVersion'".bash()
132 | "git tag -a v$newVersion -m 'Release $newVersion'".bash()
133 | }
134 | }
135 | tasks.register("releaseRevert") {
136 | group = "release"
137 | doLast {
138 | val oldVersion = version.toString()
139 | val newVersion = "$oldVersion-SNAPSHOT"
140 | writeVersion(newVersion, oldVersion)
141 | "git reset --hard HEAD~1".bash()
142 | "git tag -d v$oldVersion".bash()
143 | println("Reverted to $newVersion")
144 | }
145 | }
146 | tasks.register("releasePublish") {
147 | dependsOn(tasks.clean)
148 | dependsOn(tasks.build)
149 | dependsOn(tasks.publish)
150 | dependsOn(tasks.closeAndReleaseStagingRepositories)
151 | doLast {
152 | val oldVersion = version.toString()
153 | val newVersion = generateVersion("dev")
154 | writeVersion(newVersion, oldVersion)
155 | "git add build.gradle.kts".bash()
156 | "git commit -m 'Prepare next development iteration: $newVersion'".bash()
157 | "git push".bash()
158 | "git push --tags".bash()
159 | }
160 | }
161 | tasks.register("releasePrepareNextDevelopmentIteration") {
162 | doLast {
163 | val oldVersion = version.toString()
164 | val newVersion = generateVersion("dev")
165 | writeVersion(newVersion, oldVersion)
166 | "git add build.gradle.kts".bash()
167 | "git commit -m 'Prepare next development iteration: $newVersion'".bash()
168 | "git push".bash()
169 | }
170 | }
171 |
172 | fun generateVersion(updateMode: String): String {
173 | properties["overrideVersion"].let {
174 | if (it != null) {
175 | return it as String
176 | }
177 | }
178 |
179 | val version = properties["version"] as String
180 | val nonSnapshotVersion = version.removeSuffix("-SNAPSHOT")
181 |
182 | val (oldMajor, oldMinor, oldPatch) = nonSnapshotVersion.split(".").map(String::toInt)
183 | var (newMajor, newMinor, newPatch) = arrayOf(oldMajor, oldMinor, 0)
184 |
185 | when (updateMode) {
186 | "major" -> newMajor = (oldMajor + 1).also { newMinor = 0 }
187 | "minor" -> newMinor = oldMinor + 1
188 | "dev" -> newPatch = oldPatch + 1
189 | else -> newPatch = oldPatch + 1
190 | }
191 | if (updateMode == "dev" || nonSnapshotVersion != version) {
192 | return "$newMajor.$newMinor.$newPatch-SNAPSHOT"
193 | }
194 | return "$newMajor.$newMinor.$newPatch"
195 | }
196 |
197 | fun writeVersion(newVersion: String, oldVersion: String = version.toString()) {
198 | val oldContent = buildFile.readText()
199 | val newContent = oldContent.replace("""= "$oldVersion"""", """= "$newVersion"""")
200 | buildFile.writeText(newContent)
201 | }
202 |
203 | private fun String.bash(): String {
204 | val process = ProcessBuilder(
205 | "bash", "-c", this
206 | ).start()
207 | var content = ""
208 | val er = Thread {
209 | process.errorStream.reader().useLines { lines ->
210 | lines.forEach {
211 | println(it)
212 | }
213 | }
214 | }
215 | val out = Thread {
216 | content = process.inputStream.reader().useLines { lines ->
217 | lines.map {
218 | println(it)
219 | it
220 | }.joinToString("\n")
221 | }
222 | }
223 | er.start()
224 | out.start()
225 | process.waitFor().also { code ->
226 | er.join()
227 | out.join()
228 | if (code != 0) {
229 | throw GradleException("Failed ($code) to execute command: $this")
230 | }
231 | }
232 | return content
233 | }
234 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
2 | org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
3 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | ## Generated by $ ./gradlew refreshVersionsCatalog
2 |
3 | [plugins]
4 |
5 | org-jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
6 |
7 | org-jetbrains-dokka = { id = "org.jetbrains.dokka", version = "2.0.0" }
8 |
9 | gradle-nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
10 |
11 | org-jetbrains-dokka-javadoc = { id = "org.jetbrains.dokka-javadoc", version = "2.0.0" }
12 |
13 | io-github-gradle-nexus-publish-plugin = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
14 |
15 | [versions]
16 |
17 | kotlin = "2.1.21"
18 |
19 | junit-junit = "4.13.2"
20 |
21 | gradle-nexus-publish = "1.5.0"
22 |
23 | [libraries]
24 |
25 | kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
26 |
27 | dokka-gradle-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version = "2.0.0" }
28 |
29 | selenium-remote-driver = "org.seleniumhq.selenium:selenium-remote-driver:4.32.0"
30 |
31 | selenium-support = "org.seleniumhq.selenium:selenium-support:4.32.0"
32 |
33 | junit = { group = "junit", name = "junit", version.ref = "junit-junit" }
34 |
35 | selenium-chrome-driver = "org.seleniumhq.selenium:selenium-chrome-driver:4.32.0"
36 |
37 | webdrivermanager = "io.github.bonigarcia:webdrivermanager:6.1.0"
38 |
39 | commons-io = "commons-io:commons-io:2.19.0"
40 |
41 | bcprov-jdk18on = "org.bouncycastle:bcprov-jdk18on:1.80"
42 |
43 | jackson-databind = "com.fasterxml.jackson.core:jackson-databind:2.19.0"
44 |
45 | analysis-kotlin-descriptors = "org.jetbrains.dokka:analysis-kotlin-descriptors:2.0.0"
46 |
47 | dokka-core = "org.jetbrains.dokka:dokka-core:2.0.0"
48 |
49 | javadoc-plugin = "org.jetbrains.dokka:javadoc-plugin:2.0.0"
50 |
51 | templating-plugin = "org.jetbrains.dokka:templating-plugin:2.0.0"
52 |
53 | dokka-base = "org.jetbrains.dokka:dokka-base:2.0.0"
54 |
55 | kotlin-build-tools-impl = { module = "org.jetbrains.kotlin:kotlin-build-tools-impl" }
56 |
57 | kotlin-scripting-compiler-embeddable = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-compiler-embeddable", version.ref = "kotlin" }
58 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IodeSystems/SeleniumJQuery/e3aae4bad76f24ddbcbfd73de64be3eb76fa3343/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:recommended"
5 | ],
6 | "minimumReleaseAge": "3 days",
7 | "automergeStrategy": "rebase",
8 | "packageRules": [
9 | {
10 | "matchUpdateTypes": [
11 | "minor",
12 | "patch"
13 | ],
14 | "automerge": true
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | mavenCentral()
5 | }
6 | }
7 |
8 | plugins {
9 | id("de.fayard.refreshVersions") version "0.60.5"
10 | }
11 |
12 |
13 | rootProject.name = "selenium-jquery"
14 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/iodesystems/selenium/el/El.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium.el
2 |
3 | import com.iodesystems.selenium.exceptions.RetryException
4 | import com.iodesystems.selenium.jQuery
5 | import org.openqa.selenium.*
6 | import org.openqa.selenium.interactions.Actions
7 | import org.openqa.selenium.interactions.MoveTargetOutOfBoundsException
8 | import org.openqa.selenium.remote.RemoteWebDriver
9 | import org.openqa.selenium.remote.RemoteWebElement
10 | import org.openqa.selenium.support.ui.Select
11 | import java.io.File
12 | import java.time.Duration
13 |
14 | data class El(
15 | override val jq: jQuery,
16 | override val selector: List,
17 | val atLeast: Int? = null,
18 | val atMost: Int? = null,
19 | ) : IEl {
20 |
21 | private fun safely(
22 | el: RemoteWebElement,
23 | fn: RemoteWebElement.() -> T
24 | ): T {
25 | try {
26 | return fn(el)
27 | } catch (e: InvalidElementStateException) {
28 | throw RetryException("Element not interactable", e)
29 | } catch (e: ElementNotInteractableException) {
30 | throw RetryException("Element not interactable", e)
31 | } catch (e: StaleElementReferenceException) {
32 | throw RetryException("Stale element reference", e)
33 | } catch (e: MoveTargetOutOfBoundsException) {
34 | try {
35 | Actions(jq.driver as WebDriver).moveToElement(el).perform()
36 | } catch (e: MoveTargetOutOfBoundsException) {
37 | scrollIntoView()
38 | throw RetryException("Element cannot be scrolled to", e)
39 | }
40 | throw RetryException("Element requires scrolling to", e)
41 | }
42 | }
43 |
44 | override fun data(key: String): String? {
45 | return element().getAttribute("data-$key")
46 | }
47 |
48 | override fun attr(key: String): String? {
49 | return element().getAttribute(key)
50 | }
51 |
52 | override fun actions(): Actions {
53 | return Actions(jq.driver)
54 | }
55 |
56 | override fun atLeast(): Int? {
57 | return atLeast
58 | }
59 |
60 | override fun atMost(): Int? {
61 | return atMost
62 | }
63 |
64 | override fun one(): IEl {
65 | return require(1, 1)
66 | }
67 |
68 | override fun click(): IEl {
69 | jq.waitForNonNull("could not click") {
70 | val element = element()
71 | safely(element) {
72 | try {
73 | click()
74 | } catch (e: ElementClickInterceptedException) {
75 | jq.driver.executeScript("arguments[0].click()", element)
76 | }
77 | }
78 | }
79 | return this
80 | }
81 |
82 | override fun clear(): IEl {
83 | jq.waitForNonNull("could not clear element") {
84 | safely(element()) {
85 | clear()
86 | val length = (getAttribute("value") ?: "").length
87 | if (length > 0) sendKeys((0..length).joinToString("") {
88 | Keys.BACK_SPACE
89 | })
90 | }
91 | }
92 | return this
93 | }
94 |
95 | override fun blur(): IEl {
96 | actions().sendKeys(Keys.TAB).perform()
97 | return this
98 | }
99 |
100 | override fun text(): String {
101 | return element().text
102 | }
103 |
104 | override fun sendKeys(text: CharSequence, rateMillis: Int?): IEl {
105 | if (rateMillis == null) {
106 | jq.waitForNonNull("Could not send keys") {
107 | safely(element()) {
108 | sendKeys(text)
109 | }
110 | }
111 | } else {
112 | val script = renderScript()
113 | jq.waitForNonNull(
114 | "Could not send keys",
115 | retry = Duration.ofMillis(text.length * rateMillis.toLong()),
116 | timeOut = Duration.ofMillis(text.length * rateMillis.toLong() * 100),
117 | ) {
118 | val elements = elementsUnChecked()
119 | if (elements.size != 1) {
120 | throw RetryException("Elements for $script not 1, but ${elements.size}")
121 | }
122 | safely(elements[0]) {
123 | text.fold(
124 | Actions(jq.driver as WebDriver)
125 | .click(this)
126 | ) { a, c ->
127 | a.pause(Duration.ofMillis(rateMillis.toLong())).sendKeys(c.toString())
128 | }.perform()
129 | }
130 | }
131 | }
132 | return this
133 | }
134 |
135 | override fun refine(refineSelector: String): IEl {
136 | return copy(
137 | selector =
138 | if (selector.isEmpty()) listOf(refineSelector)
139 | else selector.map { "$it$refineSelector" }
140 | )
141 | }
142 |
143 |
144 | override fun contains(text: String): IEl {
145 | return refine(":contains(${jq.escape(text)})")
146 | }
147 |
148 | override fun value(): String {
149 | return (element().getAttribute("value") ?: "").trim()
150 | }
151 |
152 | override fun gone() {
153 | copy(atMost = 0, atLeast = null).elements()
154 | }
155 |
156 | override fun exists() {
157 | if (atLeast == null || atLeast == 0) {
158 | copy(atLeast = 1).element()
159 | } else element()
160 | }
161 |
162 | override fun disabled(): IEl {
163 | return refine(":disabled")
164 | }
165 |
166 | override fun visible(): IEl {
167 | return refine(":visible")
168 | }
169 |
170 | override fun maybeExists(): Boolean {
171 | return elementsUnChecked().isNotEmpty()
172 | }
173 |
174 | override fun ifExists(fn: IEl.() -> T): T? {
175 | return if (maybeExists()) return null
176 | else fn(this)
177 | }
178 |
179 | override fun withDriver(remoteWebDriver: RemoteWebDriver): IEl {
180 | return jq.copy(driver = remoteWebDriver).root()
181 | }
182 |
183 | override fun element(): RemoteWebElement {
184 | return elements().first()
185 | }
186 |
187 | override fun elementsUnChecked(): List {
188 | return jq.search(
189 | listOf(this.copy(atLeast = null, atMost = null))
190 | ).firstOrNull() ?: emptyList()
191 | }
192 |
193 | override fun elements(): List {
194 | return jq.search(listOf(this)).first()!!
195 | }
196 |
197 | override fun renderSelector(): String {
198 | return if (selector.isEmpty()) ":root"
199 | else selector.joinToString(", ")
200 | }
201 |
202 | override fun js(script: String, vararg args: Any?): Any? {
203 | return jq.driver.executeScript(script, *args)
204 | }
205 |
206 | override fun scrollIntoView(): IEl {
207 | jq.driver.executeScript(
208 | "arguments[0].scrollIntoView({block:'end', inline:'end', behavior:'instant'})",
209 | element()
210 | )
211 | return this
212 | }
213 |
214 | override fun screenshot(destinationFile: String): IEl {
215 | File(destinationFile).writeBytes(jq.driver.getScreenshotAs(OutputType.BYTES))
216 | return this
217 | }
218 |
219 | override fun renderScript(): String {
220 | return """
221 | jQuery(${escape(renderSelector())})
222 | """.trimIndent()
223 | }
224 |
225 | override fun findAll(childSelector: List, atLeast: Int?, atMost: Int?): IEl {
226 | return copy(
227 | selector = if (selector.isEmpty()) childSelector else selector.map { parent ->
228 | childSelector.map { child ->
229 | "$parent $child".trim()
230 | }
231 | }.flatten(),
232 | atLeast = atLeast,
233 | atMost = atMost,
234 | )
235 | }
236 |
237 | override fun findAll(childSelector: String, atLeast: Int?, atMost: Int?): IEl {
238 | return findAll(listOf(childSelector), atLeast, atMost)
239 | }
240 |
241 | override fun find(childSelector: List, fn: IEl.() -> T): T {
242 | return find(childSelector).run(fn)
243 | }
244 |
245 | override fun find(childSelector: List): IEl {
246 | return findAll(childSelector, 1, 1)
247 | }
248 |
249 | override fun find(childSelector: String): IEl {
250 | return find(listOf(childSelector))
251 | }
252 |
253 | override fun require(atMost: Int?, atLeast: Int?): IEl {
254 | return copy(atMost = atMost, atLeast = atLeast)
255 | }
256 |
257 | override fun find(childSelector: String, fn: IEl.() -> T): T {
258 | return fn(find(childSelector))
259 | }
260 |
261 | override fun parent(parentSelector: String, atLeast: Int?, atMost: Int?): IEl {
262 | return parent(listOf(parentSelector), atLeast, atMost)
263 | }
264 |
265 | override fun parent(parentSelector: List, atLeast: Int?, atMost: Int?): IEl {
266 | return copy(
267 | selector = parentSelector.map { parent ->
268 | selector.map { child ->
269 | "$parent:has(${child}):last"
270 | }
271 | }.flatten(),
272 | atLeast = atLeast,
273 | atMost = atMost
274 | )
275 | }
276 |
277 | override fun enabled(): IEl {
278 | return refine(":enabled")
279 | }
280 |
281 | override fun reroot(selector: String?): IEl {
282 | return copy(
283 | selector = if (selector == null) emptyList() else listOf(selector),
284 | atLeast = 1,
285 | atMost = null
286 | )
287 | }
288 |
289 | override fun escape(string: String): String {
290 | return jq.escape(string)
291 | }
292 |
293 | override fun first(first: String, vararg rest: String): IEl {
294 | return first(find(first), *rest.map { find(it) }.toTypedArray())
295 | }
296 |
297 | override fun first(first: IEl, vararg rest: IEl): IEl {
298 | val all = listOf(first) + rest.toList()
299 | val results = jq.search(all)
300 | val found = results.find { it != null }!!
301 | return all[results.indexOf(found)]
302 | }
303 |
304 | override fun first(): IEl {
305 | return copy(atLeast = 1, atMost = null).refine(":first")
306 | }
307 |
308 | override fun last(): IEl {
309 | return copy(atLeast = 1, atMost = null).refine(":last")
310 | }
311 |
312 | override fun selectValue(value: String): IEl {
313 | Select(element()).selectByValue(value)
314 | return this
315 | }
316 |
317 | override fun withTab(label: String, cb: IEl.() -> T): T {
318 | val jq = jq
319 | val driver = waitFor {
320 | jq.driver.windowHandles.stream().map { handle ->
321 | val newDriver = jq.driver.switchTo().window(handle)
322 | val title = newDriver.title ?: ""
323 | if (title.contains(label, ignoreCase = true)) {
324 | newDriver
325 | } else {
326 | newDriver.close()
327 | null
328 | }
329 | }.filter { it != null }.findFirst().orElse(null)
330 | } as RemoteWebDriver
331 | try {
332 | return cb(jq.copy(driver = driver).root())
333 | } finally {
334 | driver.close()
335 | }
336 | }
337 |
338 | override fun withFrame(selector: String, fn: IEl.() -> T): T {
339 | val dr = (jq.driver as WebDriver)
340 | val frame = find(selector).element()
341 | val driver = dr.switchTo().frame(frame) as RemoteWebDriver
342 | try {
343 | return fn(jq.copy(driver = driver).root())
344 | } finally {
345 | driver.close()
346 | }
347 | }
348 |
349 | override fun waitUntil(message: String, fn: IEl.() -> Boolean): IEl {
350 | val msg = "Timeout waiting for $message on ${renderScript()}"
351 | jq.waitForNonNull(msg) {
352 | if (!fn(this)) {
353 | throw RetryException(msg)
354 | }
355 | }
356 | return this
357 | }
358 |
359 | override fun waitFor(message: String, fn: IEl.() -> T?): T {
360 | return jq.waitForNonNull(message) {
361 | fn(this) ?: throw RetryException("Timeout waiting for $message on ${renderScript()}")
362 | }
363 | }
364 | }
365 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/iodesystems/selenium/el/IEl.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium.el
2 |
3 | import com.iodesystems.selenium.jQuery
4 | import org.openqa.selenium.interactions.Actions
5 | import org.openqa.selenium.remote.RemoteWebDriver
6 | import org.openqa.selenium.remote.RemoteWebElement
7 |
8 | interface IEl {
9 | fun data(key: String): String?
10 | fun attr(key: String): String?
11 |
12 | fun actions(): Actions
13 | fun atLeast(): Int?
14 | fun atMost(): Int?
15 | fun one(): IEl
16 | fun click(): IEl
17 | fun clear(): IEl
18 | fun blur(): IEl
19 | fun text(): String
20 | fun sendKeys(text: CharSequence, rateMillis: Int? = null): IEl
21 | fun withDriver(remoteWebDriver: RemoteWebDriver): IEl
22 | fun refine(refineSelector: String): IEl
23 | fun contains(text: String): IEl
24 | fun value(): String
25 | fun gone()
26 | fun exists()
27 | fun visible(): IEl
28 | fun enabled(): IEl
29 | fun disabled(): IEl
30 | fun maybeExists(): Boolean
31 | fun ifExists(fn: IEl.() -> T): T?
32 | fun element(): RemoteWebElement
33 | fun elementsUnChecked(): List
34 | fun elements(): List
35 | fun renderScript(): String
36 | fun renderSelector(): String
37 | fun scrollIntoView(): IEl
38 | fun screenshot(destinationFile: String): IEl
39 |
40 | // Generic child finder
41 | fun findAll(childSelector: String, atLeast: Int? = 1, atMost: Int? = null): IEl
42 | fun findAll(childSelector: List, atLeast: Int? = 1, atMost: Int? = null): IEl
43 |
44 | // Single child finders
45 | fun find(childSelector: List, fn: IEl.() -> T): T
46 | fun find(childSelector: String, fn: IEl.() -> T): T
47 | fun find(childSelector: List): IEl
48 | fun find(childSelector: String): IEl
49 | fun require(atMost: Int?, atLeast: Int?): IEl
50 |
51 | // Parent finders
52 | fun parent(parentSelector: String, atLeast: Int? = 1, atMost: Int? = 1): IEl
53 | fun parent(parentSelector: List, atLeast: Int? = 1, atMost: Int? = 1): IEl
54 |
55 | fun first(first: String, vararg rest: String): IEl
56 | fun first(first: IEl, vararg rest: IEl): IEl
57 | fun escape(string: String): String
58 |
59 | fun first(): IEl
60 | fun selectValue(value: String): IEl
61 | fun last(): IEl
62 | fun reroot(selector: String? = null): IEl
63 | fun withTab(label: String, cb: IEl.() -> T): T
64 | fun withFrame(selector: String, fn: IEl.() -> T): T
65 | fun waitUntil(message: String = "condition to be true", fn: IEl.() -> Boolean): IEl
66 | fun waitFor(message: String = "expression to be nonnull", fn: IEl.() -> T?): T
67 | fun js(script: String, vararg args: Any?): Any?
68 |
69 | val jq: jQuery
70 | val selector: List
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/iodesystems/selenium/el/IElExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium.el
2 |
3 | object IElExtensions {
4 | fun IEl.button(text: String): IEl {
5 | return find("button").icontains(text)
6 | }
7 |
8 | fun IEl.link(text: String): IEl {
9 | return find("a").icontains(text)
10 | }
11 |
12 | fun IEl.linkTo(href: String): IEl {
13 | return find("a[href='$href']")
14 | }
15 |
16 | fun IEl.waitForPageLoaded() {
17 | waitFor("document.readyState === 'complete'") {
18 | if (js("return document.readyState") == "complete") true else null
19 | }
20 | }
21 |
22 | fun IEl.icontains(text: String): IEl {
23 | return refine(":icontains(${jq.escape(text)})")
24 | }
25 |
26 |
27 | fun IEl.not(selector: String): IEl {
28 | return refine(":not($selector)")
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/iodesystems/selenium/exceptions/RetryException.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium.exceptions
2 |
3 | class RetryException(
4 | message: String, cause: Throwable? = null
5 | ) : Exception(message, cause)
6 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/iodesystems/selenium/exceptions/SearchNotFoundException.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium.exceptions
2 |
3 | class SearchNotFoundException(
4 | message: String, cause: Throwable? = null
5 | ) : Exception(message, cause)
6 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/iodesystems/selenium/jQuery.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium
2 |
3 | import com.iodesystems.selenium.el.El
4 | import com.iodesystems.selenium.el.IEl
5 | import com.iodesystems.selenium.exceptions.RetryException
6 | import org.openqa.selenium.JavascriptException
7 | import org.openqa.selenium.NoSuchWindowException
8 | import org.openqa.selenium.ScriptTimeoutException
9 | import org.openqa.selenium.StaleElementReferenceException
10 | import org.openqa.selenium.remote.RemoteWebDriver
11 | import org.openqa.selenium.remote.RemoteWebElement
12 | import org.openqa.selenium.support.ui.FluentWait
13 | import java.io.ByteArrayOutputStream
14 | import java.io.Closeable
15 | import java.time.Duration
16 |
17 |
18 | data class jQuery(
19 | val driver: RemoteWebDriver,
20 | val timeout: Duration = Duration.ofSeconds(5),
21 | val logQueriesToBrowser: Boolean = false,
22 | val logQueriesToStdout: Boolean = false,
23 | val onInstallScript: String? = null,
24 | ) : Closeable {
25 | private fun install() {
26 | val shouldRunOnInstallScript = mapOf(
27 | "jQuery" to "jquery-3.7.1.slim.min.js",
28 | "SeleniumJQuery" to "selenium-jquery-helpers.js"
29 | ).map { entry ->
30 | if (logQueriesToStdout) {
31 | println("Installing ${entry.key} from ${entry.value}")
32 | }
33 | if (driver.executeScript("return typeof window.${entry.key}") == "undefined") {
34 | val jQueryStream = javaClass.getResourceAsStream("/${entry.value}")
35 | val jQueryStreamBuffer = ByteArrayOutputStream()
36 | jQueryStream?.transferTo(jQueryStreamBuffer)
37 | val jQueryContent = jQueryStreamBuffer.toString()
38 | driver.executeScript(jQueryContent)
39 | true
40 | } else {
41 | false
42 | }
43 | }.any { it }
44 | if (shouldRunOnInstallScript && onInstallScript != null) {
45 | driver.executeScript(onInstallScript)
46 | }
47 | }
48 |
49 | fun escape(string: String): String {
50 | return '"' + string.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r") + '"'
51 | }
52 |
53 | fun search(els: List): List?> {
54 | return waitForNonNull("Search query to return stable results") {
55 | try {
56 | if (logQueriesToStdout) {
57 | println(els.joinToString("; ") { it.renderScript() } + ";")
58 | }
59 | @Suppress("UNCHECKED_CAST")
60 | driver.executeAsyncScript(
61 | "SeleniumJQuery.search(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])",
62 | logQueriesToBrowser,
63 | els.map { it.renderSelector() },
64 | els.map { it.atLeast() },
65 | els.map { it.atMost() }
66 | ) as List?>
67 | } catch (e: StaleElementReferenceException) {
68 | throw RetryException("Stale element returned", e)
69 | } catch (e: ScriptTimeoutException) {
70 | // Render message and selectors
71 | val messages = els.joinToString(", ") { el ->
72 | val message = when (el.atMost()) {
73 | 0 -> "not present"
74 | null -> when (el.atLeast()) {
75 | 0 -> "present"
76 | null -> "present"
77 | else -> "at least ${el.atLeast()} elements"
78 | }
79 |
80 | else -> when (el.atLeast()) {
81 | 0 -> "at most ${el.atMost()} elements"
82 | null -> "at most ${el.atMost()} elements"
83 | else -> "between ${el.atLeast()} and ${el.atMost()} elements"
84 | }
85 | }
86 | el.renderSelector() + " to be $message)"
87 | }
88 | throw RetryException("Timeout waiting for $messages", e)
89 | }
90 | }
91 | }
92 |
93 | fun waitForJsTrue(
94 | script: String,
95 | message: String = "script to return true",
96 | retryDelay: Duration? = null,
97 | timeOut: Duration? = null
98 | ) {
99 | waitForNonNull(message, retry = retryDelay, timeOut = timeOut) {
100 | when (val result = driver.executeScript(script)) {
101 | is Boolean -> if (!result) {
102 | throw RetryException("Script returned false")
103 | } else {
104 | true
105 | }
106 |
107 | else -> throw RetryException("Script did not return a boolean")
108 | }
109 | }
110 | }
111 |
112 | fun waitForNonNull(
113 | failureMessage: String,
114 | retry: Duration? = null,
115 | timeOut: Duration? = null,
116 | t: () -> T
117 | ): T {
118 | return FluentWait(driver)
119 | .withTimeout(timeOut ?: timeout)
120 | .pollingEvery(retry ?: Duration.ofMillis(10))
121 | .withMessage(failureMessage)
122 | .ignoring(RetryException::class.java).until {
123 | try {
124 | t()
125 | } catch (_: JavascriptException) {
126 | install()
127 | t()
128 | }
129 | }
130 | }
131 |
132 | fun go(url: String): El {
133 | if (url.startsWith("/")) {
134 | val baseUrl = try {
135 | driver.currentUrl?.split("/")?.take(3)?.joinToString("/")
136 | } catch (e: NoSuchWindowException) {
137 | val handles = driver.windowHandles
138 | if (handles.isEmpty()) throw e
139 | // Close other handles
140 | handles.drop(1).forEach {
141 | driver.switchTo().window(it).close()
142 | }
143 | // Switch to the first
144 | driver.switchTo().window(handles.first())
145 | driver.currentUrl
146 | }
147 | if (baseUrl != null) {
148 | return go("$baseUrl$url")
149 | } else {
150 | throw IllegalStateException("No base url found, cannot prepend / to $url")
151 | }
152 | }
153 | driver.get(url)
154 | return root()
155 | }
156 |
157 | fun go(url: String, fn: El.() -> T): T {
158 | return go(url).fn()
159 | }
160 |
161 | fun root(): El {
162 | return El(jq = this, selector = listOf())
163 | }
164 |
165 | override fun close() {
166 | driver.close()
167 | driver.quit()
168 | }
169 |
170 | fun navigate(): Navigate {
171 | return Navigate(driver)
172 | }
173 |
174 | data class Navigate(
175 | private val driver: RemoteWebDriver
176 | ) {
177 |
178 | fun back() {
179 | driver.navigate().back()
180 | }
181 |
182 | fun forward() {
183 | driver.navigate().forward()
184 | }
185 |
186 | fun refresh() {
187 | driver.navigate().refresh()
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/src/main/resources/jquery-3.7.1.slim.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v3.7.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-deprecated/ajax-event-alias,-effects,-effects/animatedSelector,-effects/Tween | (c) OpenJS Foundation and other contributors | jquery.org/license */
2 | !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},m=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||m).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-deprecated/ajax-event-alias,-effects,-effects/animatedSelector,-effects/Tween",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+ge+")"+ge+"*"),b=new RegExp(ge+"|>"),A=new RegExp(g),D=new RegExp("^"+t+"$"),N={ID:new RegExp("^#("+t+")"),CLASS:new RegExp("^\\.("+t+")"),TAG:new RegExp("^("+t+"|[*])"),ATTR:new RegExp("^"+d),PSEUDO:new RegExp("^"+g),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ge+"*(even|odd|(([+-]|)(\\d*)n|)"+ge+"*(?:([+-]|)"+ge+"*(\\d+)|))"+ge+"*\\)|)","i"),bool:new RegExp("^(?:"+f+")$","i"),needsContext:new RegExp("^"+ge+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ge+"*((?:-\\d)?\\d*)"+ge+"*\\)|)(?=[^-]|$)","i")},L=/^(?:input|select|textarea|button)$/i,j=/^h\d$/i,O=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,P=/[+~]/,H=new RegExp("\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\([^\\r\\n\\f])","g"),q=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},R=function(){V()},M=K(function(e){return!0===e.disabled&&fe(e,"fieldset")},{dir:"parentNode",next:"legend"});try{E.apply(oe=ae.call(ye.childNodes),ye.childNodes),oe[ye.childNodes.length].nodeType}catch(e){E={apply:function(e,t){me.apply(e,ae.call(t))},call:function(e){me.apply(e,ae.call(arguments,1))}}}function I(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,d=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==d&&9!==d&&11!==d)return n;if(!r&&(V(e),e=e||C,T)){if(11!==d&&(u=O.exec(t)))if(i=u[1]){if(9===d){if(!(a=e.getElementById(i)))return n;if(a.id===i)return E.call(n,a),n}else if(f&&(a=f.getElementById(i))&&I.contains(e,a)&&a.id===i)return E.call(n,a),n}else{if(u[2])return E.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&e.getElementsByClassName)return E.apply(n,e.getElementsByClassName(i)),n}if(!(h[t+" "]||p&&p.test(t))){if(c=t,f=e,1===d&&(b.test(t)||m.test(t))){(f=P.test(t)&&X(e.parentNode)||e)==e&&le.scope||((s=e.getAttribute("id"))?s=ce.escapeSelector(s):e.setAttribute("id",s=k)),o=(l=Y(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+G(l[o]);c=l.join(",")}try{return E.apply(n,f.querySelectorAll(c)),n}catch(e){h(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return re(t.replace(ve,"$1"),e,n,r)}function W(){var r=[];return function e(t,n){return r.push(t+" ")>x.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function B(e){return e[k]=!0,e}function F(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function $(t){return function(e){return fe(e,"input")&&e.type===t}}function _(t){return function(e){return(fe(e,"input")||fe(e,"button"))&&e.type===t}}function z(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&M(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function U(a){return B(function(o){return o=+o,B(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function X(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function V(e){var t,n=e?e.ownerDocument||e:ye;return n!=C&&9===n.nodeType&&n.documentElement&&(r=(C=n).documentElement,T=!ce.isXMLDoc(C),i=r.matches||r.webkitMatchesSelector||r.msMatchesSelector,r.msMatchesSelector&&ye!=C&&(t=C.defaultView)&&t.top!==t&&t.addEventListener("unload",R),le.getById=F(function(e){return r.appendChild(e).id=ce.expando,!C.getElementsByName||!C.getElementsByName(ce.expando).length}),le.disconnectedMatch=F(function(e){return i.call(e,"*")}),le.scope=F(function(){return C.querySelectorAll(":scope")}),le.cssHas=F(function(){try{return C.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),le.getById?(x.filter.ID=function(e){var t=e.replace(H,q);return function(e){return e.getAttribute("id")===t}},x.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&T){var n=t.getElementById(e);return n?[n]:[]}}):(x.filter.ID=function(e){var n=e.replace(H,q);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},x.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&T){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),x.find.TAG=function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},x.find.CLASS=function(e,t){if("undefined"!=typeof t.getElementsByClassName&&T)return t.getElementsByClassName(e)},p=[],F(function(e){var t;r.appendChild(e).innerHTML="",e.querySelectorAll("[selected]").length||p.push("\\["+ge+"*(?:value|"+f+")"),e.querySelectorAll("[id~="+k+"-]").length||p.push("~="),e.querySelectorAll("a#"+k+"+*").length||p.push(".#.+[+~]"),e.querySelectorAll(":checked").length||p.push(":checked"),(t=C.createElement("input")).setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),r.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&p.push(":enabled",":disabled"),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||p.push("\\["+ge+"*name"+ge+"*="+ge+"*(?:''|\"\")")}),le.cssHas||p.push(":has"),p=p.length&&new RegExp(p.join("|")),l=function(e,t){if(e===t)return a=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!le.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument==ye&&I.contains(ye,e)?-1:t===C||t.ownerDocument==ye&&I.contains(ye,t)?1:o?se.call(o,e)-se.call(o,t):0:4&n?-1:1)}),C}for(e in I.matches=function(e,t){return I(e,null,null,t)},I.matchesSelector=function(e,t){if(V(e),T&&!h[t+" "]&&(!p||!p.test(t)))try{var n=i.call(e,t);if(n||le.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){h(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(H,q),e[3]=(e[3]||e[4]||e[5]||"").replace(H,q),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||I.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&I.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return N.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&A.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(H,q).toLowerCase();return"*"===e?function(){return!0}:function(e){return fe(e,t)}},CLASS:function(e){var t=s[e+" "];return t||(t=new RegExp("(^|"+ge+")"+e+"("+ge+"|$)"))&&s(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=I.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(e,n,r){return v(n)?ce.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?ce.grep(e,function(e){return e===n!==r}):"string"!=typeof n?ce.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(ce.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||E,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:k.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ce?t[0]:t,ce.merge(this,ce.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:m,!0)),C.test(r[1])&&ce.isPlainObject(t))for(r in t)v(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=m.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(ce):ce.makeArray(e,this)}).prototype=ce.fn,E=ce(m);var S=/^(?:parents|prev(?:Until|All))/,A={children:!0,contents:!0,next:!0,prev:!0};function D(e,t){while((e=e[t])&&1!==e.nodeType);return e}ce.fn.extend({has:function(e){var t=ce(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,Ce=/^$|^module$|\/(?:java|ecma)script/i;re=m.createDocumentFragment().appendChild(m.createElement("div")),(be=m.createElement("input")).setAttribute("type","radio"),be.setAttribute("checked","checked"),be.setAttribute("name","t"),re.appendChild(be),le.checkClone=re.cloneNode(!0).cloneNode(!0).lastChild.checked,re.innerHTML="",le.noCloneChecked=!!re.cloneNode(!0).lastChild.defaultValue,re.innerHTML="",le.option=!!re.lastChild;var Te={thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};function Ee(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&fe(e,t)?ce.merge([e],n):n}function ke(e,t){for(var n=0,r=e.length;n",""]);var Se=/<|?\w+;/;function Ae(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),d=[],p=0,h=e.length;p\s*$/g;function Re(e,t){return fe(e,"table")&&fe(11!==t.nodeType?t:t.firstChild,"tr")&&ce(e).children("tbody")[0]||e}function Me(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Ie(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function We(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(_.hasData(e)&&(s=_.get(e).events))for(i in _.remove(t,"handle events"),s)for(n=0,r=s[i].length;n",2===yt.childNodes.length),ce.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(le.createHTMLDocument?((r=(t=m.implementation.createHTMLDocument("")).createElement("base")).href=m.location.href,t.head.appendChild(r)):t=m),o=!n&&[],(i=C.exec(e))?[t.createElement(i[1])]:(i=Ae([e],t,o),o&&o.length&&ce(o).remove(),ce.merge([],i.childNodes)));var r,i,o},ce.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=ce.css(e,"position"),c=ce(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=ce.css(e,"top"),u=ce.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),v(t)&&(t=t.call(e,n,ce.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},ce.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ce.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===ce.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===ce.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=ce(e).offset()).top+=ce.css(e,"borderTopWidth",!0),i.left+=ce.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-ce.css(r,"marginTop",!0),left:t.left-i.left-ce.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===ce.css(e,"position"))e=e.offsetParent;return e||K})}}),ce.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;ce.fn[t]=function(e){return R(this,function(e,t,n){var r;if(y(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),ce.each(["top","left"],function(e,n){ce.cssHooks[n]=Qe(le.pixelPosition,function(e,t){if(t)return t=Ve(e,n),$e.test(t)?ce(e).position()[n]+"px":t})}),ce.each({Height:"height",Width:"width"},function(a,s){ce.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){ce.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return R(this,function(e,t,n){var r;return y(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?ce.css(e,t,i):ce.style(e,t,n,i)},s,n?e:void 0,n)}})}),ce.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)}}),ce.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){ce.fn[n]=function(e,t){return 0= 0
4 | }
5 | })
6 |
7 | window.SeleniumJQuery = {
8 | searches: [],
9 | log: false,
10 | minLength: null,
11 | maxLength: null,
12 | observer: null,
13 | debounce: null,
14 | observeNow: function () {
15 | const foundSearches = []
16 | for (let i = 0; i < SeleniumJQuery.searches.length; i++) {
17 | const search = SeleniumJQuery.searches[i]
18 | const foundItems = []
19 | let foundCallback = null
20 | for (let j = 0; j < search.length; j++) {
21 | const item = search[j]
22 | const found = jQuery(item.query)
23 |
24 | // Constraints
25 | if (item.atLeast != null && (found.length < item.atLeast)) {
26 | foundItems.push(null)
27 | if (SeleniumJQuery.log) console.log('Not enough items for', item.query, 'found', found.length, 'atLeast', item.atLeast)
28 | continue
29 | }
30 | if (item.atMost != null && (found.length > item.atMost)) {
31 | foundItems.push(null)
32 | if (SeleniumJQuery.log) console.log('Too many items for', item.query, "found", found.length)
33 | continue
34 | }
35 | foundCallback = item.callback
36 | foundItems.push(found.toArray())
37 | }
38 | if (foundCallback) {
39 | if (SeleniumJQuery.log) console.log('Found search group', search.map(s=>s.query).join(", "), foundItems.length)
40 | foundSearches.push({
41 | search,
42 | foundItems,
43 | foundCallback
44 | })
45 | } else {
46 | if (SeleniumJQuery.log) console.log('Did not find search group', search.map(s=>s.query).join(", "))
47 | }
48 | }
49 | for (let i = 0; i < foundSearches.length; i++) {
50 | const group = foundSearches[i]
51 | setTimeout(() => {group.foundCallback(group.foundItems)}, 1)
52 | SeleniumJQuery.searches.splice(SeleniumJQuery.searches.indexOf(group.search), 1)
53 | }
54 | },
55 | observe: function () {
56 | if (SeleniumJQuery.debounce) clearTimeout(SeleniumJQuery.debounce)
57 | if (SeleniumJQuery.searches.length === 0) return
58 | SeleniumJQuery.debounce = setTimeout(SeleniumJQuery.observeNow, 1)
59 | },
60 |
61 | search: function (log, queries, atLeasts, atMosts, callback) {
62 | SeleniumJQuery.log = log
63 | if (SeleniumJQuery.observer == null) {
64 | SeleniumJQuery.observer = new MutationObserver(SeleniumJQuery.observe)
65 | SeleniumJQuery.observer.observe(document.documentElement || document.body, {
66 | attributes: true,
67 | childList: true,
68 | subtree: true,
69 | })
70 | }
71 | SeleniumJQuery.searches.push(queries.map(function (query, index) {
72 | return {
73 | query: query,
74 | atLeast: atLeasts[index],
75 | atMost: atMosts[index],
76 | callback: callback
77 | }
78 | }))
79 | SeleniumJQuery.observe()
80 | }
81 | }
82 | SeleniumJQuery.searches = []
83 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/iodesystems/selenium/jQueryTest.kt:
--------------------------------------------------------------------------------
1 | package com.iodesystems.selenium
2 |
3 | import com.iodesystems.selenium.el.IElExtensions.icontains
4 | import io.github.bonigarcia.wdm.WebDriverManager
5 | import org.apache.commons.io.output.NullOutputStream
6 | import org.junit.Test
7 | import org.openqa.selenium.Keys
8 | import org.openqa.selenium.OutputType
9 | import org.openqa.selenium.PageLoadStrategy
10 | import org.openqa.selenium.chrome.ChromeDriver
11 | import org.openqa.selenium.chrome.ChromeDriverService
12 | import org.openqa.selenium.chrome.ChromeOptions
13 | import org.openqa.selenium.logging.LogType
14 | import org.openqa.selenium.logging.LoggingPreferences
15 | import java.io.File
16 | import java.io.PrintWriter
17 | import java.io.StringWriter
18 | import java.lang.reflect.InvocationTargetException
19 | import java.nio.file.Files
20 | import java.nio.file.StandardCopyOption
21 | import java.time.Duration
22 | import java.time.OffsetDateTime
23 | import java.time.format.DateTimeFormatter
24 | import java.util.logging.Level
25 | import kotlin.test.assertEquals
26 | import kotlin.test.assertTrue
27 |
28 |
29 | class jQueryTest {
30 |
31 | fun cause(ex: Throwable): Throwable {
32 | var e = when (ex) {
33 | is InvocationTargetException ->
34 | ex.targetException
35 |
36 | else -> ex
37 | }
38 | while (e.cause != null && e.cause != e) {
39 | e = e.cause!!
40 | when (e) {
41 | is InvocationTargetException ->
42 | e = e.targetException
43 | }
44 | }
45 | return e
46 | }
47 |
48 | fun subject(fn: (jq: jQuery) -> Unit) {
49 | WebDriverManager.chromedriver().setup()
50 | val chromeDriverService: ChromeDriverService = ChromeDriverService.Builder()
51 | .withSilent(true)
52 | .build()
53 | chromeDriverService.sendOutputTo(NullOutputStream.INSTANCE)
54 | val options = ChromeOptions()
55 | options.addArguments("--auto-open-devtools-for-tabs")
56 | options.addArguments("--remote-allow-origins=*")
57 | // If you want to see the browser, comment this out
58 | // options.addArguments("--headless=new").addArguments("window-size=1920,1080")
59 | val logPrefs = LoggingPreferences()
60 | logPrefs.enable(LogType.BROWSER, Level.ALL)
61 | options.setCapability("goog:loggingPrefs", logPrefs)
62 | options.setPageLoadStrategy(PageLoadStrategy.EAGER)
63 | val driver = ChromeDriver(chromeDriverService, options)
64 | driver.manage().timeouts().apply {
65 | scriptTimeout(Duration.ofSeconds(5))
66 | }
67 | val jq = jQuery(
68 | driver,
69 | logQueriesToBrowser = true,
70 | logQueriesToStdout = true
71 | )
72 | try {
73 | fn(jq)
74 | } catch (ex: Throwable) {
75 | val e = cause(ex)
76 | val sb = StringWriter()
77 | e.printStackTrace(PrintWriter(sb))
78 | val banned = listOf(
79 | "java.base/java.lang.reflect",
80 | "org.openqa.selenium.remote.codec",
81 | "org.openqa.selenium.remote.RemoteWebElement.execute",
82 | "org.openqa.selenium.remote.service.DriverCommandExecutor",
83 | "org.springframework.aop",
84 | "org.openqa.selenium.remote.RemoteWebDriver.execute",
85 | "org.openqa.selenium.remote.HttpCommandExecutor.execute",
86 | "org.openqa.selenium.support.ui.FluentWait",
87 | "com.iodesystems.selenium.jQuery\$waitFor",
88 | "com.iodesystems.selenium.jQuery.waitFor",
89 | "org.springframework.test",
90 | "\$El",
91 | "\$IEl",
92 | "\$Factory"
93 | )
94 | val stack = sb.toString().lines().filter { line ->
95 | banned.find { ban -> line.contains(ban) } == null
96 | }.joinToString("\n")
97 | val onUrl = "On url: " + driver.currentUrl
98 | val tmp = File.createTempFile(
99 | "screenshot-" + OffsetDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME), ".png"
100 | )
101 | Files.move(
102 | driver.getScreenshotAs(OutputType.FILE).absoluteFile.toPath(),
103 | tmp.toPath(),
104 | StandardCopyOption.REPLACE_EXISTING
105 | )
106 | val screenshot = "See a screenshot at file://" + tmp.absoluteFile
107 | val message = e.message + """
108 | $onUrl
109 | $screenshot
110 | With a simplified stack:
111 | """.trimIndent() + stack
112 | jq.root().sendKeys(Keys.chord(Keys.COMMAND, Keys.CONTROL, "j"))
113 | println(message)
114 | println("Browser Logs:")
115 | val logs = jq.driver.manage().logs()
116 | println(logs.availableLogTypes.map { logger ->
117 | logs.get(logger)
118 | }
119 | .flatten()
120 | .filter { line -> line.message.contains("The user aborted a request") }
121 | .joinToString("\n"))
122 | assert(false)
123 | } finally {
124 | driver.quit()
125 | }
126 | }
127 |
128 | @Test
129 | fun testRootFind() {
130 | subject { jq ->
131 | val el = jq.root()
132 | assertTrue(el.selector.isEmpty(), "Selector should be empty")
133 | el.find("body") {
134 | assertEquals(
135 | selector,
136 | listOf("body")
137 | )
138 | find(listOf("a", "b")) {
139 | assertEquals(
140 | selector,
141 | listOf(
142 | "body a",
143 | "body b"
144 | )
145 | )
146 | }
147 | }
148 | }
149 | }
150 |
151 | @Test
152 | fun testGoogleSearch() {
153 | subject { jq ->
154 | jq.go("http://google.com") {
155 | icontains("GOOGLE").exists()
156 | contains("GOOGLE").gone()
157 | find("textarea[name='q']").sendKeys("hello world", 30)
158 | find("input[value='Google Search']").first().click()
159 | }
160 | }
161 | }
162 | }
163 |
164 |
--------------------------------------------------------------------------------
/versions.properties:
--------------------------------------------------------------------------------
1 | #### Dependencies and Plugin versions with their available updates.
2 | #### Generated by `./gradlew refreshVersions` version 0.60.5
3 | ####
4 | #### Don't manually edit or split the comments that start with four hashtags (####),
5 | #### they will be overwritten by refreshVersions.
6 | ####
7 | #### suppress inspection "SpellCheckingInspection" for whole file
8 | #### suppress inspection "UnusedProperty" for whole file
9 |
10 | plugin.io.github.gradle-nexus.publish-plugin=2.0.0
11 |
12 | ## unused
13 | version.junit.junit=4.13.2
14 |
15 | ## unused
16 | version.org.seleniumhq.selenium..selenium-support=4.30.0
17 |
18 | ## unused
19 | version.org.seleniumhq.selenium..selenium-remote-driver=4.30.0
20 |
21 | ## unused
22 | version.org.seleniumhq.selenium..selenium-chrome-driver=4.30.0
23 |
24 | ## unused
25 | version.org.jetbrains.dokka..templating-plugin=2.0.0
26 |
27 | ## unused
28 | version.org.jetbrains.dokka..javadoc-plugin=2.0.0
29 |
30 | ## unused
31 | version.org.jetbrains.dokka..dokka-core=2.0.0
32 |
33 | ## unused
34 | version.org.jetbrains.dokka..dokka-base=2.0.0
35 |
36 | ## unused
37 | version.org.jetbrains.dokka..analysis-kotlin-descriptors=2.0.0
38 |
39 | ## unused
40 | version.org.bouncycastle..bcprov-jdk18on=1.80
41 |
42 | ## unused
43 | version.io.github.bonigarcia..webdrivermanager=6.0.0
44 |
45 | ## unused
46 | version.commons-io..commons-io=2.18.0
47 |
48 | ## unused
49 | version.com.fasterxml.jackson.core..jackson-databind=2.18.3
50 |
51 | plugin.org.jetbrains.dokka-javadoc=2.0.0
52 |
53 | ## unused
54 | plugin.org.jetbrains.dokka=2.0.0
55 |
56 | version.kotlin=2.1.20
57 |
--------------------------------------------------------------------------------