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

Commit 5753a31

Browse files
committed
feat: Refactor open and close application
1 parent 02c034e commit 5753a31

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

AppiumFlutterLibrary/keywords/_applicationmanagement.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,18 @@
99

1010
class _ApplicationManagementKeyWords(KeywordGroup):
1111
def __init__(self):
12-
self._cache = ApplicationCache
12+
self._cache = ApplicationCache()
1313
self._timeout_in_secs = float(5)
1414

15-
def open_application(self, remote_url, alias=None, **kwargs):
15+
def close_application(self):
16+
self._cache.close()
17+
18+
def open_application(self, remote_url, alias =None, **kwargs):
1619
desired_caps = kwargs
17-
application = Remote(str(remote_url), dict(desired_caps))
20+
application = Remote(str(remote_url), desired_caps)
1821

1922
return self._cache.register(application, alias)
2023

21-
def login_to_application(self, remote_url, alias=None, **kwargs):
22-
driver = Remote('http://localhost:4723/wd/hub', dict(
23-
platformName='android',
24-
automationName='flutter',
25-
udid='emulator-5554',
26-
app='/home/igortavtib/Projects/robotframework-appiumflutterlibrary/app-prod-debug.apk'
27-
))
28-
29-
finder = FlutterFinder()
30-
31-
key_finder = finder.by_value_key('input-user')
32-
input_element = FlutterElement(driver, key_finder)
33-
key_finder = finder.by_value_key('input-password')
34-
password_element = FlutterElement(driver, key_finder)
35-
driver.execute_script('flutter:waitFor', input_element)
36-
input_element.send_keys('igoraugsto@gmail.com')
37-
password_element.send_keys('senha123')
38-
3924
def set_appium_timeout(self, seconds):
4025
old_timeout = self.get_appium_timeout()
4126
self._timeout_in_secs = robot.utils.timestr_to_secs(seconds)
@@ -45,4 +30,11 @@ def get_appium_timeout(self):
4530
"""Gets the timeout in seconds that is used by various keywords.
4631
4732
See `Set Appium Timeout` for an explanation."""
48-
return robot.utils.secs_to_timestr(self._timeout_in_secs)
33+
return robot.utils.secs_to_timestr(self._timeout_in_secs)
34+
35+
# Private
36+
37+
def _current_application(self):
38+
if not self._cache.current:
39+
raise RuntimeError('No application is open')
40+
return self._cache.current

0 commit comments

Comments
 (0)