Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit 54554c5

Browse files
authored
Feat: Element verifiers (#1)
* delete test.py file * feat: Element verifiers * feat: Update readme * feat: upgrade version * fix: remove wrong import at element * fix: remvoe unfuntional keywords * feat: raise error when automationName isnt flutter * fix: scroll to element keyword
1 parent 18c91fe commit 54554c5

File tree

10 files changed

+60
-32
lines changed

10 files changed

+60
-32
lines changed

AppiumFlutterLibrary/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
class AppiumFlutterLibrary(
99
_ApplicationManagementKeyWords,
1010
_ElementKeywords,
11+
_LoggingKeywords,
12+
_ScreenKeywords,
1113
_RunOnFailureKeyWords,
1214
_WaintingKeywords,
13-
_LoggingKeywords
1415
):
1516
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
1617
ROBOT_LIBRARY_VERSION = VERSION

AppiumFlutterLibrary/finder/elementfinder.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def __init__(self):
55
self._element_finder = FlutterFinder()
66
self._strategies = {
77
'xpath': self._find_by_xpath,
8-
'key': self._find_by_key
8+
'key': self._find_by_key,
9+
'text': self._find_by_text,
910
}
1011

1112
def find(self, application, locator):
@@ -29,6 +30,14 @@ def _find_by_key(self, application, element_key):
2930
def _find_by_xpath(self, application, xpath):
3031
return
3132

33+
def _find_by_text(self, application, element_text):
34+
finder_text = self._element_finder.by_text(element_text)
35+
element = FlutterElement(application, finder_text)
36+
37+
return element
38+
39+
40+
3241
def _parse_locator(self, locator):
3342
prefix = None
3443
criteria = locator
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from ._applicationmanagement import _ApplicationManagementKeyWords
22
from ._element import _ElementKeywords
3+
from ._logging import _LoggingKeywords
34
from ._runonfailure import _RunOnFailureKeyWords
5+
from ._screen import _ScreenKeywords
46
from ._waiting import _WaintingKeywords
5-
from ._logging import _LoggingKeywords
67

78
__all__ = [
89
"_ApplicationManagementKeyWords",
910
"_ElementKeywords",
1011
"_LoggingKeywords",
1112
"_RunOnFailureKeyWords",
13+
"_ScreenKeywords",
1214
"_WaintingKeywords"
1315
]

AppiumFlutterLibrary/keywords/_applicationmanagement.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import robot
4+
import time
45
from AppiumFlutterLibrary.utils import ApplicationCache
56
from AppiumFlutterLibrary.keywords.keywordgroup import KeywordGroup
67
from appium.webdriver import Remote
@@ -15,8 +16,9 @@ def close_application(self):
1516

1617
def open_application(self, remote_url, alias =None, **kwargs):
1718
desired_caps = kwargs
19+
if desired_caps['automationName'] != 'flutter':
20+
raise ValueError("Appium Flutter Library only suports flutter automation. Try changing automationName capability to 'flutter'")
1821
application = Remote(str(remote_url), desired_caps)
19-
2022
return self._cache.register(application, alias)
2123

2224
def set_appium_timeout(self, seconds):
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import time
1+
from appium.webdriver.webelement import WebElement
22
from .keywordgroup import KeywordGroup
33
from AppiumFlutterLibrary.finder import ElementFinder
44

@@ -10,12 +10,31 @@ def __init__(self):
1010
self._element_finder = ElementFinder()
1111

1212
def input_text(self, locator, text):
13-
application = self._current_application()
14-
element = self._element_finder.find(application, locator)
13+
element = self._find_element(locator)
1514
self._info("Typing text '%s' into component '%s'" % (text, locator))
1615
element.send_keys(text)
1716

1817
def click_element(self, locator):
19-
application = self._current_application()
20-
element = self._element_finder.find(application, locator)
18+
element = self._find_element(locator)
19+
self._info("Clicking on element %s" % locator)
2120
element.click()
21+
22+
def element_should_be_visible(self, locator):
23+
element = self._find_element(locator)
24+
if not self._is_visible(element):
25+
raise AssertionError("Element '%s' should be visible but not" % locator)
26+
27+
def element_text_should_be(self, locator, text):
28+
element = self._find_element(locator)
29+
if element.text != text:
30+
raise AssertionError("Element '%s' text should be '%s' but is '%s'." %
31+
(locator, text, element.text))
32+
33+
def _is_visible(self, element):
34+
application = self._current_application()
35+
application.execute_script('flutter:waitFor', element, 1)
36+
return 1
37+
38+
def _find_element(self, locator):
39+
application = self._current_application()
40+
return self._element_finder.find(application, locator)

AppiumFlutterLibrary/keywords/_screen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from _typeshed import ReadableBuffer
21
from AppiumFlutterLibrary.finder import ElementFinder
32
from AppiumFlutterLibrary.keywords.keywordgroup import KeywordGroup
43

@@ -9,4 +8,5 @@ def __init__(self):
98
def scroll_to_element(self, locator):
109
application = self._current_application()
1110
element = self._element_finder.find(application, locator)
12-
application.execute_script('flutter:scrollIntoView', element)
11+
self._info(element)
12+
application.execute_script('flutter:scrollIntoView', element, 0)

AppiumFlutterLibrary/keywords/test.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

AppiumFlutterLibrary/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
VERSION = '1.0.0-alpha.1'
2+
VERSION = '1.0.0-alpha.2'

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
# AppiumFlutterLibary
2+
3+
![PyPI](https://img.shields.io/pypi/v/robotframework-appiumflutterlibrary?color=blue)
4+
![PyPI - Downloads](https://img.shields.io/pypi/dm/robotframework-appiumflutterlibrary)
5+
26
AppiumFlutterLibrary is a library for testing Flutter apps with [RobotFramework](https://robotframework.org/).
7+
8+
The project uses the [Flutter Driver](https://flutter.dev/docs/cookbook/testing/integration/introduction) test tools integrated to [Appium](https://appium.io/) as a RobotFramework library.
9+
10+
## Installation
11+
12+
Install using [pip](https://pypi.org/project/robotframework-appiumflutterlibrary/)
13+
14+
```bash
15+
pip install --upgrade robotframework-appiumflutterlibrary
16+
```

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
ROOT = dirname(abspath(__file__))
77

8-
98
setup(name='robotframework-appiumflutterlibrary',
10-
version='1.0.0-alpha.1',
9+
version='1.0.0-alpha.2',
1110
description='Robot Framework Mobile flutter app testing library for Appium Client Android & iOS & Web',
1211
long_description=open(join(ROOT, 'README.md')).read(),
1312
author='Igor Augusto',

0 commit comments

Comments
 (0)