From 8936194c5d17cf1aa82c601721bbff6ffb3bfdf3 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Fri, 20 Aug 2021 15:39:53 +0530 Subject: [PATCH] WIP --- src/bitmessagekivy/tests/rubbish | 120 ++++++++++++++++++ src/bitmessagekivy/tests/telenium_process.py | 56 ++++++-- .../tests/test_allmail_message.py | 13 +- .../tests/test_create_random_address.py | 35 +++-- .../tests/test_myaddress_screen.py | 88 ++++--------- .../tests/test_network_screen.py | 26 ++-- .../tests/test_payment_subscription.py | 31 +++-- src/bitmessagekivy/tests/test_sent_message.py | 1 - .../tests/test_setting_screen.py | 15 ++- .../tests/test_trash_message.py | 107 ++++++++++++---- 10 files changed, 343 insertions(+), 149 deletions(-) create mode 100644 src/bitmessagekivy/tests/rubbish diff --git a/src/bitmessagekivy/tests/rubbish b/src/bitmessagekivy/tests/rubbish new file mode 100644 index 00000000..7392d3db --- /dev/null +++ b/src/bitmessagekivy/tests/rubbish @@ -0,0 +1,120 @@ +my address test + +from .telenium_process import TeleniumTestProcess +from .common import ordered + + +data = [ + 'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h', + 'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr' +] + +class MyAddressScreen(TeleniumTestProcess): + """MyAddress Screen Functionality Testing""" + + @ordered + def test_select_myaddress_list(self): + """Select Address From List of Address""" + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # 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 + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) + # this is for scrolling Nav drawer + self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") + # assert for checking scroll function + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + # this is for opening My Address screen + self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=2) + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + + + @ordered + def test_show_Qrcode(self): + """Show the Qr code of selected address""" + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + # Click on Address to open popup + self.cli.wait_click('//MDList[0]/CustomTwoLineAvatarIconListItem[0]', timeout=2) + # Check the Popup is opened + self.assertExists('//MyaddDetailPopup//MDLabel[@text=\"Show QR code\"]', timeout=2) + # Cick on 'Show QR code' button to view QR Code + self.cli.wait_click('//MyaddDetailPopup//MDLabel[@text=\"Show QR code\"]') + # Check Current screen is QR Code screen + self.assertExists("//ScreenManager[@current=\"showqrcode\"]", timeout=2) + # Click on BACK button + self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2) + # Checking current screen(My Address) after BACK press + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + + + @ordered + def test_send_message_from(self): + """Send Message From send Button""" + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=5, value='myaddress') + # Click on Address to open popup + self.cli.wait_click('//MDList[0]/CustomTwoLineAvatarIconListItem[0]', timeout=2) + # Checking Popup Opened + self.assertExists('//MyaddDetailPopup//MDLabel[@text=\"Send message from\"]', timeout=2) + # Click on Send Message Button to redirect Create Screen + self.cli.wait_click('//MyaddDetailPopup//MDRaisedButton[0]/MDLabel[0]', timeout=2) + # Checking Current screen(Create) + self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2) + # Entering Receiver Address + self.cli.setattr( + '//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", data[1]) + # Checking Receiver Address filled or not + self.assertNotEqual('//DropDownWidget//MyTextInput[0]', '') + # ADD SUBJECT + self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', 'Hey this is Demo Subject') + # Checking Subject Field is Entered + self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', '') + # ADD MESSAGE BODY + self.cli.setattr('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[0]', + 'text', 'Hey,i am sending message directly from MyAddress book') + # Checking Message body is Entered + self.assertNotEqual('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text]', '') + # Click on Send Icon + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=3) + self.cli.sleep(2) # Send Messages takes 2 seconds to send message so need to user sleep + # Checking Current screen after Send a message + self.assert_wait_no_except('//ScreenManager[@current]', timeout=5, value='inbox') + + @ordered + def test_disable_address(self): + """Disable Addresses""" + # this is for checking current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=5, value='inbox') + # this is for opening Nav drawer + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=4) + # checking state of Nav drawer + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=4) + # this is for scrolling Nav drawer + self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") + # assert for checking scroll function + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=4) + # this is for opening setting screen + self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=4) + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + # ADDRESS DISABLED + # self.cli.sleep(1) + self.cli.wait_click('//Thumb', timeout=2) + # CLICKING ON DISABLE ACCOUNT TO OPEN POPUP + self.click_on('//MyAddress//MDList[0]/CustomTwoLineAvatarIconListItem[0]', seconds=2) + # Checking the pop is Opened + self.assertExists('//MDDialog[@text=\"Address is not currently active. Please click on Toggle button to active it.\"]', timeout=2) + # Clicking on 'Ok' Button To Dismiss the pop + self.click_on('//MDFlatButton[@text=\"Ok\"]', seconds=2) + self.assertNotExists('//MDDialog[@text=\"Address is not currently active. Please click on Toggle button to active it.\"]', timeout=2) + # ADDRESS ENABLED + self.click_on('//Thumb', seconds=2) + # self.assertExists('//Thumb[@active=\"False\"]', timeout=2) + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index 10129d73..deb014c7 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -6,8 +6,7 @@ import os import shutil import tempfile from time import time, sleep -from turtle import Turtle, pd - +from telenium.client import TeleniumHttpException from telenium.tests import TeleniumTestCase _files = ( @@ -64,15 +63,50 @@ class TeleniumTestProcess(TeleniumTestCase): pass cleanup() - def assertCheck_app_launch(self, selector, timeout=-1): - """This method is written to check the application is launched otherwise it will wait untill timeout value""" - while timeout > 0: + 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: - self.assertTrue(selector, 'inbox') - timeout -= 0.3 - except: - raise Exception("Timeout") - sleep(0.3) + 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) + def swipe_drag(self, is_drag_open, timeout=-1): + start = time() + deadline = start + timeout + while time() < deadline: + try: + if is_drag_open: + print('except --------------1', is_drag_open) + self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]') + self.assertEqual(is_drag_open, True) + self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon=\"trash-can\"]', timeout=5) + print('except --------------2', is_drag_open) + break + else: + print('except --------------3', is_drag_open) + self.cli.drag( + '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', + '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 1) + print('except --------------4', is_drag_open) + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]') + print('except --------------5', is_drag_open) + sleep(0.2) + continue + except TeleniumHttpException: + print('------------------6-') + sleep(0.2) + continue + # self.assertEqual(is_drag_open, True) + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon=\"trash-can\"]', timeout=5) def click_on(self, xpath, seconds=0.3): """this method is used for on_click event with time""" @@ -110,4 +144,4 @@ 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) diff --git a/src/bitmessagekivy/tests/test_allmail_message.py b/src/bitmessagekivy/tests/test_allmail_message.py index 6f2d8078..e90fc017 100644 --- a/src/bitmessagekivy/tests/test_allmail_message.py +++ b/src/bitmessagekivy/tests/test_allmail_message.py @@ -7,13 +7,12 @@ class AllMailMessage(TeleniumTestProcess): @ordered def test_show_allmail_list(self): """Show All Messages on Mail Screen/Window""" - try: - # checking current screen - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) - except: - self.cli.sleep(8) - # checking current screen - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # This is for checking the Side nav Bar id 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=3) # checking state of Nav drawer diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py index e22e0028..b45ef251 100644 --- a/src/bitmessagekivy/tests/test_create_random_address.py +++ b/src/bitmessagekivy/tests/test_create_random_address.py @@ -4,6 +4,9 @@ from .telenium_process import TeleniumTestProcess, cleanup from .common import ordered from random import choice from string import ascii_lowercase +from time import time, sleep +from telenium.client import TeleniumHttpException + class CreateRandomAddress(TeleniumTestProcess): """This is for testing randrom address creation""" @@ -13,19 +16,35 @@ class CreateRandomAddress(TeleniumTestProcess): os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir() cleanup() super(TeleniumTestProcess, cls).setUpClass() - + @ordered def test_login_screen(self): """Clicking on Proceed Button to Proceed to Next Screen.""" - print("=====================Test - Login Screen=====================") - self.cli.sleep(8) - # Checking current Screen(Login screen) - self.assertExists("//Login[@name~=\"login\"]", timeout=3) + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=20, value='login') + # self.assertExists("//Login[@name~=\"login\"]", timeout=3) # Clicking on Proceed Next Button - self.cli.wait_click( - '//Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2) + # self.assertExists("//ScreenManager[@current=\"login\"]", timeout=5) + print(self.cli.getattr('//ScreenManager[@current]', 'current'), '--------------------------------------') + get_screen_value = self.cli.getattr('//ScreenManager[@current]', 'current') + start = time() + deadline = start + 5 + while time() < deadline: + self.cli.click_on( + '//Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[@text=\"Proceed Next\"]') + try: + if self.cli.getattr('//ScreenManager[@current]', 'current') == 'random': + self.assertTrue(get_screen_value, 'random') + break + except TeleniumHttpException: + + sleep(0.1) + continue + raise AssertionError('timeout') # Checking Current Screen(Random Screen) after Clicking on Proceed Next Button - self.assertExists("//Random[@name~=\"random\"]", timeout=2) + print(self.cli.getattr('//ScreenManager[@current]', 'current'), '--------------------------------------') + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='random') + @ordered def test_random_screen(self): diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py index c536ef58..844ae474 100644 --- a/src/bitmessagekivy/tests/test_myaddress_screen.py +++ b/src/bitmessagekivy/tests/test_myaddress_screen.py @@ -1,42 +1,42 @@ from .telenium_process import TeleniumTestProcess from .common import ordered - data = [ 'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h', 'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr' ] + class MyAddressScreen(TeleniumTestProcess): """MyAddress Screen Functionality Testing""" @ordered def test_select_myaddress_list(self): """Select Address From List of Address""" - print("=====================Test -Select Address From List of Address=====================") - self.cli.sleep(8) - # this is for checking current screen - self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=3) + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # 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=2) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) # this is for scrolling Nav drawer self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") # assert for checking scroll function self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) - # self.assertExists('//NavigationItem[@text=\"My addresses\"]', timeout=2) - # this is for opening setting screen + # this is for opening My Address screen self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=2) # Checking current screen - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) @ordered def test_show_Qrcode(self): """Show the Qr code of selected address""" - print("=====================Test -Show QR code of selected address=====================") # Checking current screen - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) # Click on Address to open popup self.cli.wait_click('//MDList[0]/CustomTwoLineAvatarIconListItem[0]', timeout=2) # Check the Popup is opened @@ -44,19 +44,17 @@ class MyAddressScreen(TeleniumTestProcess): # Cick on 'Show QR code' button to view QR Code self.cli.wait_click('//MyaddDetailPopup//MDLabel[@text=\"Show QR code\"]') # Check Current screen is QR Code screen - self.assertExists("//ShowQRCode[@name~=\"showqrcode\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"showqrcode\"]", timeout=2) # Click on BACK button self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2) # Checking current screen(My Address) after BACK press - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) @ordered def test_send_message_from(self): - """Send Message From Send Message From Button""" - print("=====================Test -Send Message From Send Message From Button=====================") - self.cli.sleep(2) - # Checking current screen - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) + """Send Message From send Button""" + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=5, value='myaddress') # Click on Address to open popup self.cli.wait_click('//MDList[0]/CustomTwoLineAvatarIconListItem[0]', timeout=2) # Checking Popup Opened @@ -64,57 +62,23 @@ class MyAddressScreen(TeleniumTestProcess): # Click on Send Message Button to redirect Create Screen self.cli.wait_click('//MyaddDetailPopup//MDRaisedButton[0]/MDLabel[0]', timeout=2) # Checking Current screen(Create) - self.assertExists("//Create[@name~=\"create\"]", timeout=2) - # Entering Receiver Address + self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2) + # Entering Receiver Address self.cli.setattr( '//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", data[1]) # Checking Receiver Address filled or not self.assertNotEqual('//DropDownWidget//MyTextInput[0]', '') - # ADD SUBJECT + # ADD SUBJECT self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', 'Hey this is Demo Subject') # Checking Subject Field is Entered self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', '') - # ADD MESSAGE BODY - self.cli.setattr('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[0]', - 'text', 'Hey,i am sending message directly from MyAddress book') + # ADD MESSAGE BODY + self.cli.setattr( + '//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[0]', 'text', + 'Hey,i am sending message directly from MyAddress book') # Checking Message body is Entered self.assertNotEqual('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text]', '') # Click on Send Icon self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=3) - self.cli.sleep(2) # Send Messages takes 2 seconds to send message so need to user sleep - # Checking Current screen after Send a message - self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=3) - - @ordered - def test_disable_address(self): - """Disable Addresses""" - self.cli.sleep(3) - # this is for checking current screen - self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=4) - # this is for opening Nav drawer - self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=4) - # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=4) - # this is for scrolling Nav drawer - self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") - # assert for checking scroll function - self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=4) - # self.assertExists('//NavigationItem[@text=\"My addresses\"]', timeout=4) - # this is for opening setting screen - self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=4) - # Checking current screen - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=4) - # ADDRESS DISABLED - self.cli.sleep(1) - self.cli.wait_click('//Thumb', timeout=2) - # CLICKING ON DISABLE ACCOUNT TO OPEN POPUP - self.click_on('//MyAddress//MDList[0]/CustomTwoLineAvatarIconListItem[0]', seconds=2) - # Checking the pop is Opened - self.assertExists('//MDDialog[@text=\"Address is not currently active. Please click on Toggle button to active it.\"]', timeout=2) - # Clicking on 'Ok' Button To Dismiss the pop - self.click_on('//MDFlatButton[@text=\"Ok\"]', seconds=2) - self.assertNotExists('//MDDialog[@text=\"Address is not currently active. Please click on Toggle button to active it.\"]', timeout=2) - # ADDRESS ENABLED - self.click_on('//Thumb', seconds=2) - # self.assertExists('//Thumb[@active=\"False\"]', timeout=2) - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) + # Checking Current screen after Sending a message + self.assert_wait_no_except('//ScreenManager[@current]', timeout=5, value='inbox') diff --git a/src/bitmessagekivy/tests/test_network_screen.py b/src/bitmessagekivy/tests/test_network_screen.py index a9198c5f..9c297cc0 100644 --- a/src/bitmessagekivy/tests/test_network_screen.py +++ b/src/bitmessagekivy/tests/test_network_screen.py @@ -6,25 +6,25 @@ class NetworkStatusScreen(TeleniumTestProcess): def test_network_status(self): """Show Netwrok Status""" - try: - # checking current screen - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) - except: - self.cli.sleep(8) - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # This is for checking the Side nav Bar id 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=2) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) # this is for scrolling Nav drawer self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") # assert for checking scroll function - self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=5) # Clicking on Network Status tab - self.cli.wait_click('//NavigationItem[@text=\"Network status\"]', timeout=2) + self.cli.wait_click('//NavigationItem[@text=\"Network status\"]', timeout=5) # checking current screen - self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=5) # Clicking on Processes Tab - self.cli.wait_click('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"]', timeout=2) + self.cli.wait_click('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"]', timeout=3) # this is for checking current screen - self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=3) diff --git a/src/bitmessagekivy/tests/test_payment_subscription.py b/src/bitmessagekivy/tests/test_payment_subscription.py index 59998df3..ec2df8b2 100644 --- a/src/bitmessagekivy/tests/test_payment_subscription.py +++ b/src/bitmessagekivy/tests/test_payment_subscription.py @@ -1,22 +1,21 @@ -from requests import sessions from .telenium_process import TeleniumTestProcess class PaymentScreen(TeleniumTestProcess): """SubscriptionPayment Screen Functionality Testing""" - def test_select_subscripton(self): - """Select Subscripton From List of Subscriptons""" - try: - # checking current screen - self.assertExists("//Scre enManager[@current=\"inbox\"]", timeout=5) - except: - self.cli.sleep(8) - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + def test_select_subscription(self): + """Select Subscription From List of Subscriptions""" + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # This is for checking the Side nav Bar id 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=3) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) # Dragging from sent to inbox to get Payment tab self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") # assert for checking scroll function @@ -24,9 +23,11 @@ class PaymentScreen(TeleniumTestProcess): # this is for opening Payment screen self.cli.wait_click('//NavigationItem[@text=\"Purchase\"]', timeout=2) # Assert for checking Current Screen - self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=3) + # self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=3) + self.assert_wait_no_except('//ScreenManager[@current]', timeout=2, value='Payment') # Scrolling Down Product list - self.click_on('//ProductCategoryLayout[0]/ProductLayout[1]', seconds=1) + self.cli.wait_click('//ProductCategoryLayout[0]/ProductLayout[1]', timeout=3) + # self.click_on('//ProductCategoryLayout[0]/ProductLayout[1]', seconds=1) self.drag( '//ProductCategoryLayout[0]/ProductLayout[1]', '//ProductCategoryLayout[0]/ProductLayout[0]') @@ -34,10 +35,12 @@ class PaymentScreen(TeleniumTestProcess): self.assertCheckScrollDown('//Payment//ScrollView[0]', timeout=3) # Click on BUY Button self.cli.wait_click('//MDRaisedButton[@text=\"BUY\"]', timeout=2) + self.assert_wait_no_except('//ScreenManager[@current]', timeout=2, value='payment') # CLick on the Payment Method self.cli.click_on('//ScrollView[0]/ListItemWithLabel[0]') # Check pop up is opened - self.assertEqual(self.cli.getattr('//PaymentMethodLayout/BoxLayout[0]/MDLabel[0]', 'text'), 'Select Payment Method') + self.assertEqual(self.cli.getattr('//PaymentMethodLayout/BoxLayout[0]/MDLabel[0]', 'text'), + 'Select Payment Method') # Click out side to dismiss the popup self.cli.wait_click('//MDRaisedButton[3]', timeout=2) # Checking Current screen(Payment screen) diff --git a/src/bitmessagekivy/tests/test_sent_message.py b/src/bitmessagekivy/tests/test_sent_message.py index 6caec3fc..642e2d0c 100644 --- a/src/bitmessagekivy/tests/test_sent_message.py +++ b/src/bitmessagekivy/tests/test_sent_message.py @@ -16,7 +16,6 @@ class SendMessage(TeleniumTestProcess): Sending Message From Inbox Screen opens a pop-up(screen)which send message from sender to reciever """ - print("=======Test - Sending Message From Inbox Screen with validation Checks=======") self.cli.sleep(8) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) diff --git a/src/bitmessagekivy/tests/test_setting_screen.py b/src/bitmessagekivy/tests/test_setting_screen.py index 5060eaa5..2ba5cfd6 100644 --- a/src/bitmessagekivy/tests/test_setting_screen.py +++ b/src/bitmessagekivy/tests/test_setting_screen.py @@ -6,15 +6,16 @@ class SettingScreen(TeleniumTestProcess): def test_setting_screen(self): """Show Setting Screen""" - # self.cli.sleep(8) - self.assertCheck_app_launch('//ScreenManager[@current]', timeout=5) - # print(self.assertTrue('//ScreenManager[@current]', 'inbox'), "self.assertTrue('//ScreenManager[@current]', 'inbox')self.assertTrue('//ScreenManager[@current]', 'inbox')self.assertTrue('//ScreenManager[@current]', 'inbox')self.assertTrue('//ScreenManager[@current]', 'inbox')") - # self.assertTrue('//ScreenManager[@current]', 'inbox') - # self.assertCheck_app_launch('//ScreenManager[@current=\"inbox\"]', timeout=5) + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # This is for checking the Side nav Bar id 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=2) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) # this is for scrolling Nav drawer self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") # assert for checking scroll function diff --git a/src/bitmessagekivy/tests/test_trash_message.py b/src/bitmessagekivy/tests/test_trash_message.py index 7052ece7..719773e7 100644 --- a/src/bitmessagekivy/tests/test_trash_message.py +++ b/src/bitmessagekivy/tests/test_trash_message.py @@ -1,3 +1,4 @@ +from time import sleep from .telenium_process import TeleniumTestProcess @@ -6,43 +7,97 @@ class TrashMessage(TeleniumTestProcess): def test_delete_trash_message(self): """Delete Trash message permanently from trash message listing""" - try: - # checking current screen - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) - except: - self.cli.sleep(8) - # checking current screen - self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=18, value='inbox') + # This is for checking the Side nav Bar id 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 self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) # this is for opening Trash screen - self.click_on('//NavigationItem[@text=\"Trash\"]', seconds=2) + self.cli.wait_click('//NavigationItem[@text=\"Trash\"]', timeout=3) # checking current screen(Trash Screen) - self.assertExists("//ScreenManager[@current=\"trash\"]", timeout=3) - # Checking Trash Icon is in disable state - self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'True') - # This is for swiping message to activate delete icon. - self.drag( + # self.assertExists("//ScreenManager[@current=\"trash\"]", timeout=3) + self.assert_wait_no_except('//ScreenManager[@current]', timeout=5, value='trash') + self.cli.sleep(2) + self.cli.drag( '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', - '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]') + '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 1) + # Checking Trash Icon is in disable state + # self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', False) + # is_trash_icon = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]/MDIconButton[@disabled]', 'disabled') + # self.assertEqual(is_trash_icon, True) + # is_drag_open = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', '_opens_process') + # self.assertEqual(is_drag_open, False) + # print(is_drag_open, '=s--------------------------------------1') + + # self.cli.sleep(3) + # self.cli.wait_click('//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', timeout=5) + # This is for swiping message to activate delete icon. + + # self.swipe_drag(is_trash_icon, timeout=5) + # self.swipe_drag(is_drag_open, timeout=5) + # self.cli.sleep(1) + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]', timeout=2) + + # self.cli.drag( + # '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', + # '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 1) + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]', timeout=2) + + # is_drag_open = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', '_opens_process') + # self.assertEqual(is_drag_open, False) + # print(is_drag_open, '--------------------------------------2') + # Assert to check the drag is worked (Trash icon Activated) - self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'False') + # self.assertExists("//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon~=\"trash-can\"]", timeout=2) + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]') + # self.assertEqual(is_trash_icon, False) + # self.assertEqual(is_trash_icon, False) # Checking the Trash Icon after swipe. - self.assertExists("//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon~=\"trash-can\"]", timeout=2) + # Clicking on Trash icon to open Confirm delete pop up - self.click_on('//MDList[0]/CustomSwipeToDeleteItem[0]', seconds=1) - # Checking Confirm delete Popup is Opened - self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', 'True') - # clicking on Trash Box icon to delete message. - self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[0]', timeout=2) - # Checking the popup screen is closed. - self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', 'False') - # Clicking on 'Yes' Button on Popup to confirm delete. - self.click_on('//MDFlatButton[@text=\"Yes\"]', seconds=1.1) + # self.cli.wait_click('//MDList[0]/Cust omSwipeToDeleteItem[0]', timeout=3) + # checking current screen(Trash Screen) + # self.cli.sleep(3) + # self.cli.wait_click('//NavigationItem[@text=\"Trash\"]', timeout=3) + # self.cli.sleep(3) + + # Checking Confirm delete Popup is Opened + # self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', True) + + # clicking on Trash Box icon to delete message. + # self.cli.click_on('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon=\"trash-can\"]') + # self.assertEqual(is_drag_open, True) + sleep(5) + + self.cli.click_on('//Trash//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon=\"trash-can\"]') + print(self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon]', 'icon'), '=====================icon') + # self.assert_wait_no_except('//ScreenManager[@current]', timeout=6, value='trash') + sleep(5) + # Checking the popup screen is closed. + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon=\"trash-can\"]', timeout=5) + # is_drag_open = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', '_opens_process') + # self.assertEqual(is_drag_open, False) + # print(is_drag_open, '--------------------------------------3') + + + # self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', True) + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='trash') + is_trash_icon = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]/MDIconButton[@disabled]', 'disabled') + # self.cli.sleep(10) + is_trash_icon = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[0]/MDCardSwipeLayerBox[0]/MDIconButton[@disabled]', 'disabled') + # self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon=\"trash-can\"]', timeout=5) + is_drag_open = self.cli.getattr('//Trash//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', '_opens_process') + # self.assertEqual(is_drag_open, False) + # print(is_drag_open, '--------------------------------------4') + + # Clicking on 'Yes' Button on Popup to confirm delete. + # self.cli.wait_click('//MDFlatButton[@text=\"Yes\"]', timeout=5) # checking current screen(Trash Screen) - self.assertExists("//ScreenManager[@current=\"trash\"]", timeout=2) total_trash_msgs = len(self.cli.select("//CustomSwipeToDeleteItem")) # Checking messages count after delete. self.assertEqual(total_trash_msgs, 1)