Skip to content

Commit

Permalink
cleanup and some wait keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfe1 committed Nov 25, 2020
1 parent c594366 commit ed579b4
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/APILibraryDocumentation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/DesktopLibraryDocumentation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/GUILibraryDocumentation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/MobileLibraryDocumentation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/SOAPLibraryDocumentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@
jQuery.extend({highlight:function(e,t,n,r){if(e.nodeType===3){var i=e.data.match(t);if(i){var s=document.createElement(n||"span");s.className=r||"highlight";var o=e.splitText(i.index);o.splitText(i[0].length);var u=o.cloneNode(true);s.appendChild(u);o.parentNode.replaceChild(s,o);return 1}}else if(e.nodeType===1&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&!(e.tagName===n.toUpperCase()&&e.className===r)){for(var a=0;a<e.childNodes.length;a++){a+=jQuery.highlight(e.childNodes[a],t,n,r)}}return 0}});jQuery.fn.unhighlight=function(e){var t={className:"highlight",element:"span"};jQuery.extend(t,e);return this.find(t.element+"."+t.className).each(function(){var e=this.parentNode;e.replaceChild(this.firstChild,this);e.normalize()}).end()};jQuery.fn.highlight=function(e,t){var n={className:"highlight",element:"span",caseSensitive:false,wordsOnly:false};jQuery.extend(n,t);if(e.constructor===String){e=[e]}e=jQuery.grep(e,function(e,t){return e!=""});e=jQuery.map(e,function(e,t){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")});if(e.length==0){return this}var r=n.caseSensitive?"":"i";var i="("+e.join("|")+")";if(n.wordsOnly){i="\\b"+i+"\\b"}var s=new RegExp(i,r);return this.each(function(){jQuery.highlight(this,s,n.element,n.className)})}
</script>
<script type="text/javascript">
libdoc = {"all_tags":[],"contains_tags":false,"doc":"<p>Zoomba SOAP Library\x3c/p>\n<p>This class is the base Library used to generate automated SOAP Tests in the Zoomba Automation Framework.\x3c/p>","generated":"2020-11-25 14:01:14","inits":[],"keywords":[{"args":["action=None","soap_object=None"],"doc":"<p>Call Soap Method. Calls soap method with list object\x3c/p>\n<p>action: (string) SOAP Action to be called.\x3c/p>\n<p>soap_object: (list) Soap Object in list format, list must be ordered wrt schema\x3c/p>","matched":true,"name":"Call Soap Method With List Object","shortdoc":"Call Soap Method. Calls soap method with list object ","tags":[]},{"args":["action=None","**soap_object"],"doc":"<p>Call Soap Method with dictionary object. Calls soap method\x3c/p>\n<p>action: (string) SOAP Action to be called.\x3c/p>\n<p>soap_object: (dict) Soap Object in dict format, dict must contain all required parts of schema object.\x3c/p>","matched":true,"name":"Call Soap Method With Object","shortdoc":"Call Soap Method with dictionary object. Calls soap method ","tags":[]},{"args":["soap_response=None"],"doc":"<p>Convert Soap Response To Dictionary: This keyword builds a dictionary from the sudsLibrary response\x3c/p>\n<p>json_actual_response: (request response object) The response from an API.\x3c/p>\n<p>return: There is no actual returned output, other than error messages when comparisons fail.\x3c/p>","matched":true,"name":"Convert Soap Response To Json","shortdoc":"Convert Soap Response To Dictionary: This keyword builds a dictionary from the sudsLibrary response","tags":[]},{"args":["host=None","endpoint=None","alias=None","**kwargs"],"doc":"<p>Create Soap Session. This Keyword utilizes the WSDL to create a soap client.\x3c/p>\n<p>host: (string) The host url.\x3c/p>\n<p>endpoint: (string) SOAP API endpoint containing the actions to be referenced.\x3c/p>\n<p>**kwargs: (optional) Parameters that could be included to add options to client creation. Current supported parameters are:\x3c/p>\n<p>set_location: http address\x3c/p>","matched":true,"name":"Create Soap Session","shortdoc":"Create Soap Session. This Keyword utilizes the WSDL to create a soap client.","tags":[]},{"args":["host=None","endpoint=None","alias=None","**kwargs"],"doc":"<p>Create Soap Session. This Keyword utilizes the WSDL and directly accesses calls from sudsLibrary.\x3c/p>\n<p>host: (string) The host url.\x3c/p>\n<p>endpoint: (string) SOAP API endpoint containing the actions to be referenced.\x3c/p>\n<p>alias: (string} Sets the alias for the SudsLibrary Framework **kwargs: (optional) Parameters that could be included to add options to client creation. Current supported parameters are:\x3c/p>\n<p>set_location: http address\x3c/p>","matched":true,"name":"Create Soap Session And Fix Wsdl","shortdoc":"Create Soap Session. This Keyword utilizes the WSDL and directly accesses calls from sudsLibrary.","tags":[]},{"args":["host=None","endpoint=None","alias=None","set_location=None","fix=False"],"doc":"<p>Create Soap Session and Set Location. In addition to the client creation, this keyword sets the location as specified.\x3c/p>\n<p>host: (string) The host url.\x3c/p>\n<p>endpoint: (string) SOAP API endpoint containing the actions to be referenced.\x3c/p>\n<p>set_location: (string) If set will overwrite the WSDL location with specified address.\x3c/p>\n<p>If set to None will replace location with host and endpoint specified\x3c/p>","matched":true,"name":"Create Soap Session And Set Location","shortdoc":"Create Soap Session and Set Location. In addition to the client creation, this keyword sets the location as specified.","tags":[]},{"args":["wsdl_type=None","object_dict=None"],"doc":"<p>Create Wsdl Objects. This Keyword utilizes the WSDL to create a WSDL object based on the information provided.\x3c/p>\n<p>wsdl_type: (string) Wsdl object to be created.\x3c/p>\n<p>object_dict: (dict) Python Dictionary containing values and nested dictionaries with construction similar to wsdl defined objects.\x3c/p>\n<p>return: (response object) Returns the SOAP client object.\x3c/p>","matched":true,"name":"Create Wsdl Objects","shortdoc":"Create Wsdl Objects. This Keyword utilizes the WSDL to create a WSDL object based on the information provided.","tags":[]}],"name":"SOAP_Library","named_args":true,"scope":"TEST","version":"2.6.1"};
libdoc = {"all_tags":[],"contains_tags":false,"doc":"<p>Zoomba SOAP Library\x3c/p>\n<p>This class is the base Library used to generate automated SOAP Tests in the Zoomba Automation Framework.\x3c/p>","generated":"2020-11-25 14:23:52","inits":[],"keywords":[{"args":["action=None","soap_object=None"],"doc":"<p>Call Soap Method. Calls soap method with list object\x3c/p>\n<p>action: (string) SOAP Action to be called.\x3c/p>\n<p>soap_object: (list) Soap Object in list format, list must be ordered wrt schema\x3c/p>","matched":true,"name":"Call Soap Method With List Object","shortdoc":"Call Soap Method. Calls soap method with list object ","tags":[]},{"args":["action=None","**soap_object"],"doc":"<p>Call Soap Method with dictionary object. Calls soap method\x3c/p>\n<p>action: (string) SOAP Action to be called.\x3c/p>\n<p>soap_object: (dict) Soap Object in dict format, dict must contain all required parts of schema object.\x3c/p>","matched":true,"name":"Call Soap Method With Object","shortdoc":"Call Soap Method with dictionary object. Calls soap method ","tags":[]},{"args":["soap_response=None"],"doc":"<p>Convert Soap Response To Dictionary: This keyword builds a dictionary from the sudsLibrary response\x3c/p>\n<p>json_actual_response: (request response object) The response from an API.\x3c/p>\n<p>return: There is no actual returned output, other than error messages when comparisons fail.\x3c/p>","matched":true,"name":"Convert Soap Response To Json","shortdoc":"Convert Soap Response To Dictionary: This keyword builds a dictionary from the sudsLibrary response","tags":[]},{"args":["host=None","endpoint=None","alias=None","**kwargs"],"doc":"<p>Create Soap Session. This Keyword utilizes the WSDL to create a soap client.\x3c/p>\n<p>host: (string) The host url.\x3c/p>\n<p>endpoint: (string) SOAP API endpoint containing the actions to be referenced.\x3c/p>\n<p>**kwargs: (optional) Parameters that could be included to add options to client creation. Current supported parameters are:\x3c/p>\n<p>set_location: http address\x3c/p>","matched":true,"name":"Create Soap Session","shortdoc":"Create Soap Session. This Keyword utilizes the WSDL to create a soap client.","tags":[]},{"args":["host=None","endpoint=None","alias=None","**kwargs"],"doc":"<p>Create Soap Session. This Keyword utilizes the WSDL and directly accesses calls from sudsLibrary.\x3c/p>\n<p>host: (string) The host url.\x3c/p>\n<p>endpoint: (string) SOAP API endpoint containing the actions to be referenced.\x3c/p>\n<p>alias: (string} Sets the alias for the SudsLibrary Framework **kwargs: (optional) Parameters that could be included to add options to client creation. Current supported parameters are:\x3c/p>\n<p>set_location: http address\x3c/p>","matched":true,"name":"Create Soap Session And Fix Wsdl","shortdoc":"Create Soap Session. This Keyword utilizes the WSDL and directly accesses calls from sudsLibrary.","tags":[]},{"args":["host=None","endpoint=None","alias=None","set_location=None","fix=False"],"doc":"<p>Create Soap Session and Set Location. In addition to the client creation, this keyword sets the location as specified.\x3c/p>\n<p>host: (string) The host url.\x3c/p>\n<p>endpoint: (string) SOAP API endpoint containing the actions to be referenced.\x3c/p>\n<p>set_location: (string) If set will overwrite the WSDL location with specified address.\x3c/p>\n<p>If set to None will replace location with host and endpoint specified\x3c/p>","matched":true,"name":"Create Soap Session And Set Location","shortdoc":"Create Soap Session and Set Location. In addition to the client creation, this keyword sets the location as specified.","tags":[]},{"args":["wsdl_type=None","object_dict=None"],"doc":"<p>Create Wsdl Objects. This Keyword utilizes the WSDL to create a WSDL object based on the information provided.\x3c/p>\n<p>wsdl_type: (string) Wsdl object to be created.\x3c/p>\n<p>object_dict: (dict) Python Dictionary containing values and nested dictionaries with construction similar to wsdl defined objects.\x3c/p>\n<p>return: (response object) Returns the SOAP client object.\x3c/p>","matched":true,"name":"Create Wsdl Objects","shortdoc":"Create Wsdl Objects. This Keyword utilizes the WSDL to create a WSDL object based on the information provided.","tags":[]}],"name":"SOAP_Library","named_args":true,"scope":"TEST","version":"2.6.1"};
</script>
<title></title>
</head>
Expand Down
8 changes: 5 additions & 3 deletions samples/Appium-DesktopTests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Documentation Zoomba Desktop Library Tests.
Library Zoomba.DesktopLibrary
Suite Setup Start App
Test Setup Launch Application
#Test Teardown Quit Application
#Suite Teardown Close All Applications
Test Teardown Quit Application
Suite Teardown Close All Applications
Force Tags Windows

*** Variables ***
Expand Down Expand Up @@ -132,8 +132,10 @@ Drag And Drop By Touch Tests

Tap Tests
Tap name=Five
Wait For And Tap name=Five
Double Tap name=Five
Wait Until Element Contains accessibility_id=CalculatorResults 555
Wait For And Double Tap name=Five
Wait Until Element Contains accessibility_id=CalculatorResults 555,555

Flick Tests
Select Element From ComboBox accessibility_id=TogglePaneButton accessibility_id=Graphing
Expand Down
4 changes: 3 additions & 1 deletion samples/WinAppDriver-DesktopTests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ Drag And Drop By Touch Tests

Tap Tests
Tap name=Five
Wait For And Tap name=Five
Double Tap name=Five
Wait Until Element Contains accessibility_id=CalculatorResults 555
Wait For And Double Tap name=Five
Wait Until Element Contains accessibility_id=CalculatorResults 555,555

Flick Tests
Select Element From ComboBox accessibility_id=TogglePaneButton accessibility_id=Graphing
Expand Down
54 changes: 52 additions & 2 deletions src/Zoomba/DesktopLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def get_keyword_names(self):
'capture_page_screenshot', 'save_appium_screenshot', 'select_element_from_combobox',
'driver_setup', 'driver_teardown', 'select_elements_from_menu',
'select_elements_from_context_menu', 'drag_and_drop_by_touch',
'drag_and_drop_by_touch_offset', 'double_tap', 'flick', 'flick_from_element',
'scroll', 'scroll_from_element',
'drag_and_drop_by_touch_offset', 'wait_for_and_tap', 'wait_for_and_double_tap',
'double_tap', 'flick', 'flick_from_element', 'scroll', 'scroll_from_element',
# External Libraries
'clear_text', 'click_button', 'click_element', 'close_all_applications',
'close_application', 'element_attribute_should_match', 'element_should_be_disabled',
Expand Down Expand Up @@ -728,6 +728,30 @@ def double_tap(self, locator):
action = TouchActions(self._current_application())
action.double_tap(element).perform()

@keyword("Wait For And Tap")
def wait_for_and_tap(self, locator, timeout=None, error=None):
"""Wait for and tap the element identified by ``locator``.
Fails if ``timeout`` expires before the element appears.
``error`` can be used to override the default error message.
See `introduction` for details about locating elements."""
self._wait_until_page_contains_element(locator, timeout, error)
self.tap(locator)

@keyword("Wait For And Double Tap")
def wait_for_and_double_tap(self, locator, timeout=None, error=None):
"""Wait for and double tap the element identified by ``locator``.
Fails if ``timeout`` expires before the element appears.
``error`` can be used to override the default error message.
See `introduction` for details about locating elements."""
self._wait_until_page_contains_element(locator, timeout, error)
self.double_tap(locator)

@keyword("Flick")
def flick(self, x_speed, y_speed):
""" Flicks from current position.
Expand All @@ -751,6 +775,19 @@ def flick_from_element(self, locator, x_offset, y_offset, speed):
action = TouchActions(self._current_application())
action.flick_element(element, x_offset, y_offset, speed).perform()

@keyword("Wait For And Flick From Element")
def wait_for_and_flick_from_element(self, locator, x_offset, y_offset, speed,
timeout=None, error=None):
"""Wait for and flick from element identified by ``locator``.
Fails if ``timeout`` expires before the element appears.
``error`` can be used to override the default error message.
See `introduction` for details about locating elements."""
self._wait_until_page_contains_element(locator, timeout, error)
self.flick_from_element(locator, x_offset, y_offset, speed)

@keyword("Scroll")
def scroll(self, x_offset, y_offset):
""" Scrolls from current position.
Expand All @@ -772,6 +809,19 @@ def scroll_from_element(self, locator, x_offset, y_offset):
action = TouchActions(self._current_application())
action.scroll_from_element(element, x_offset, y_offset).perform()

@keyword("Wait For And Scroll From Element")
def wait_for_and_scroll_from_element(self, locator, x_offset, y_offset,
timeout=None, error=None):
"""Wait for and scroll from element identified by ``locator``.
Fails if ``timeout`` expires before the element appears.
``error`` can be used to override the default error message.
See `introduction` for details about locating elements."""
self._wait_until_page_contains_element(locator, timeout, error)
self.scroll_from_element(locator, x_offset, y_offset)

# Private
def _move_to_element(self, actions, element, x_offset=0, y_offset=0):
if x_offset != 0 or y_offset != 0:
Expand Down
20 changes: 20 additions & 0 deletions test/Desktop/test_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ def test_flick_from_element(self, flick_element):
DesktopLibrary.flick_from_element(mock_desk, "some_locator", 50, 100, 10)
flick_element.assert_called_with(unittest.mock.ANY, 50, 100, 10)

def test_wait_for_and_flick_from_element(self):
mock_desk = MagicMock()
DesktopLibrary.wait_for_and_flick_from_element(mock_desk, "some_locator", 50, 100, 10)
mock_desk.flick_from_element.assert_called_with(unittest.mock.ANY, 50, 100, 10)

@patch("selenium.webdriver.common.touch_actions.TouchActions.scroll")
def test_scroll(self, scroll):
mock_desk = MagicMock()
Expand All @@ -661,12 +666,27 @@ def test_scroll_from_element(self, scroll_from_element):
DesktopLibrary.scroll_from_element(mock_desk, "some_locator", 50, 100)
scroll_from_element.assert_called_with(unittest.mock.ANY, 50, 100)

def test_wait_for_and_scroll_from_element(self):
mock_desk = MagicMock()
DesktopLibrary.wait_for_and_scroll_from_element(mock_desk, "some_locator", 50, 100)
mock_desk.scroll_from_element.assert_called_with(unittest.mock.ANY, 50, 100)

@patch("selenium.webdriver.common.touch_actions.TouchActions.double_tap")
def test_double_tap(self, double_tap):
mock_desk = MagicMock()
DesktopLibrary.double_tap(mock_desk, "some_locator")
double_tap.assert_called_with(unittest.mock.ANY)

def test_wait_for_and_tap(self):
mock_desk = MagicMock()
DesktopLibrary.wait_for_and_tap(mock_desk, "some_locator")
mock_desk.tap.assert_called_with(unittest.mock.ANY)

def test_wait_for_and_double_tap(self):
mock_desk = MagicMock()
DesktopLibrary.wait_for_and_double_tap(mock_desk, "some_locator")
mock_desk.double_tap.assert_called_with(unittest.mock.ANY)

@patch("selenium.webdriver.common.touch_actions.TouchActions.tap_and_hold")
def test_drag_and_drop_by_touch(self, tap_and_hold):
mock_desk = MagicMock()
Expand Down

0 comments on commit ed579b4

Please sign in to comment.