From 98545741e6069a2ec288552bac7de6e4e690a450 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 24 Jan 2024 14:47:21 +1100 Subject: [PATCH] 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. --- spec/support/request/web_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index e452939972..01a4796f4e 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -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