diff --git a/src/bitmessagekivy/tests/test_sent_message.py b/src/bitmessagekivy/tests/test_sent_message.py index 3368e165..e85c8ec5 100644 --- a/src/bitmessagekivy/tests/test_sent_message.py +++ b/src/bitmessagekivy/tests/test_sent_message.py @@ -1,51 +1,49 @@ -from telenium.client import TeleniumHttpException from .telenium_process import TeleniumTestProcess from .common import ordered 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' + test_subject = 'Test_Subject' + test_body = 'Hello This is test message body' + @ordered def test_validate_empty_form(self): """ Sending Message From Inbox Screen opens a pop-up(screen) which send message from sender to reciever """ - # Checking current Screen(Login screen) - self.assert_wait_no_except('//ScreenManager[@current]', timeout=10, value='login') + # Checking current Screen(Inbox screen) + self.assert_wait_no_except('//ScreenManager[@current]', timeout=10, value='inbox') # 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) - # Checking State of Sender's Address Input Field (Empty) + # Checking State of Sender's Address Input Field (should be Empty) self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=3) - # Click on Receiver's Address Field to check validation - # self.cli.wait_click('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=4) - # Checking State of Receiver's Address Input Field (Empty) + # Checking State of Receiver's Address Input Field (should be Empty) self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2) - # Click on Subject Field to check validation - # self.cli.wait_click('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=2) - # Checking State of Subject Input Field (Empty) + # Checking State of Subject Input Field (shoudl be 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=5) - # import pdb; pdb.set_trace() + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2) # Checking validation Pop up is Opened - 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) + self.assertExists('//MDDialog[@open]', timeout=5) + # Checking the 'Ok' Button is rendered + self.assertExists('//MDFlatButton[@text=\"Ok\"]', timeout=5) + # Click "OK" button to dismiss the Popup + self.cli.wait_click('//MDFlatButton[@text=\"Ok\"]', timeout=5) + # Checking the pop is closed + self.assertNotExists('//MDDialog[@open]', timeout=5) # 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. + Validate the half filled form and press back button to save message in draft box. """ # Checking current screen self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2) @@ -53,37 +51,43 @@ class SendMessage(TeleniumTestProcess): # 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 - self.assertEqual(self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open'), False) + 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') - # self.assertEqual(is_open, True) - print(is_open, '----------------------------------------') # Select Sender's Address from Dropdown self.cli.wait_click('//ComposerSpinnerOption[0]', timeout=3) # Assert to check Sender's address dropdown closed - self.assertEqual(self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open'), False) + is_open = self.cli.getattr('//Create//CustomSpinner[@is_open]', 'is_open') + self.assertEqual(is_open, False) + # Checking the sender address is selected + sender_address = self.cli.getattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[@text]', 'text') + self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"{}\"]'.format(sender_address), timeout=2) # Assert check for empty Subject Field - self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[0]', '') + self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=5) # ADD SUBJECT self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', self.test_subject) # Checking Subject Field is Entered - self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[text]', '') + self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"{}\"]'.format(self.test_subject), timeout=5) + # self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[text]', '') + # Checking BODY Field(EMPTY) self.assertExists('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"\"]', timeout=2) # ADD BODY self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[0]', 'text', self.test_body) # Checking BODY is Entered - self.assertNotEqual( - '//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[text]', '') + # self.assertNotEqual('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[text]', '') + # import pdb; pdb.set_trace() + self.assertExists('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"{}\"]'.format(self.test_body), timeout=2) # click on send icon - self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2) - # Checking validation so Pop up is Opened - self.assertExists('//MDDialog', timeout=2) - # clicked on ok button to close popup - self.cli.wait_click('//MDFlatButton[@text=\"Ok\"]', timeout=2) - # self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5) + # Checking validation Pop up is Opened + self.assertExists('//MDDialog', timeout=5) + # clicked on 'Ok' button to close popup + self.cli.wait_click('//MDFlatButton[@text=\"Ok\"]', timeout=5) + # Checking current screen after dialog dismiss self.assertExists("//ScreenManager[@current=\"create\"]", timeout=5) @ordered @@ -97,7 +101,8 @@ class SendMessage(TeleniumTestProcess): # Entering Receiver Address 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]', '') + # self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[text]', '') + self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"{}\"]'.format(test_address['autoresponder_address']), timeout=5) # Clicking on send icon self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5) # Checking the current screen