22 Test for creating new identity
33"""
44
5+ from time import sleep
56from random import choice
67from string import ascii_lowercase
78from .telenium_process import TeleniumTestProcess
8- from .common import skip_screen_checks
99from .common import ordered
1010
1111
1212class CreateRandomAddress (TeleniumTestProcess ):
1313 """This is for testing randrom address creation"""
14-
1514 @staticmethod
1615 def populate_test_data ():
1716 pass
@@ -23,38 +22,43 @@ def test_landing_screen(self):
2322 """Click on Proceed Button to Proceed to Next Screen."""
2423 # Checking current Screen(Login screen)
2524 self .assert_wait_no_except ('//ScreenManager[@current]' , timeout = 15 , value = 'login' )
26- # Click on "Proceed Next" Button to "generate random label for address" screen
27- # Some widgets cannot renders suddenly and become not functional so we used loop with a timeout.
28- self .assertExists ("//Screen[0]//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]" , timeout = 5 )
25+ self .assertExists (
26+ '''//Login//Screen[@name=\" check_screen\" ]'''
27+ '''//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]''' , timeout = 5
28+ )
2929 # Clicking on Proceed Next Button to redirect to "random" screen
30- self .cli .wait_click ('//Screen[0]//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]' , timeout = 5 )
30+ self .cli .wait_click (
31+ '''//Login//Screen[@name=\" check_screen\" ]'''
32+ '''//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]''' , timeout = 5
33+ )
3134 self .assertExists ("//ScreenManager[@current=\" random\" ]" , timeout = 5 )
3235
3336 @ordered
3437 def test_generate_random_address_label (self ):
3538 """Creating New Adress For New User."""
3639 # Checking the Button is rendered
3740 self .assertExists (
38- '//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/ MDTextField[@hint_text=\" Label\" ]' , timeout = 2 )
41+ '//Random//RandomBoxlayout// MDTextField[@hint_text=\" Label\" ]' , timeout = 1 )
3942 # Click on Label Text Field to give address Label
4043 self .cli .wait_click (
41- '//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1] /MDTextField[@hint_text=\" Label\" ]' , timeout = 2 )
44+ '//Random//RandomBoxlayout/ /MDTextField[@hint_text=\" Label\" ]' , timeout = 2 )
4245 # Enter a Label Randomly
4346 random_label = ""
4447 for _ in range (10 ):
4548 random_label += choice (ascii_lowercase )
46- self .cli .setattr ('//RandomBoxlayout//AnchorLayout[1] /MDTextField[0]' , "text" , random_label )
49+ self .cli .setattr ('//Random/ /MDTextField[0]' , "text" , random_label )
4750 self .cli .sleep (0.1 )
4851 # Checking the Button is rendered
49- self .assertExists ('//RandomBoxlayout//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]' , timeout = 3 )
52+ self .assertExists (
53+ '//Random//RandomBoxlayout//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]' , timeout = 3 )
5054 # Click on Proceed Next button to generate random Address
51- self .cli .wait_click ('//RandomBoxlayout//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]' , timeout = 3 )
55+ self .cli .wait_click (
56+ '//Random//RandomBoxlayout//MDFillRoundFlatIconButton[@text=\" Proceed Next\" ]' , timeout = 3 )
5257 # Checking "My Address" Screen after creating a address
5358 self .assertExists ("//ScreenManager[@current=\" myaddress\" ]" , timeout = 5 )
5459 # Checking the new address is created
55- self .assertExists ('//MDList[0]/CustomTwoLineAvatarIconListItem' , timeout = 10 )
60+ self .assertExists ('//MyAddress// MDList[0]/CustomTwoLineAvatarIconListItem' , timeout = 10 )
5661
57- @skip_screen_checks
5862 @ordered
5963 def test_set_default_address (self ):
6064 """Select First Address From Drawer-Box"""
@@ -63,13 +67,40 @@ def test_set_default_address(self):
6367 # This is for opening side navbar
6468 self .open_side_navbar ()
6569 # Click to open Address Dropdown
66- self .cli .wait_click ('//NavigationItem[0]/CustomSpinner[0]' , timeout = 5 )
67- # Checking the dropdown option is exist
68- self .assertExists ('//MySpinnerOption[0]' , timeout = 5 )
69- is_open = self .cli .getattr ('//NavigationItem[0]/CustomSpinner[@is_open]' , 'is_open' )
70+ self .assertExists ('//NavigationItem[0][@text=\" dropdown_nav_item\" ]' , timeout = 2 )
71+ self .assertExists (
72+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]'
73+ '/IdentitySpinner[@name=\" identity_dropdown\" ]' , timeout = 1
74+ )
75+ is_open = self .cli .getattr (
76+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]'
77+ '/IdentitySpinner[@name=\" identity_dropdown\" ][@is_open]' , "is_open" )
78+ self .assertEqual (is_open , False )
79+ self .cli .wait (
80+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]'
81+ '/IdentitySpinner[@name=\" identity_dropdown\" ][@state=\" normal\" ]' , timeout = 2
82+ )
83+ self .cli .wait_click (
84+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]'
85+ '/IdentitySpinner[@name=\" identity_dropdown\" ]' , timeout = 1
86+ )
87+ if self .cli .wait (
88+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]'
89+ '/IdentitySpinner[@name=\" identity_dropdown\" ][@state=\" normal\" ]' , timeout = 2 ):
90+ sleep (0.2 )
7091 # Check the state of dropdown.
92+ is_open = self .cli .getattr (
93+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]'
94+ '/IdentitySpinner[@name=\" identity_dropdown\" ][@is_open]' , 'is_open'
95+ )
7196 self .assertEqual (is_open , True )
97+ # List of addresses
98+ addresses_in_dropdown = self .cli .getattr (
99+ '//NavigationItem[0][@text=\" dropdown_nav_item\" ]/IdentitySpinner[@values]' , 'values'
100+ )
101+ # Checking the dropdown options are exists
102+ self .assertGreaterEqual (len (self .cli .getattr (
103+ '//MySpinnerOption[@text]' , 'text' )), len (addresses_in_dropdown )
104+ )
72105 # Selection of an address to set as a default address.
73106 self .cli .wait_click ('//MySpinnerOption[0]' , timeout = 5 )
74- # Checking current screen
75- self .assertExists ("//ScreenManager[@current=\" inbox\" ]" , timeout = 5 )
0 commit comments