Class: Spreewald::FieldErrorFinder
Instance Method Summary
collapse
#without_waiting
Methods included from DriverInfo
#browser, #javascript_capable?, #poltergeist_driver?, #require_selenium!, #selenium_driver?, #webkit_driver?
Constructor Details
Returns a new instance of FieldErrorFinder.
27
28
29
30
|
# File 'lib/spreewald_support/field_errors.rb', line 27
def initialize(page, element)
@page = page
@element = element
end
|
Instance Method Details
#bootstrap3_error? ⇒ Boolean
46
47
48
49
50
|
# File 'lib/spreewald_support/field_errors.rb', line 46
def bootstrap3_error?
has_xpath? do |x|
x.ancestor(:div)[x.attr(:class).contains_word('form-group')][x.attr(:class).contains_word('has-error')]
end
end
|
#bootstrap45_error? ⇒ Boolean
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/spreewald_support/field_errors.rb', line 52
def bootstrap45_error?
without_waiting do
element_classes = @element[:class]&.split(' ') || []
invalid_elements = if javascript_capable?
@page.all(':invalid')
end
element_classes.include?('is-invalid') || (invalid_elements && invalid_elements.include?(@element))
end
end
|
#custom_error? ⇒ Boolean
38
39
40
41
42
43
44
|
# File 'lib/spreewald_support/field_errors.rb', line 38
def custom_error?
return false unless Spreewald.field_error_class
has_xpath? do |x|
x.ancestor_or_self(:div)[x.attr(:class).contains_word(Spreewald.field_error_class)]
end
end
|
#error_present? ⇒ Boolean
32
33
34
35
36
|
# File 'lib/spreewald_support/field_errors.rb', line 32
def error_present?
without_waiting do
custom_error? || bootstrap3_error? || bootstrap45_error? || rails_error?
end
end
|
#rails_error? ⇒ Boolean
63
64
65
66
67
|
# File 'lib/spreewald_support/field_errors.rb', line 63
def rails_error?
has_xpath? do |x|
x.ancestor(:div)[x.attr(:class).contains_word('field_with_errors')]
end
end
|