This repository has been archived on 2025-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2025-02-02/src/bitmessagekivy/tests/test_addressbook.py

135 lines
7.6 KiB
Python
Raw Normal View History

2021-07-19 10:21:48 +02:00
from tkinter.constants import S
from .telenium_process import TeleniumTestProcess
from .common import ordered
2021-04-08 14:09:05 +02:00
data = [
'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h',
'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr'
]
2021-03-06 00:14:43 +01:00
class AddressBook(TeleniumTestProcess):
"""AddressBook Screen Functionality Testing"""
@ordered
2021-03-06 00:14:43 +01:00
def test_save_address(self):
"""Save Address On Address Book Screen/Window"""
print("=====================Test -Save Address In Address Book=====================")
2021-07-23 09:01:38 +02:00
self.cli.sleep(8)
2021-07-19 10:21:48 +02:00
# this is for checking current screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=3)
# this is for opening Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=2)
# checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# 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 setting screen
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
2021-03-06 00:14:43 +01:00
self.cli.execute('app.addingtoaddressbook()')
2021-07-19 10:21:48 +02:00
# Click on Label field to check validation
2021-07-22 12:04:32 +02:00
self.cli.wait_click('//GrashofPopup/BoxLayout[0]/MDTextField[@hint_text=\"Label\"]', timeout=2)
2021-07-19 10:21:48 +02:00
# Checking the Label Field shows Validation for empty string
self.assertExists('//GrashofPopup/BoxLayout[0]/MDTextField[@text=\"\"]', timeout=2)
# # Click on Address Field
2021-07-22 12:04:32 +02:00
self.cli.wait_click('//GrashofPopup/BoxLayout[0]/MDTextField[@hint_text=\"Address\"]', timeout=2)
2021-07-19 10:21:48 +02:00
# Checking the Address Field shows Validation for empty string
self.assertExists('//GrashofPopup/BoxLayout[0]/MDTextField[@text=\"\"]', timeout=2)
# Click On save Button to check Field validation
self.cli.wait_click('//MDRaisedButton[0]', timeout=2)
# Add Label to label Field
2021-07-22 12:04:32 +02:00
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[@hint_text=\"Label\"]', 'text', 'test1')
2021-07-19 10:21:48 +02:00
# Add incorrect Address to Address Field to check validation
2021-07-22 12:04:32 +02:00
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[@hint_text=\"Address\"]', 'text', data[0])
2021-07-19 10:21:48 +02:00
# Click on Save Button to check the address is correct or not
2021-07-22 12:04:32 +02:00
self.cli.wait_click('//MDRaisedButton[@text=\"Save\"]')
2021-07-19 10:21:48 +02:00
# Add Correct Address
2021-07-22 12:04:32 +02:00
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[@hint_text=\"Address\"]', 'text', 'BM-2cX78L9CZpb6GGC3rRVizYiUBwHELMLybd')
2021-07-19 10:21:48 +02:00
# Click on Save Button
2021-07-22 12:04:32 +02:00
self.cli.wait_click('//MDRaisedButton[@text=\"Save\"]', timeout=2)
2021-07-19 10:21:48 +02:00
# Check Current Screen (Address Book)
self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2)
# Checking Number of addresses increased
address_book_msgs = len(self.cli.select("//SwipeToDeleteItem"))
self.assertEqual(address_book_msgs, 1)
2021-03-06 00:14:43 +01:00
@ordered
def test_cancel_addressbook_popup(self):
2021-03-06 00:14:43 +01:00
"""Cancel Address"""
print("=====================Test -Cancel Address Add Popup=====================")
2021-07-27 08:28:50 +02:00
# Click on Account-Plus Icon to open popup for add Address
2021-03-06 00:14:43 +01:00
self.cli.execute('app.addingtoaddressbook()')
2021-07-19 10:21:48 +02:00
# Add Label to label Field
2021-05-19 10:27:10 +02:00
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[0]', 'text', 'test2')
2021-07-19 10:21:48 +02:00
# Add Address to Address Field
2021-05-19 10:27:10 +02:00
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]', 'text', data[0])
2021-07-19 10:21:48 +02:00
# Click on Save Button
self.cli.wait_click('//MDRaisedButton[1]', timeout=2)
# Check Current Screen (Address Book)
self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2)
2021-03-06 00:14:43 +01:00
@ordered
2021-03-06 00:14:43 +01:00
def test_send_message_to_addressbook(self):
"""Directly Send Message To The User"""
print("=====================Test -Directly Send Message To The User=====================")
2021-07-19 10:21:48 +02:00
# Check Current Screen (Address Book)
self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2)
# Click on a Address to show address Details
self.cli.wait_click(
'//AddressBook/BoxLayout[0]//SwipeToDeleteItem[0]', timeout=2)
# Checking the pop us opened
self.assertNotExists('//AddbookDetailPopup//MDDialog[@state~=\"closed\"]', timeout=2)
# Click on the Send to message Button
self.cli.wait_click('//MDRaisedButton[0]', timeout=2)
# Redirected to message composer screen(create)
self.assertExists("//Create[@name~=\"create\"]", timeout=2)
# Open and select Sender's Address from DropDown
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/MDTextField[0]', 'text', 'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr')
# Checking the Sender's Field is Entered
2021-07-22 12:04:32 +02:00
self.assertNotEqual('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/MDTextField[@text]', '')
2021-07-19 10:21:48 +02:00
# ADD SUBJECT
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Demo Subject')
# Checking Subject Field is Entered
self.assertExists('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[@text=\"Demo Subject\"]', timeout=2)
# ADD MESSAGE BODY
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[0]',
2021-07-27 08:28:50 +02:00
'text', 'Hey,This is draft Message Body from Address Book')
2021-07-19 10:21:48 +02:00
# Checking Message body is Entered
2021-07-22 12:04:32 +02:00
self.assertNotEqual('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[@text]', '')
2021-07-19 10:21:48 +02:00
# Click on Send Icon
2021-07-22 12:04:32 +02:00
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=3)
2021-07-19 10:21:48 +02:00
# After Click send, Screen is redirected to Inbox screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
2021-03-06 00:14:43 +01:00
@ordered
2021-03-06 00:14:43 +01:00
def test_delete_address_from_address_contact(self):
"""Delete Address From Address Book"""
print("=====================Test -Delete Address From Address Book=====================")
2021-07-19 10:21:48 +02:00
# this is for checking current screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=3)
# this is for opening Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=2)
# checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# this is for opening setting screen
self.cli.wait_click('//NavigationItem[@text=\"Address Book\"]', timeout=2)
# Checking current screen
self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2)
# Swipe to delete
2021-07-22 12:04:32 +02:00
self.assertTrue('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'True')
self.drag(
'//MDList[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]',
'//MDList[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]')
# Click on trash-can icon
2021-07-22 12:04:32 +02:00
self.cli.wait_click('//MDList[0]//SwipeToDeleteItem[0]', timeout=3)
# Checking the trash icon is acrivated
self.assertTrue('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'False')
# Click on trash icon
self.cli.click_on('//MDList[0]//MDIconButton[@icon=\"delete-forever\"]')
# Checking current screen
2021-07-22 12:04:32 +02:00
self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2)