Module: Appom::Retry::RetryMethods
- Included in:
- Helpers::ElementHelpers, Helpers::WaitHelpers
- Defined in:
- lib/appom/retry.rb
Overview
Mixin for adding retry capabilities to classes
Instance Method Summary collapse
-
#find_with_retry(element_name, **retry_options) ⇒ Object
Retry element finding with exponential backoff.
-
#get_text_with_retry(element_name, **retry_options) ⇒ Object
Retry getting element text.
-
#interact_with_retry(element_name, action = :tap, **retry_options) ⇒ Object
Retry element interaction (tap, click, etc.).
-
#wait_for_state_with_retry(element_name, state = :displayed, **retry_options) ⇒ Object
Retry waiting for element state.
Instance Method Details
#find_with_retry(element_name, **retry_options) ⇒ Object
Retry element finding with exponential backoff
65 66 67 68 69 70 71 |
# File 'lib/appom/retry.rb', line 65 def find_with_retry(element_name, **) config = build_retry_config() Appom::Retry.with_retry(config) do send(element_name) end end |
#get_text_with_retry(element_name, **retry_options) ⇒ Object
Retry getting element text
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/appom/retry.rb', line 85 def get_text_with_retry(element_name, **) config = build_retry_config() Appom::Retry.with_retry(config) do element = send(element_name) text = element.text # Validate text if validation block provided raise Appom::ElementStateError.new(element_name, 'valid text', text) if [:validate_text] && ![:validate_text].call(text) text end end |
#interact_with_retry(element_name, action = :tap, **retry_options) ⇒ Object
Retry element interaction (tap, click, etc.)
74 75 76 77 78 79 80 81 82 |
# File 'lib/appom/retry.rb', line 74 def interact_with_retry(element_name, action = :tap, **) config = build_retry_config() Appom::Retry.with_retry(config) do element = send(element_name) perform_element_action(element, action, ) element end end |
#wait_for_state_with_retry(element_name, state = :displayed, **retry_options) ⇒ Object
Retry waiting for element state
100 101 102 103 104 105 106 107 108 |
# File 'lib/appom/retry.rb', line 100 def wait_for_state_with_retry(element_name, state = :displayed, **) config = build_retry_config() Appom::Retry.with_retry(config) do element = send(element_name) validate_element_state(element, element_name, state) element end end |