enhanced code quality

This commit is contained in:
shekhar-cis 2021-10-01 20:48:39 +05:30
parent 3d8992aed3
commit 3dba85fad9
Signed by untrusted user: shekhar-cis
GPG Key ID: 8B2A6C8D5F7F1635
3 changed files with 167 additions and 151 deletions

View File

@ -27,14 +27,15 @@ class CreateRandomAddress(TeleniumTestProcess):
# self.assertExists("//ScreenManager[@current=\"login\"]", timeout=5)
start = time()
deadline = start + 2
while time() < deadline:
try:
# Clicking on Proceed Next Button to redirect to "random" screen
self.cli.wait_click('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
except:
except TeleniumHttpException:
# Checking Current Screen(Random Screen) after Clicking on "Proceed Next" Button
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
# if not is_checked:
# # self.assertExists('//Screen[0]//AnchorLayout[1]//Check[@active=\"True\"]', timeout=5)
# self.cli.wait_click('//Screen[0]//AnchorLayout[1]//Check', timeout=2)
@ -72,19 +73,19 @@ class CreateRandomAddress(TeleniumTestProcess):
# self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=3)
# import pdb; pdb.set_trace()
self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=5)
num_of_addresses = len(self.cli.select('//MDList[0]/CustomTwoLineAvatarIconListItem'))
start = time()
deadline = start + 6
while time() < deadline:
try:
if num_of_addresses >= 1:
self.assertEqual(num_of_addresses, 1)
break
except TeleniumHttpException:
print('iexcept------------------------------------------')
continue
print(len(self.cli.select('//MDList[0]/CustomTwoLineAvatarIconListItem')), '>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# self.cli.sleep(10)
self.assertExists('//MDList[0]/CustomTwoLineAvatarIconListItem', timeout=10)
# self.cli.sleep(5)
# start = time()
# deadline = start + 7
# while time() < deadline:
# try:
# self.assertExists('//MDList[0]/CustomTwoLineAvatarIconListItem', timeout=7)
# except TeleniumHttpException:
# self.cli.sleep(0.1)
# continue
# print(len(self.cli.select('//MDList[0]/CustomTwoLineAvatarIconListItem')), '>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# # Clicking on Proceed Next Button to redirect to "random" screen
# self.cli.sleep(5)
# except:

View File

@ -9,67 +9,14 @@ class DraftMessage(TeleniumTestProcess):
def test_save_draft_message(self):
"""Select A Draft Screen From Navigaion-Drawer-Box Then
Send a drafted message """
print("=====================Test - Select A Draft Screen From Navigaion-Drawer-Box=====================")
self.cli.sleep(8)
# this is for opening Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
# checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# Click to open Inbox
self.cli.wait_click('//NavigationItem[@text=\"Inbox\"]', timeout=2)
# Checking Inbox Screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2)
# Due to animation and transition effect, it needed some halt otherwise it fails
self.cli.sleep(1)
# Checking current Screen(Login screen)
self.assert_wait_no_except('//ScreenManager[@current]', timeout=10, value='login')
# Click on Composer Icon(Plus icon)
self.cli.wait_click('//ComposerButton[0]/MDFloatingActionButton[@icon=\"plus\"]', timeout=2)
# Checking Message Composer Screen(Create)
self.assertExists("//Create[@name~=\"create\"]", timeout=4)
# ADD SENDER'S ADDRESS
# Checking State of Sender's Address Input Field (Empty)
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=2)
# Open Sender's Address DropDown
self.cli.wait_click(
'//DropDownWidget/ScrollView[0]//BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]', timeout=2)
# Due to animation and transition effect, it needed some halt otherwise it fails
self.cli.sleep(2)
# SENDER FIELD
# Select Sender's Address from Dropdown
self.cli.wait_click(
'//DropDownWidget/ScrollView[0]//BoxLayout[0]/CustomSpinner[0]', timeout=2)
self.cli.click_on('//ComposerSpinnerOption[0]')
# Assert to check Sender's address dropdown open or not
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[@text]', '')
# RECEIVER FIELD
# Checking Receiver Address Field
self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
# Entering Receiver Address
self.cli.setattr(
'//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", 'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
# Checking Receiver Address filled or not
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[@text]', '')
# CLICK BACK-BUTTON
self.cli.wait_click('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2)
# Checking current screen(Login) after BACK Press
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2)
self.cli.sleep(0.5)
# Click on Composer Icon(Plus icon)
self.cli.wait_click('//ComposerButton[0]/MDFloatingActionButton[@icon=\"plus\"]', timeout=2)
# Checking Message Composer Screen(Create)
self.assertExists("//Create[@name~=\"create\"]", timeout=4)
# ADD SENDER'S ADDRESS
# Checking State of Sender's Address Input Field (Empty)
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=2)
# Open Sender's Address DropDown
self.cli.wait_click(
'//Create//CustomSpinner[0]/ArrowImg[0]', timeout=2)
# Due to animation and transition effect, it needed some halt otherwise it fails
self.cli.sleep(2)
# Select Sender's Address from Dropdown
self.cli.wait_click(
'//DropDownWidget/ScrollView[0]//CustomSpinner[0]', timeout=2)
self.cli.click_on('//ComposerSpinnerOption[0]')
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=5)
# Assert to check Sender's address dropdown open or not
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[@text]', '')
@ -81,68 +28,122 @@ class DraftMessage(TeleniumTestProcess):
'//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", 'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
# Checking Receiver Address filled or not
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[@text]', '')
# ADD SUBJECT
self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', 'Another Draft message')
# Checking Subject Field is Entered
self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"Another Draft message\"]', timeout=2)
# CLICK BACK-BUTTON
self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2)
# Checking current screen(Login) after BACK Press
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2)
@ordered
def test_edit_and_resend_draft_messgae(self):
"""Select A Message From List of Messages Then
make changes and send it."""
print("=====================Test - Edit A Message From Draft Screen=====================")
# OPEN NAVIGATION-DRAWER
# this is for opening Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
# checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# Click to open Draft Screen
self.cli.wait_click('//NavigationItem[@text=\"Draft\"]', timeout=2)
# Checking Draft Screen
self.assertExists("//Draft[@name~=\"draft\"]", timeout=2)
# Due to animation and transition effect, it needed some halt otherwise it fails
self.cli.sleep(1)
# SHOW DRAFT MESSAGE AND SELECT FIRST MESSAGE
self.cli.wait_click('//SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]', timeout=2)
# Checking current screen Mail Detail
self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=2)
# CLICK EDIT BUTTON
self.cli.wait_click('//MDToolbar/BoxLayout[2]/MDActionTopAppBarButton[@icon=\"pencil\"]', timeout=2)
# Checking Current Screen 'Create'
self.assertExists("//Create[@name~=\"create\"]", timeout=2)
# ADD MESSAGE BODY
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[@text]',
'text', 'Hey,This is draft Message Body')
# 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)
# After Click send, Screen is redirected to Inbox screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
self.assertEqual(is_open, False)
# Open Sender's Address DropDown
self.cli.wait_click('//Create//CustomSpinner[0]/ArrowImg[0]', timeout=5)
# Checking the Address Dropdown is in open State
is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
# Select Sender's Address from Dropdown
self.cli.wait_click('//ComposerSpinnerOption[0]', timeout=5)
# Assert to check Sender's address dropdown closed
is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
self.assertEqual(is_open, False)
self.cli.sleep(5)
# # CLICK BACK-BUTTON
# self.cli.wait_click('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2)
# # Checking current screen(Login) after BACK Press
# self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=4)
# self.cli.sleep(0.5)
# # Click on Composer Icon(Plus icon)
# self.cli.wait_click('//ComposerButton[0]/MDFloatingActionButton[@icon=\"plus\"]', timeout=2)
# # Checking Message Composer Screen(Create)
# self.assertExists("//ScreenManager[@current=\"create\"]", timeout=4)
# # ADD SENDER'S ADDRESS
# # Checking State of Sender's Address Input Field (Empty)
# self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=2)
# # Assert to check Sender's address dropdown is closed
# is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
# self.assertEqual(is_open, False)
# # Open Sender's Address DropDown
# self.cli.wait_click('//Create//CustomSpinner[0]/ArrowImg[0]', timeout=5)
# # Checking the Address Dropdown is in open State
# is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
# # Select Sender's Address from Dropdown
# self.cli.wait_click('//ComposerSpinnerOption[0]', timeout=3)
# # Assert to check Sender's address dropdown is closed
# is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
# self.assertEqual(is_open, False)
# # Assert to check Sender's address dropdown open or not
# self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[@text]', '')
# # RECEIVER FIELD
# # Checking Receiver Address Field
# self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
# # Entering Receiver Address
# self.cli.setattr(
# '//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", 'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
# # Checking Receiver Address filled or not
# self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[@text]', '')
# # ADD SUBJECT
# self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', 'Another Draft message')
# # Checking Subject Field is Entered
# self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"Another Draft message\"]', timeout=2)
# # CLICK BACK-BUTTON
# self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2)
# # Checking current screen(Login) after BACK Press
# self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2)
# @ordered
# def test_edit_and_resend_draft_messgae(self):
# """Select A Message From List of Messages Then
# make changes and send it."""
# print("=====================Test - Edit A Message From Draft Screen=====================")
# # OPEN NAVIGATION-DRAWER
# # this is for opening Nav drawer
# self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
# # checking state of Nav drawer
# self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# # Click to open Draft Screen
# self.cli.wait_click('//NavigationItem[@text=\"Draft\"]', timeout=2)
# # Checking Draft Screen
# self.assertExists("//Draft[@name~=\"draft\"]", timeout=2)
# # Due to animation and transition effect, it needed some halt otherwise it fails
# self.cli.sleep(1)
# # SHOW DRAFT MESSAGE AND SELECT FIRST MESSAGE
# self.cli.wait_click('//SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]', timeout=2)
# # Checking current screen Mail Detail
# self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=2)
# # CLICK EDIT BUTTON
# self.cli.wait_click('//MDToolbar/BoxLayout[2]/MDActionTopAppBarButton[@icon=\"pencil\"]', timeout=2)
# # Checking Current Screen 'Create'
# self.assertExists("//Create[@name~=\"create\"]", timeout=2)
# # ADD MESSAGE BODY
# self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[@text]',
# 'text', 'Hey,This is draft Message Body')
# # 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)
# # After Click send, Screen is redirected to Inbox screen
# self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
# @ordered
# def test_delete_draft_message(self):
# """Delete A Message From List of Messages"""
# print("=====================Test - Delete A Message From List of Messages=====================")
# self.cli.sleep(2)
# # OPEN NAVIGATION-DRAWER
# # this is for opening Nav drawer
# self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
# # checking state of Nav drawer
# self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# # Click to open Draft Screen
# self.cli.wait_click('//NavigationItem[@text=\"Draft\"]', timeout=2)
# # Checking Draft Screen
# self.assertExists("//Draft[@name~=\"draft\"]", timeout=2)
# self.cli.sleep(1)
# self.cli.wait_click('//SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]', timeout=3)
# # Checking Current screen is Mail Detail
# self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=3)
# # Click on trash-can icon to delete
# self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"delete-forever\"]', timeout=2)
# # After Deleting, Screen is redirected to Draft screen
# self.assertExists("//Draft[@name~=\"draft\"]", timeout=1)
@ordered
def test_delete_draft_message(self):
"""Delete A Message From List of Messages"""
print("=====================Test - Delete A Message From List of Messages=====================")
self.cli.sleep(2)
# OPEN NAVIGATION-DRAWER
# this is for opening Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
# checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# Click to open Draft Screen
self.cli.wait_click('//NavigationItem[@text=\"Draft\"]', timeout=2)
# Checking Draft Screen
self.assertExists("//Draft[@name~=\"draft\"]", timeout=2)
self.cli.sleep(1)
self.cli.wait_click('//SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]', timeout=3)
# Checking Current screen is Mail Detail
self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=3)
# Click on trash-can icon to delete
self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"delete-forever\"]', timeout=2)
# After Deleting, Screen is redirected to Draft screen
self.assertExists("//Draft[@name~=\"draft\"]", timeout=1)

