From 0d3ebfdae3195800fd978dda9402c29f589c933a Mon Sep 17 00:00:00 2001 From: Minasyan1 Date: Wed, 11 Sep 2024 16:46:21 -0500 Subject: [PATCH 1/7] Adding a new keyword to GUILibrary.py --- src/Zoomba/GUILibrary.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Zoomba/GUILibrary.py b/src/Zoomba/GUILibrary.py index b92db0da..d837863c 100644 --- a/src/Zoomba/GUILibrary.py +++ b/src/Zoomba/GUILibrary.py @@ -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 first attempts to find a web element, clears it, and then inputs text. + Subsequently, it selects the first item in the search dropdown. + If typing into the element fails, the keyword will scroll to the bottom of the page and try again. + + 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(locator) + self.input_text(locator, text) + self.wait_until_javascript_is_complete() + self.send_keys(Keys.ARROW_DOWN) + self.send_keys(Keys.ENTER) From 9e9268ca9bbf8d3dfd29bd3b376ad1b8f1325ba4 Mon Sep 17 00:00:00 2001 From: Minasyan1 Date: Mon, 16 Sep 2024 14:29:08 -0500 Subject: [PATCH 2/7] Changing Select From Search Field keyword description --- src/Zoomba/GUILibrary.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Zoomba/GUILibrary.py b/src/Zoomba/GUILibrary.py index d837863c..17db034a 100644 --- a/src/Zoomba/GUILibrary.py +++ b/src/Zoomba/GUILibrary.py @@ -439,10 +439,10 @@ def get_react_list_labels(self, locator): @keyword("Select From Search Field") def select_from_search_field(self, locator, text, timeout=None): - """This is a Selenium keyword that first attempts to find a web element, clears it, and then inputs text. + """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. - If typing into the element fails, the keyword will scroll to the bottom of the page and try again. - + locator: (string) A selenium locator(CSS, XPATH, ID, NAME, etc) text: (string) Text to be typed into the input field. From 9736570c6e609bed0a59492210c9bf7d96d2f91c Mon Sep 17 00:00:00 2001 From: ruben_minasyan Date: Thu, 19 Sep 2024 10:33:38 -0500 Subject: [PATCH 3/7] Adding a unit test --- src/Zoomba/GUILibrary.py | 1 + test/GUI/test_gui.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/Zoomba/GUILibrary.py b/src/Zoomba/GUILibrary.py index 17db034a..3fef0e65 100644 --- a/src/Zoomba/GUILibrary.py +++ b/src/Zoomba/GUILibrary.py @@ -7,6 +7,7 @@ from robot.utils import is_string from selenium.webdriver.common.action_chains import ActionChains, ScrollOrigin import importlib +from selenium.webdriver.common.keys import Keys # Importing ReactSelect try: diff --git a/test/GUI/test_gui.py b/test/GUI/test_gui.py index 225919a6..ce471a6c 100644 --- a/test/GUI/test_gui.py +++ b/test/GUI/test_gui.py @@ -6,6 +6,7 @@ from Zoomba.GUILibrary import GUILibrary from Zoomba.Helpers import ReactSelect from selenium.common.exceptions import UnexpectedTagNameException +from selenium.webdriver.common.keys import Keys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../src/'))) @@ -441,3 +442,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.assert_called_with("some_locator") + mock_gui.input_text.assert_called_with("some_locator", "some_text") + mock_gui.send_keys.assert_called_with(Keys.ENTER) From 06f4a1f584d4faeffe3986c8e28fabee5240c15d Mon Sep 17 00:00:00 2001 From: ruben_minasyan Date: Thu, 19 Sep 2024 15:59:42 -0500 Subject: [PATCH 4/7] Adding a unit test and gui tests --- src/Zoomba/GUILibrary.py | 9 ++++++--- test/GUI/GUITests.robot | 7 +++++++ test/GUI/GUITestsEdge.robot | 7 +++++++ test/GUI/test_gui.py | 4 ++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Zoomba/GUILibrary.py b/src/Zoomba/GUILibrary.py index 3fef0e65..56c6c592 100644 --- a/src/Zoomba/GUILibrary.py +++ b/src/Zoomba/GUILibrary.py @@ -8,6 +8,9 @@ from selenium.webdriver.common.action_chains import ActionChains, ScrollOrigin import importlib from selenium.webdriver.common.keys import Keys +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.by import By # Importing ReactSelect try: @@ -451,8 +454,8 @@ def select_from_search_field(self, locator, text, timeout=None): 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(locator) + self.clear_element_text(locator) self.input_text(locator, text) self.wait_until_javascript_is_complete() - self.send_keys(Keys.ARROW_DOWN) - self.send_keys(Keys.ENTER) + self.press_keys(locator, "ARROW_DOWN") + self.press_keys(locator, "RETURN") diff --git a/test/GUI/GUITests.robot b/test/GUI/GUITests.robot index 15828b8d..97fe4b4c 100644 --- a/test/GUI/GUITests.robot +++ b/test/GUI/GUITests.robot @@ -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 diff --git a/test/GUI/GUITestsEdge.robot b/test/GUI/GUITestsEdge.robot index 65941ca3..8607ff20 100644 --- a/test/GUI/GUITestsEdge.robot +++ b/test/GUI/GUITestsEdge.robot @@ -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 diff --git a/test/GUI/test_gui.py b/test/GUI/test_gui.py index ce471a6c..93d64b38 100644 --- a/test/GUI/test_gui.py +++ b/test/GUI/test_gui.py @@ -446,6 +446,6 @@ def test_react_select_expand_select_list_already_expanded(self): 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.assert_called_with("some_locator") + mock_gui.clear_element_text.assert_called_with("some_locator") mock_gui.input_text.assert_called_with("some_locator", "some_text") - mock_gui.send_keys.assert_called_with(Keys.ENTER) + mock_gui.press_keys.assert_called_with("some_locator", "RETURN") From 8cb077a26759a0d4ededfec9182397fd30e53167 Mon Sep 17 00:00:00 2001 From: ruben_minasyan Date: Thu, 19 Sep 2024 16:12:24 -0500 Subject: [PATCH 5/7] Removing unnecessary imports --- src/Zoomba/GUILibrary.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Zoomba/GUILibrary.py b/src/Zoomba/GUILibrary.py index 56c6c592..ae2a4dbf 100644 --- a/src/Zoomba/GUILibrary.py +++ b/src/Zoomba/GUILibrary.py @@ -8,9 +8,6 @@ from selenium.webdriver.common.action_chains import ActionChains, ScrollOrigin import importlib from selenium.webdriver.common.keys import Keys -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.common.by import By # Importing ReactSelect try: From 9ab99b7a395d81b80c830db080b2ba2a9f9c31f3 Mon Sep 17 00:00:00 2001 From: ruben_minasyan Date: Thu, 19 Sep 2024 16:15:04 -0500 Subject: [PATCH 6/7] Removing unnecessary import --- src/Zoomba/GUILibrary.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Zoomba/GUILibrary.py b/src/Zoomba/GUILibrary.py index ae2a4dbf..34d9c799 100644 --- a/src/Zoomba/GUILibrary.py +++ b/src/Zoomba/GUILibrary.py @@ -7,7 +7,6 @@ from robot.utils import is_string from selenium.webdriver.common.action_chains import ActionChains, ScrollOrigin import importlib -from selenium.webdriver.common.keys import Keys # Importing ReactSelect try: From eb5aad79b766352246921f1550a81e0777c76c86 Mon Sep 17 00:00:00 2001 From: ruben_minasyan Date: Thu, 19 Sep 2024 16:16:01 -0500 Subject: [PATCH 7/7] Removing unnecessary import --- test/GUI/test_gui.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/GUI/test_gui.py b/test/GUI/test_gui.py index 93d64b38..6eb212c1 100644 --- a/test/GUI/test_gui.py +++ b/test/GUI/test_gui.py @@ -6,7 +6,6 @@ from Zoomba.GUILibrary import GUILibrary from Zoomba.Helpers import ReactSelect from selenium.common.exceptions import UnexpectedTagNameException -from selenium.webdriver.common.keys import Keys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../src/')))