Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit b6af56a

Browse files
feat: press and long press keycode (#6)
* feat: press and long press keycode * feat: touch keywords * feat: update libdoc
1 parent de09d70 commit b6af56a

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ nosetests.xml
3030
# Translations
3131
*.mo
3232

33-
# PyCharm
33+
# IDE
3434
.idea
35+
.vscode
3536

3637
# Mr Developer
3738
.mr.developer.cfg
@@ -45,6 +46,7 @@ report.html
4546
demo/test_doubandaily.txt
4647
htmlcov/
4748
run.sh
49+
4850
# for eclipse
4951
.settings
5052
.eggs/

‎AppiumFlutterLibrary/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
class AppiumFlutterLibrary(
99
_ApplicationManagementKeyWords,
1010
_ElementKeywords,
11+
_KeyeventsKeywords,
1112
_LoggingKeywords,
1213
_ScreenKeywords,
1314
_RunOnFailureKeyWords,
15+
_TouchKeywords,
1416
_WaintingKeywords,
1517
):
1618
""" AppiumFlutterLibrary is a flutter testing library for Robot Framework
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
from ._applicationmanagement import _ApplicationManagementKeyWords
22
from ._element import _ElementKeywords
3+
from ._keyevents import _KeyeventsKeywords
34
from ._logging import _LoggingKeywords
45
from ._runonfailure import _RunOnFailureKeyWords
56
from ._screen import _ScreenKeywords
7+
from ._touch import _TouchKeywords
68
from ._waiting import _WaintingKeywords
79

810
__all__ = [
911
"_ApplicationManagementKeyWords",
1012
"_ElementKeywords",
13+
"_KeyeventsKeywords",
1114
"_LoggingKeywords",
1215
"_RunOnFailureKeyWords",
1316
"_ScreenKeywords",
14-
"_WaintingKeywords"
17+
"_TouchKeywords",
18+
"_WaintingKeywords",
1519
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from .keywordgroup import KeywordGroup
2+
3+
class _KeyeventsKeywords(KeywordGroup):
4+
def press_keycode(self, keycode, metastate=None):
5+
"""Sends a press of keycode to the device.
6+
Android only.
7+
Possible keycodes & meta states can be found in
8+
http://developer.android.com/reference/android/view/KeyEvent.html
9+
Meta state describe the pressed state of key modifiers such as
10+
Shift, Ctrl & Alt keys. The Meta State is an integer in which each
11+
bit set to 1 represents a pressed meta key.
12+
For example
13+
- META_SHIFT_ON = 1
14+
- META_ALT_ON = 2
15+
| metastate=1 --> Shift is pressed
16+
| metastate=2 --> Alt is pressed
17+
| metastate=3 --> Shift+Alt is pressed
18+
- _keycode- - the keycode to be sent to the device
19+
- _metastate- - status of the meta keys
20+
"""
21+
driver = self._current_application()
22+
driver.press_keycode(keycode, metastate)
23+
24+
def long_press_keycode(self, keycode, metastate=None):
25+
"""Sends a long press of keycode to the device.
26+
Android only.
27+
See `press keycode` for more details.
28+
"""
29+
driver = self._current_application()
30+
driver.long_press_keycode(int(keycode), metastate)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from .keywordgroup import KeywordGroup
2+
from AppiumFlutterLibrary.finder import ElementFinder
3+
4+
class _TouchKeywords(KeywordGroup):
5+
def init(self):
6+
self._element_finder = ElementFinder()
7+
8+
def scroll(self, start_locator, end_locator):
9+
"""
10+
Scrolls from one element to another
11+
Key attributes for arbitrary elements are `id` and `name`. See
12+
`introduction` for details about locating elements.
13+
"""
14+
el1 = self._find_element(self, start_locator)
15+
el2 = self._find_element(self, end_locator)
16+
driver = self._current_application()
17+
driver.scroll(el1, el2)
18+
19+
def scroll_down(self, locator):
20+
"""Scrolls down to element"""
21+
driver = self._current_application()
22+
element = self._find_element(self, locator)
23+
driver.execute_script("mobile: scroll", {"direction": 'down', 'elementid': element.id})
24+
25+
def scroll_up(self, locator):
26+
"""Scrolls up to element"""
27+
driver = self._current_application()
28+
element = self._element_find(locator, True, True)
29+
driver.execute_script("mobile: scroll", {"direction": 'up', 'elementid': element.id})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /