From cde4019561738cc41fe1a89be8e6099eae3b7279 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Mon, 27 Sep 2021 17:21:42 +0530 Subject: [PATCH] added create_new_address_test --- src/bitmessagekivy/baseclass/addressbook.py | 1 - src/bitmessagekivy/tests/telenium_process.py | 20 ++++++++++- .../tests/test_create_random_address.py | 33 ++++++++++++------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index 53ec14eb..0b476d8d 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -1,4 +1,3 @@ -from turtle import pd from bitmessagekivy.get_platform import platform from bitmessagekivy import kivy_helper_search from helper_sql import sqlExecute diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index a398d301..7122c12a 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -8,6 +8,7 @@ import tempfile from time import time, sleep from telenium.tests import TeleniumTestCase +from telenium.client import TeleniumHttpException _files = ( 'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat', @@ -99,4 +100,21 @@ class TeleniumTestProcess(TeleniumTestCase): return False if timeout > 0 and time() - start > timeout: raise Exception("Timeout") - sleep(0.1) \ No newline at end of file + sleep(0.1) + + def assert_wait_no_except(self, selector, timeout=-1, value='inbox'): + """This method is to check the application is launched.""" + start = time() + deadline = start + timeout + while time() < deadline: + try: + if self.cli.getattr(selector, 'current') == value: + self.assertTrue(selector, value) + break + except TeleniumHttpException: + sleep(0.1) + continue + finally: + # Finally Sleep is used to make the menu button funcationlly available for the click process. + # (because Transition is little bit slow) + sleep(0.2) diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py index 2f2cccc0..c7c04789 100644 --- a/src/bitmessagekivy/tests/test_create_random_address.py +++ b/src/bitmessagekivy/tests/test_create_random_address.py @@ -20,17 +20,18 @@ class CreateRandomAddress(TeleniumTestProcess): """Click on Proceed Button to Proceed to Next Screen.""" # Checking current Screen(Login screen) self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='login') - # This is for checking the Side nav Bar is closed - self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) # Clicking on Proceed Next Button + self.assertExists('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2) self.cli.wait_click( '//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2) # Checking Current Screen(Random Screen) after Clicking on Proceed Next Button # self.assertExists("//Random[@name~=\"random\"]", timeout=2) - self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5) - self.cli.wait_click( - '//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2) - + try: + self.assertExists("//ScreenManager[@current=\"random\"]", timeout=2) + except: + self.cli.wait_click( + '//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5) + self.assertExists("//ScreenManager[@current=\"random\"]", timeout=2) @ordered def test_random_screen(self): @@ -62,6 +63,7 @@ class CreateRandomAddress(TeleniumTestProcess): # Checking state of scrolled screen self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) # Clicking on New Address Tab + self.assertExists('//NavigationItem[@text=\"New address\"]', timeout=5) self.cli.wait_click('//NavigationItem[@text=\"New address\"]', timeout=3) self.cli.sleep(1) # Checking current Screen(Login screen) @@ -79,6 +81,10 @@ class CreateRandomAddress(TeleniumTestProcess): @ordered def test_select_address(self): """Select First Address From Drawer-Box""" + # This is for checking the Side nav Bar is closed + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + # This is for checking the menu button is appeared + self.assertExists('//MDActionTopAppBarButton[@icon~=\"menu\"]', timeout=5) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) # checking state of Nav drawer @@ -87,10 +93,15 @@ class CreateRandomAddress(TeleniumTestProcess): self.drag("//NavigationItem[@text=\"Address Book\"]", "//NavigationItem[@text=\"Settings\"]") # Checking scroll state self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=5) - # Clicking on Address Dropdown + # Click to open Address Dropdown self.cli.wait_click('//NavigationItem[0]/CustomSpinner[0]', timeout=5) + # Checking the state of dropdown (Should be open) self.assertNotEqual('//NavigationItem[0]/CustomSpinner[@is_open]', False) - # Select address fron Address Dropdown - self.cli.wait_click('//MySpinnerOption[0]', timeout=5) - # Checking Landing Screen(Inbox) - self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5) + try: + # Select address fron Address Dropdown + self.cli.wait_click('//MySpinnerOption[0]', timeout=5) + # Checking current screen + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5) + except: + self.cli.wait_click('//MySpinnerOption[0]', timeout=5) + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)