Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select From Search Field #419

Merged
merged 7 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Zoomba/GUILibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,22 @@ def get_react_list_labels(self, locator):
react_select_container = self.find_element(locator)
options = RS.ReactSelect(react_select_container).options()
return [opt.text for opt in options]

@keyword("Select From Search Field")
def select_from_search_field(self, locator, text, timeout=None):
"""This is a Selenium keyword that that first waits for an element to be on the DOM, executes
Focus on it, then it waits for it to be visible, clears it, and then inputs text.
Subsequently, it selects the first item in the search dropdown.

locator: (string) A selenium locator(CSS, XPATH, ID, NAME, etc)

text: (string) Text to be typed into the input field.

timeout: (float) Time in seconds to wait, will use global timeout if not set.
"""
self.wait_for_and_focus_on_element(locator, timeout)
self.clear_element_text(locator)
self.input_text(locator, text)
self.wait_until_javascript_is_complete()
self.press_keys(locator, "ARROW_DOWN")
self.press_keys(locator, "RETURN")
7 changes: 7 additions & 0 deletions test/GUI/GUITests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ Wait Until Window Tests
Wait Until Window Opens Popup Example 10
Wait For And Select Window Popup Example 10

Select From Search Field Test
Go To https://jquery.com/
Wait For Page To Load
Select From Search Field //input[@type='search'] css()
Wait Until Javascript Is Complete
Page Should Contain css()

*** Keywords ***
Test Case Setup
Open Browser browser=Chrome
Expand Down
7 changes: 7 additions & 0 deletions test/GUI/GUITestsEdge.robot
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ Wait Until Window Tests
Wait Until Window Opens Popup Example 10
Wait For And Select Window Popup Example 10

Select From Search Field Test
Go To https://jquery.com/
Wait For Page To Load
Select From Search Field //input[@type='search'] css()
Wait Until Javascript Is Complete
Page Should Contain css()

*** Keywords ***
Test Case Setup
Open Browser browser=Edge
Expand Down
7 changes: 7 additions & 0 deletions test/GUI/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,10 @@ def test_react_select_expand_select_list_already_expanded(self):
with patch('Zoomba.Helpers.ReactSelect.ReactSelect.is_expanded', return_value=True):
ReactSelect.ReactSelect(mock_webelement).expand_select_list()
mock_webelement.click.assert_not_called()

def test_select_from_search_field(self):
mock_gui = Mock()
GUILibrary.select_from_search_field(mock_gui, "some_locator", "some_text", 1)
mock_gui.clear_element_text.assert_called_with("some_locator")
mock_gui.input_text.assert_called_with("some_locator", "some_text")
mock_gui.press_keys.assert_called_with("some_locator", "RETURN")
Loading