Module: Appom::ElementFinder
Instance Method Summary collapse
-
#_all(*find_args) ⇒ Object
Find elements.
-
#_find(*find_args) ⇒ Object
Find an element.
-
#wait_check_until_empty(*find_args) ⇒ Object
Use wait to check element non-exist Before timeout we will try to find elements and check response is empty.
-
#wait_check_until_not_empty(*find_args) ⇒ Object
Use wait to check element exist Before timeout we will try to find elements and check response is not empty.
-
#wait_until_element_disabled(*find_args) ⇒ Object
Wait until an element will be disable.
-
#wait_until_element_enabled(*find_args) ⇒ Object
Wait until an element will be enable.
-
#wait_until_get_not_empty(*find_args) ⇒ Object
Use wait to get elements Before timeout we will try to find elements until response is not empty.
Instance Method Details
#_all(*find_args) ⇒ Object
Find elements
10 11 12 |
# File 'lib/appom/element_finder.rb', line 10 def _all(*find_args) page.find_elements(*find_args) end |
#_find(*find_args) ⇒ Object
Find an element
4 5 6 7 |
# File 'lib/appom/element_finder.rb', line 4 def _find(*find_args) wait = Wait.new(timeout: Appom.max_wait_time) wait.until { page.find_element(*find_args) } end |
#wait_check_until_empty(*find_args) ⇒ Object
Use wait to check element non-exist Before timeout we will try to find elements and check response is empty
18 19 20 21 22 23 |
# File 'lib/appom/element_finder.rb', line 18 def wait_check_until_empty(*find_args) wait = Wait.new(timeout: Appom.max_wait_time) wait.until do page.find_elements(*find_args).empty? end end |
#wait_check_until_not_empty(*find_args) ⇒ Object
Use wait to check element exist Before timeout we will try to find elements and check response is not empty
29 30 31 32 33 34 |
# File 'lib/appom/element_finder.rb', line 29 def wait_check_until_not_empty(*find_args) wait = Wait.new(timeout: Appom.max_wait_time) wait.until do !page.find_elements(*find_args).empty? end end |
#wait_until_element_disabled(*find_args) ⇒ Object
Wait until an element will be disable
64 65 66 67 |
# File 'lib/appom/element_finder.rb', line 64 def wait_until_element_disabled(*find_args) wait = Wait.new(timeout: Appom.max_wait_time) wait.until { !page.find_element(*find_args).enabled? } end |
#wait_until_element_enabled(*find_args) ⇒ Object
Wait until an element will be enable
56 57 58 59 |
# File 'lib/appom/element_finder.rb', line 56 def wait_until_element_enabled(*find_args) wait = Wait.new(timeout: Appom.max_wait_time) wait.until { page.find_element(*find_args).enabled? } end |
#wait_until_get_not_empty(*find_args) ⇒ Object
Use wait to get elements Before timeout we will try to find elements until response is not empty
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/appom/element_finder.rb', line 40 def wait_until_get_not_empty(*find_args) wait = Wait.new(timeout: Appom.max_wait_time) wait.until do result = page.find_elements(*find_args) # If reponse is empty we will return false to make it not pass Wait condition if result.empty? raise Appom::ElementsEmptyError, "Array is empty" end # Return result return result end end |