View File

@ -2,15 +2,15 @@ from telenium.client import TeleniumHttpException
from .telenium_process import TeleniumTestProcess
from .common import ordered
test_address = {'receiver': 'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h'}
test_address = {'autoresponder_address': 'BM-2cVWtdUzPwF7UNGDrZftWuHWiJ6xxBpiSP'}
class SendMessage(TeleniumTestProcess):
"""Sent Screen Functionality Testing"""
test_subject = 'Test Subject'
test_body = 'Hello, \n Hope your are doing good.\n\t This is test message body'
popup_var = 'Please fill the form completely'
@ordered
def test_send_message_and_validation(self):
def test_validate_empty_form(self):
"""
Sending Message From Inbox Screen
opens a pop-up(screen) which send message from sender to reciever
@ -32,20 +32,28 @@ class SendMessage(TeleniumTestProcess):
# Checking State of Subject Input Field (Empty)
self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=2)
# Click on Send Icon to check validation working
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2)
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5)
# import pdb; pdb.set_trace()
# Checking validation Pop up is Opened
self.assertExists('//MDDialog[@text=\"Please fill the form completely\"]', timeout=2)
# Click on 'Ok' to dismiss the Popup
self.cli.wait_click('//MDFlatButton[0]', timeout=2)
# Checking Pop up is closed
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2)
self.assertExists('//MDDialog', timeout=5)
# Click to dismiss the Popup
# self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5)
self.cli.wait_click('//MDFlatButton[@text=\"Ok\"]', timeout=2)
# Checking current screen after dialog dismiss
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=10)
@ordered
def test_validate_half_filled_form(self):
"""
Validation the half filled form and press back button to save message in draft box.
"""
# Checking current screen
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2)
# ADD SENDER'S ADDRESS
# Checking State of Sender's Address Input Field (Empty)
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=2)
# Assert to check Sender's address dropdown closed
is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
self.assertEqual(is_open, False)
self.assertEqual(self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open'), False)
# Open Sender's Address DropDown
self.cli.wait_click('//Create//CustomSpinner[0]/ArrowImg[0]', timeout=5)
# Checking the Address Dropdown is in open State
@ -55,8 +63,7 @@ class SendMessage(TeleniumTestProcess):
# Select Sender's Address from Dropdown
self.cli.wait_click('//ComposerSpinnerOption[0]', timeout=3)
# Assert to check Sender's address dropdown closed
is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open')
self.assertEqual(is_open, False)
self.assertEqual(self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open'), False)
# Assert check for empty Subject Field
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[0]', '')
# ADD SUBJECT
@ -73,15 +80,22 @@ class SendMessage(TeleniumTestProcess):
# click on send icon
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2)
# Checking validation so Pop up is Opened
self.assertExists('//MDDialog[@text=\"Please fill the form completely\"]', timeout=2)
self.assertExists('//MDDialog', timeout=2)
# clicked on ok button to close popup
self.cli.wait_click('//MDFlatButton[0]', timeout=2)
self.cli.wait_click('//MDFlatButton[@text=\"Ok\"]', timeout=2)
# self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2)
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=5)
@ordered
def test_sending_msg_fully_filled_form(self):
"""
Sending message when all fields are filled
"""
# ADD RECEIVER ADDRESS
# Checking Receiver Address Field
self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
# Entering Receiver Address
self.cli.setattr('//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", test_address['receiver'])
self.cli.setattr('//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", test_address['autoresponder_address'])
# Checking Receiver Address filled or not
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[text]', '')
# Clicking on send icon