From de0bc59b185f91a74fd98cc8c5634a14c62968ce Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 13 Oct 2021 17:23:14 +0530 Subject: [PATCH] added format() in myaddressbook test --- .../tests/test_myaddress_screen.py | 161 +++++++++--------- 1 file changed, 81 insertions(+), 80 deletions(-) diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py index c536ef58..da6c3236 100644 --- a/src/bitmessagekivy/tests/test_myaddress_screen.py +++ b/src/bitmessagekivy/tests/test_myaddress_screen.py @@ -2,41 +2,86 @@ from .telenium_process import TeleniumTestProcess from .common import ordered -data = [ - 'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h', - 'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr' -] +test_address = { + 'recipient': 'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr' +} + class MyAddressScreen(TeleniumTestProcess): """MyAddress Screen Functionality Testing""" + subject = 'Hey this is Demo Subject' + body = 'Hey i am sending message directly from MyAddress book' @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): + def test_send_message_from(self): + """Send Message From send Button""" + # This is for 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) + # 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[@text=\"Send message from\"]', 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", test_address['recipient']) + # Checking Receiver Address filled or not + # self.assertNotEqual('//DropDownWidget//MyTextInput[0]', '') + self.assertExists('//DropDownWidget//MyTextInput[@text=\"{}\"]'.format(test_address['recipient']), timeout=5) + # ADD SUBJECT + self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', self.subject) + # Checking Subject Field is Entered + # self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', '') + self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"{}\"]'.format(self.subject), timeout=5) + # ADD MESSAGE BODY + self.cli.setattr( + '//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[0]', 'text', + self.body) + # Checking Message body is Entered + # self.assertNotEqual('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text]', '') + self.assertExists('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"{}\"]'.format(self.body), timeout=5) + # Click on Send Icon + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5) + # Check for redirected screen (Inbox Screen) + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=7) + + @ordered + def test_show_qrcode(self): """Show the Qr code of selected address""" - print("=====================Test -Show QR code of selected address=====================") + # This is for checking the Side nav Bar is closed + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) + # checking state of Nav drawer + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + # Clicking on Sent Tab + self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=3) # 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,77 +89,33 @@ 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) + def test_sent_box(self): + """ + Checking Message in Sent Screen after sending a Message. + """ # Checking current screen - self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) - # 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("//Create[@name~=\"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.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) + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) # this is for opening Nav drawer - self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=4) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=4) + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) # this is for scrolling Nav drawer - self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") + self.drag("//NavigationItem[@text=\"Purchase\"]", "//NavigationItem[@text=\"My addresses\"]") # 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) + self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + # Clicking on Sent Tab + self.cli.wait_click('//NavigationItem[@text=\"Sent\"]', timeout=3) + # Checking current screen; Sent + self.assertExists("//ScreenManager[@current=\"sent\"]", timeout=3) + # Checking the message is rendered in sent box screen + self.assertExists('//SwipeToDeleteItem', timeout=5) + # Checking messages count in sent box + total_sent_msgs = len(self.cli.select("//SwipeToDeleteItem")) + self.assertEqual(total_sent_msgs, 1)