diff --git a/.gitignore b/.gitignore index 94681fa..1fa99f3 100644 --- a/.gitignore +++ b/.gitignore @@ -30,8 +30,9 @@ nosetests.xml # Translations *.mo -# PyCharm +# IDE .idea +.vscode # Mr Developer .mr.developer.cfg @@ -45,6 +46,7 @@ report.html demo/test_doubandaily.txt htmlcov/ run.sh + # for eclipse .settings .eggs/ diff --git a/AppiumFlutterLibrary/__init__.py b/AppiumFlutterLibrary/__init__.py index ddc394b..f62f684 100644 --- a/AppiumFlutterLibrary/__init__.py +++ b/AppiumFlutterLibrary/__init__.py @@ -8,9 +8,11 @@ class AppiumFlutterLibrary( _ApplicationManagementKeyWords, _ElementKeywords, + _KeyeventsKeywords, _LoggingKeywords, _ScreenKeywords, _RunOnFailureKeyWords, + _TouchKeywords, _WaintingKeywords, ): """ AppiumFlutterLibrary is a flutter testing library for Robot Framework diff --git a/AppiumFlutterLibrary/keywords/__init__.py b/AppiumFlutterLibrary/keywords/__init__.py index 7da43b1..c15e663 100644 --- a/AppiumFlutterLibrary/keywords/__init__.py +++ b/AppiumFlutterLibrary/keywords/__init__.py @@ -1,15 +1,19 @@ from ._applicationmanagement import _ApplicationManagementKeyWords from ._element import _ElementKeywords +from ._keyevents import _KeyeventsKeywords from ._logging import _LoggingKeywords from ._runonfailure import _RunOnFailureKeyWords from ._screen import _ScreenKeywords +from ._touch import _TouchKeywords from ._waiting import _WaintingKeywords __all__ = [ "_ApplicationManagementKeyWords", "_ElementKeywords", + "_KeyeventsKeywords", "_LoggingKeywords", "_RunOnFailureKeyWords", "_ScreenKeywords", - "_WaintingKeywords" + "_TouchKeywords", + "_WaintingKeywords", ] \ No newline at end of file diff --git a/AppiumFlutterLibrary/keywords/_keyevents.py b/AppiumFlutterLibrary/keywords/_keyevents.py new file mode 100644 index 0000000..77eac34 --- /dev/null +++ b/AppiumFlutterLibrary/keywords/_keyevents.py @@ -0,0 +1,30 @@ +from .keywordgroup import KeywordGroup + +class _KeyeventsKeywords(KeywordGroup): + def press_keycode(self, keycode, metastate=None): + """Sends a press of keycode to the device. + Android only. + Possible keycodes & meta states can be found in + http://developer.android.com/reference/android/view/KeyEvent.html + Meta state describe the pressed state of key modifiers such as + Shift, Ctrl & Alt keys. The Meta State is an integer in which each + bit set to 1 represents a pressed meta key. + For example + - META_SHIFT_ON = 1 + - META_ALT_ON = 2 + | metastate=1 --> Shift is pressed + | metastate=2 --> Alt is pressed + | metastate=3 --> Shift+Alt is pressed + - _keycode- - the keycode to be sent to the device + - _metastate- - status of the meta keys + """ + driver = self._current_application() + driver.press_keycode(keycode, metastate) + + def long_press_keycode(self, keycode, metastate=None): + """Sends a long press of keycode to the device. + Android only. + See `press keycode` for more details. + """ + driver = self._current_application() + driver.long_press_keycode(int(keycode), metastate) \ No newline at end of file diff --git a/AppiumFlutterLibrary/keywords/_touch.py b/AppiumFlutterLibrary/keywords/_touch.py new file mode 100644 index 0000000..12fc3af --- /dev/null +++ b/AppiumFlutterLibrary/keywords/_touch.py @@ -0,0 +1,29 @@ +from .keywordgroup import KeywordGroup +from AppiumFlutterLibrary.finder import ElementFinder + +class _TouchKeywords(KeywordGroup): + def init(self): + self._element_finder = ElementFinder() + + def scroll(self, start_locator, end_locator): + """ + Scrolls from one element to another + Key attributes for arbitrary elements are `id` and `name`. See + `introduction` for details about locating elements. + """ + el1 = self._find_element(self, start_locator) + el2 = self._find_element(self, end_locator) + driver = self._current_application() + driver.scroll(el1, el2) + + def scroll_down(self, locator): + """Scrolls down to element""" + driver = self._current_application() + element = self._find_element(self, locator) + driver.execute_script("mobile: scroll", {"direction": 'down', 'elementid': element.id}) + + def scroll_up(self, locator): + """Scrolls up to element""" + driver = self._current_application() + element = self._element_find(locator, True, True) + driver.execute_script("mobile: scroll", {"direction": 'up', 'elementid': element.id}) \ No newline at end of file diff --git a/docs/AppiumFlutterLibrary.html b/docs/AppiumFlutterLibrary.html index 9963c00..d9d3e99 100644 --- a/docs/AppiumFlutterLibrary.html +++ b/docs/AppiumFlutterLibrary.html @@ -1102,7 +1102,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