summaryrefslogtreecommitdiff
path: root/qa/qa/page/component/dropdown.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/page/component/dropdown.rb')
-rw-r--r--qa/qa/page/component/dropdown.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/qa/qa/page/component/dropdown.rb b/qa/qa/page/component/dropdown.rb
index 01ef3533ff8..767cd40daa2 100644
--- a/qa/qa/page/component/dropdown.rb
+++ b/qa/qa/page/component/dropdown.rb
@@ -4,8 +4,18 @@ module QA
module Page
module Component
module Dropdown
- def select_item(item_text)
- find('li.gl-new-dropdown-item', text: item_text, match: :prefer_exact).click
+ # Find and click item using css selector and matching text
+ # If item_text is not provided, select the first item that matches the given css selector
+ #
+ # @param [String] item_text
+ # @param [String] css - css selector of the item
+ # @return [void]
+ def select_item(item_text, css: 'li.gl-new-dropdown-item')
+ if item_text
+ find(css, text: item_text, match: :prefer_exact).click
+ else
+ find(css, match: :first).click
+ end
end
def has_item?(item_text)
@@ -65,8 +75,8 @@ module QA
find('li.gl-new-dropdown-item span:nth-child(2)', text: item_text, exact_text: true).click
end
- def expand_select_list
- find('.gl-new-dropdown-toggle').click
+ def expand_select_list(css: '.gl-new-dropdown-toggle')
+ find(css).click
end
def wait_for_search_to_complete