From 86b772865b4bd6a8d011a129a3bd34d2079ca0ec Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Mon, 19 Jul 2021 20:31:05 +0530 Subject: [PATCH] Added Dragging assert in all Test Cases --- src/bitmessagekivy/tests/telenium_process.py | 16 +++++++++++++- src/bitmessagekivy/tests/test_addressbook.py | 16 +++++--------- .../tests/test_create_random_address.py | 5 +++-- .../tests/test_payment_subscription.py | 21 +++++++++++++------ 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index 5e6a8ae8..a398d301 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -74,7 +74,7 @@ class TeleniumTestProcess(TeleniumTestCase): self.cli.sleep(0.3) def assertCheckScrollDown(self, selector, timeout=-1): - """this method is for checking scroll""" + """this method is for checking scroll Down""" start = time() while True: scroll_distance = self.cli.getattr(selector, 'scroll_y') @@ -86,3 +86,17 @@ class TeleniumTestProcess(TeleniumTestCase): if timeout > 0 and time() - start > timeout: raise Exception("Timeout") sleep(0.1) + + def assertCheckScrollUp(self, selector, timeout=-1): + """this method is for checking scroll UP""" + start = time() + while True: + scroll_distance = self.cli.getattr(selector, 'scroll_y') + if scroll_distance < 1.0: + self.assertGreaterEqual(scroll_distance, 0.0) + return True + if timeout == -1: + return False + if timeout > 0 and time() - start > timeout: + raise Exception("Timeout") + sleep(0.1) \ No newline at end of file diff --git a/src/bitmessagekivy/tests/test_addressbook.py b/src/bitmessagekivy/tests/test_addressbook.py index 34b9b6a7..7c730c82 100644 --- a/src/bitmessagekivy/tests/test_addressbook.py +++ b/src/bitmessagekivy/tests/test_addressbook.py @@ -31,11 +31,8 @@ class AddressBook(TeleniumTestProcess): self.cli.wait_click('//NavigationItem[@text=\"Address Book\"]', timeout=2) # Checking current screen self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2) - # Click on Account-Plus Icon to opeb popup for add Address self.cli.execute('app.addingtoaddressbook()') - # Checking the popup opened - # self.assertExists("//GrashofPopup/MDRaisedButton[@text=\"Save\"]", timeout=4) # Click on Label field to check validation self.cli.wait_click('//GrashofPopup/BoxLayout[0]/MDTextField[0]', timeout=2) # Checking the Label Field shows Validation for empty string @@ -114,8 +111,6 @@ class AddressBook(TeleniumTestProcess): def test_delete_address_from_address_contact(self): """Delete Address From Address Book""" print("=====================Test -Delete Address From Address Book=====================") - - # this is for checking current screen self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=3) # this is for opening Nav drawer @@ -126,12 +121,11 @@ class AddressBook(TeleniumTestProcess): self.cli.wait_click('//NavigationItem[@text=\"Address Book\"]', timeout=2) # Checking current screen self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2) - self.cli.sleep(3) - + # Swipe to delete self.cli.drag( '//MDList[0]/SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', '//MDList[0]/SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]',2) - self.cli.sleep(3) - - self.cli.wait_click( - '//AddressBook/BoxLayout[0]//SwipeToDeleteItem[0]', timeout=2) \ No newline at end of file + # Click on trash-can icon + self.cli.click_on('//MDList[0]/SwipeToDeleteItem[0]//MDIconButton[0]') + # Checking current screen + self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2) \ No newline at end of file diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py index 8f5864ae..e1e7e6b6 100644 --- a/src/bitmessagekivy/tests/test_create_random_address.py +++ b/src/bitmessagekivy/tests/test_create_random_address.py @@ -59,7 +59,7 @@ class CreateRandomAddress(TeleniumTestProcess): # Scroll Down to get New Address Tab self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") # Checking state of scrolled screen - self.assertExists('//NavigationItem[@text=\"New address\"]', timeout=3) + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) # Clicking on New Address Tab self.cli.wait_click('//NavigationItem[@text=\"New address\"]', timeout=3) self.cli.sleep(1) @@ -86,7 +86,8 @@ class CreateRandomAddress(TeleniumTestProcess): # Scrolling up to get address dropdown self.drag("//NavigationItem[@text=\"Address Book\"]", "//NavigationItem[@text=\"Settings\"]") # Checking scroll state - self.assertExists("//NavigationDrawerSubheader[@text~=\"Accounts\"]", timeout=2) + self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + # self.assertExists("//NavigationDrawerSubheader[@text~=\"Accounts\"]", timeout=2) # Clicking on Address Dropdown self.cli.wait_click('//NavigationItem[0]/CustomSpinner[0]', timeout=2) # Select address fron Address Dropdown diff --git a/src/bitmessagekivy/tests/test_payment_subscription.py b/src/bitmessagekivy/tests/test_payment_subscription.py index c9625507..2bb20f8d 100644 --- a/src/bitmessagekivy/tests/test_payment_subscription.py +++ b/src/bitmessagekivy/tests/test_payment_subscription.py @@ -17,18 +17,27 @@ class PaymentScreen(TeleniumTestProcess): self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") # assert for checking scroll function self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) - self.assertExists('//NavigationItem[@text=\"Purchase\"]', timeout=3) # this is for opening Payment screen - self.click_on('//NavigationItem[@text=\"Purchase\"]', seconds=2) + self.cli.wait_click('//NavigationItem[@text=\"Purchase\"]', timeout=2) # Assert for checking Current Screen - self.assertExists("//Payment[@name~=\"payment\"]", timeout=4) + self.assertExists("//Payment[@name~=\"payment\"]", timeout=3) + # Scrolling Down Product list + self.cli.sleep(0.5) self.drag( '//ProductCategoryLayout[0]/ProductLayout[1]', '//ProductCategoryLayout[0]/ProductLayout[0]') # assert for checking scroll function - self.assertExists('//MDRaisedButton[3]', timeout=3) + self.assertCheckScrollDown('//Payment//ScrollView[0]', timeout=3) + # Click on BUY Button self.cli.wait_click('//MDRaisedButton[@text=\"BUY\"]', timeout=2) - self.click_on('//ScrollView[0]/ListItemWithLabel[0]', seconds=1) - self.click_on('//MDRaisedButton[3]', seconds=1) + # Checking the pop up opend by clicking on BUY button + # self.assertExists('//PaymentMethodLayout/BoxLayout[0]/MDLabel[@text=\"Select Payment Method\"]', timeout=2) + # CLick on the Payment Method + self.cli.click_on('//ScrollView[0]/ListItemWithLabel[0]') + # Click checked + # self.assertExists('//PaymentMethodLayout/BoxLayout[0]/MDLabel[@text=\"Select Payment Method\"]', timeout=2) + # Click out side to dismiss the popup + self.cli.wait_click('//MDRaisedButton[3]', timeout=2) + # Checking Current screen(Payment screen) self.assertExists("//Payment[@name~=\"payment\"]", timeout=2) \ No newline at end of file