Add tomselect_select helper

When using `tomselect_search_and_select` and searching isn't really
required it leaves the dropdown option open. It can then cause problem
when trying to interact with other element in the page. This happens
because clicking on the chosen option happena before the searching
finishes.
We can now use `tomselect_select` when searching is not actually
required.
It should not be a problem when search is required, as capybara will
wait for the option to appear on the page before clicking.
This commit is contained in:
Gaetan Craig-Riou
2024-01-24 14:47:21 +11:00
parent 270a310e0f
commit 98545741e6

View File

@@ -105,6 +105,13 @@ module WebHelper
tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click
end
def tomselect_select(value, options)
tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper")
tomselect_wrapper.find(".ts-control").click
tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click
end
def request_monitor_finished(controller = nil)
page.evaluate_script("#{angular_scope(controller)}.scope().RequestMonitor.loading == false")
end