From 3af72d1db852952687fe85e2df841250e930f571 Mon Sep 17 00:00:00 2001 From: igortavtib Date: Mon, 6 Dec 2021 15:18:46 -0300 Subject: [PATCH 1/3] feat: press and long press keycode --- .gitignore | 4 ++- AppiumFlutterLibrary/__init__.py | 1 + AppiumFlutterLibrary/keywords/__init__.py | 4 ++- AppiumFlutterLibrary/keywords/_keyevents.py | 30 +++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 AppiumFlutterLibrary/keywords/_keyevents.py 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..420bb7b 100644 --- a/AppiumFlutterLibrary/__init__.py +++ b/AppiumFlutterLibrary/__init__.py @@ -8,6 +8,7 @@ class AppiumFlutterLibrary( _ApplicationManagementKeyWords, _ElementKeywords, + _KeyeventsKeywords, _LoggingKeywords, _ScreenKeywords, _RunOnFailureKeyWords, diff --git a/AppiumFlutterLibrary/keywords/__init__.py b/AppiumFlutterLibrary/keywords/__init__.py index 7da43b1..13d15d7 100644 --- a/AppiumFlutterLibrary/keywords/__init__.py +++ b/AppiumFlutterLibrary/keywords/__init__.py @@ -1,5 +1,6 @@ from ._applicationmanagement import _ApplicationManagementKeyWords from ._element import _ElementKeywords +from ._keyevents import _KeyeventsKeywords from ._logging import _LoggingKeywords from ._runonfailure import _RunOnFailureKeyWords from ._screen import _ScreenKeywords @@ -11,5 +12,6 @@ "_LoggingKeywords", "_RunOnFailureKeyWords", "_ScreenKeywords", - "_WaintingKeywords" + "_WaintingKeywords", + "_KeyeventsKeywords", ] \ 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 From 405de4b747d66411eb71408f640a8cf9d21c987d Mon Sep 17 00:00:00 2001 From: igortavtib Date: Thu, 9 Dec 2021 13:47:14 -0300 Subject: [PATCH 2/3] feat: touch keywords --- AppiumFlutterLibrary/__init__.py | 1 + AppiumFlutterLibrary/keywords/__init__.py | 4 +++- AppiumFlutterLibrary/keywords/_touch.py | 29 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 AppiumFlutterLibrary/keywords/_touch.py diff --git a/AppiumFlutterLibrary/__init__.py b/AppiumFlutterLibrary/__init__.py index 420bb7b..f62f684 100644 --- a/AppiumFlutterLibrary/__init__.py +++ b/AppiumFlutterLibrary/__init__.py @@ -12,6 +12,7 @@ class AppiumFlutterLibrary( _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 13d15d7..c15e663 100644 --- a/AppiumFlutterLibrary/keywords/__init__.py +++ b/AppiumFlutterLibrary/keywords/__init__.py @@ -4,14 +4,16 @@ 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", + "_TouchKeywords", "_WaintingKeywords", - "_KeyeventsKeywords", ] \ 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 From 9d386c164d0728c3d4d5f972e94aed77a9703dfe Mon Sep 17 00:00:00 2001 From: igortavtib Date: Thu, 9 Dec 2021 13:47:47 -0300 Subject: [PATCH 3/3] feat: update libdoc --- docs/AppiumFlutterLibrary.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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