From 3126cabc01619ae850e9862050eb5c6b21d3e35c Mon Sep 17 00:00:00 2001 From: prachi Date: Sat, 18 Apr 2020 22:12:50 +0530 Subject: [PATCH] Create test case for new address screen --- src/test_kivy_bitmessgae_app.py | 33 ++++++++++++----------- src/test_telenium_cases.py | 48 ++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/test_kivy_bitmessgae_app.py b/src/test_kivy_bitmessgae_app.py index 0cf666dd..05ebf445 100644 --- a/src/test_kivy_bitmessgae_app.py +++ b/src/test_kivy_bitmessgae_app.py @@ -3,8 +3,9 @@ from telenium.tests import TeleniumTestCase import random import string import os -import test_telenium_cases - +import test_telenium_cases +from random import choice +from string import ascii_lowercase class TestBitMessageApp(TeleniumTestCase): @@ -29,29 +30,28 @@ class TestBitMessageApp(TeleniumTestCase): def test_random_screen(self): # if os.path.isdir("/home/cis/.config/PyBitmessage"): # pass - # else: - self.cli.setattr(u'/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Random[0]/ScrollView[0]/BoxLayout[0]/MDTextField[0]', "text", self.generate_random_string()) - time.sleep(5) + # else: + random_label = "" + for _ in range(10): + random_label += choice(ascii_lowercase) + self.cli.setattr(u'/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Random[0]/ScrollView[0]/BoxLayout[0]/MDTextField[0]', "text", random_label) + time.sleep(1) self.cli.wait_click(u'/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Random[0]/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/AnchorLayout[0]/MDRaisedButton[0]/MDLabel[0]') time.sleep(5) - def generate_random_string(self): - """Generate a random string of fixed length """ - # return ''.join(random.choice(letters) for i in range(stringLength)) - letters = string.ascii_letters - return ''.join(random.choice(letters) for i in range(10)) - - # lettersAndDigits = string.ascii_letters + string.digits - # return ''.join((random.choice(lettersAndDigits) for i in range(10))) - - + if __name__ == '__main__': TeleniumTestCase.start_process() TestBitMessageApp().runTest() + print("==================start from first screen=====================") TestBitMessageApp().test_login_screen() TestBitMessageApp().test_random_screen() + obj_11=test_telenium_cases.TestCreateNewAddress() + obj_11.test_create_new_address() + TestBitMessageApp().test_random_screen() obj=test_telenium_cases.TestSelectAddress() + obj.test_select_second_address() obj.test_select_address() obj_1=test_telenium_cases.TestSentMessage() obj_1.test_select_sent() @@ -63,4 +63,5 @@ if __name__ == '__main__': obj_1.test_archive_sent_message_from_list() obj_2=test_telenium_cases.TestDraftMessage() obj_2.test_select_draft_message() - \ No newline at end of file + # obj_11.test_random_screen() + \ No newline at end of file diff --git a/src/test_telenium_cases.py b/src/test_telenium_cases.py index 28583e7b..01d0e321 100644 --- a/src/test_telenium_cases.py +++ b/src/test_telenium_cases.py @@ -5,27 +5,54 @@ import string import os +class TestCreateNewAddress(TeleniumTestCase): + + def runTest(self): + print(self,"-------------Welcome To Kivy Testing Application Thirteenth Page-------------") + + def test_create_new_address(self): + time.sleep(5) + self.cli.execute('app.root.toggle_nav_drawer()') + time.sleep(4) + self.cli.drag("//NavigationDrawerSubheader[@text=\"All labels\"]","//NavigationDrawerIconButton[@text=\"All Mails\"]",2) + time.sleep(3) + self.cli.click_on('//NavigationDrawerIconButton[10]') + time.sleep(4) + self.cli.wait_click(u'/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Login[0]/ScrollView[0]/BoxLayout[0]/BoxLayout[2]/AnchorLayout[0]/MDRaisedButton[0]/MDLabel[0]') + + class TestSelectAddress(TeleniumTestCase): def runTest(self): print(self,"-------------Welcome To Kivy Testing Application second Page-------------") - def test_select_address(self): + def test_select_second_address(self): time.sleep(8) + data=[] + second_address=self.cli.getattr("//CustomTwoLineAvatarIconListItem[0]","secondary_text") + data.append(second_address) + return data + + def test_select_address(self): + time.sleep(6) self.cli.execute('app.root.toggle_nav_drawer()') time.sleep(5) + self.cli.drag("//NavigationDrawerSubheader[@text=\"All labels\"]","//NavigationDrawerIconButton[@text=\"Address Book\"]",2) + time.sleep(3) self.cli.click_on('//NavigationDrawerIconButton[0]') time.sleep(5) - self.cli.click_on('//NavigationDrawerIconButton[1]') + var = cli.getattr('//CustomSpinner[0]',"text") + -class TestSentMessage(TeleniumTestCase): +class TestSentMessage(TestSelectAddress): def runTest(self): print(self,"-------------Welcome To Kivy Testing Application Thirds Page-------------") def test_select_sent(self): print("ek issue h solve krna hai----") + time.sleep(5) self.cli.execute('app.root.toggle_nav_drawer()') time.sleep(5) self.cli.click_on('//NavigationDrawerIconButton[1]') @@ -36,11 +63,16 @@ class TestSentMessage(TeleniumTestCase): time.sleep(2) self.cli.click_on('//MyTextInput[0]') time.sleep(3) - self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/MyTextInput[0]',"text",'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J') + # TestSelectAddress().test_select_second_address() + self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/MyTextInput[0]',"text",TestSelectAddress().test_select_second_address()) time.sleep(3) self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/MDTextField[0]','text','heyyyyyy') time.sleep(3) - self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/MDTextField[1]','text','how are you this is body') + random_label="" + for char in "how are you this is message body": + random_label += char + self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/MDTextField[1]','text',random_label) + time.sleep(0.5) time.sleep(2) self.cli.click_on('//MDIconButton[2]') time.sleep(2) @@ -69,7 +101,11 @@ class TestSentMessage(TeleniumTestCase): time.sleep(3) self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/MDTextField[0]','text','Second') time.sleep(3) - self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/MDTextField[1]','text','Hey This is Second Message Body') + random_label="" + for char in "Hey This Is Second Message Body": + random_label += char + self.cli.setattr('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Create[0]/DropDownWidget[0]/ScrollView[0]/BoxLayout[0]/MDTextField[1]','text',random_label) + time.sleep(0.5) time.sleep(2) self.cli.click_on('//MDIconButton[2]') # time.sleep(2)