fixed populate_data method and added while loop for click and assert

This commit is contained in:
shekhar-cis 2021-09-29 18:54:55 +05:30
parent 394ee583bf
commit 4ec5b70d82
Signed by untrusted user: shekhar-cis
GPG Key ID: 8B2A6C8D5F7F1635
2 changed files with 36 additions and 35 deletions

View File

@ -41,7 +41,7 @@ class TeleniumTestProcess(TeleniumTestCase):
cls.populate_test_data()
super(TeleniumTestProcess, cls).setUpClass()
@classmethod
@staticmethod
def populate_test_data():
"""Set temp data in tmp directory"""
for file_name in tmp_db_file:

View File

@ -1,3 +1,4 @@
from time import time
from random import choice
from string import ascii_lowercase
from telenium.client import TeleniumHttpException
@ -9,8 +10,8 @@ from .common import ordered
class CreateRandomAddress(TeleniumTestProcess):
"""This is for testing randrom address creation"""
@classmethod
def populate_test_data(cls):
@staticmethod
def populate_test_data():
pass
@skip_screen_checks
@ -19,23 +20,22 @@ class CreateRandomAddress(TeleniumTestProcess):
"""Click on Proceed Button to Proceed to Next Screen."""
# Checking current Screen(Login screen)
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='login')
# Clicking on Proceed Next Button
self.assertExists('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
self.cli.wait_click(
'//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
# Checking Current Screen(Random Screen) after Clicking on Proceed Next Button
try:
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=2)
except TeleniumHttpException:
self.cli.wait_click('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=2)
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 TeleniumHttpException:
# Checking Current Screen(Random Screen) after Clicking on "Proceed Next" Button
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
@skip_screen_checks
@ordered
def test_random_screen(self):
"""Creating New Adress For New User."""
# Clicking on Label Text Field to give address name
# self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]', timeout=2)
# Generating Label Randomly
random_label = ""
for _ in range(10):
@ -52,8 +52,7 @@ class CreateRandomAddress(TeleniumTestProcess):
@ordered
def test_create_new_address(self):
"""Clicking on Navigation Drawer To Open New Address"""
# New screen is opening and transition effect takes time so Sleep is used
# this is for opening Nav drawer
# CLick to Open side Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
# checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
@ -61,23 +60,27 @@ class CreateRandomAddress(TeleniumTestProcess):
self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
# Checking state of scrolled screen
self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3)
# Clicking on New Address Tab
self.assertExists('//NavigationItem[@text=\"New address\"]', timeout=5)
# Clicking on New Address Tab
self.cli.wait_click('//NavigationItem[@text=\"New address\"]', timeout=3)
self.cli.sleep(1)
# Checking current Screen(Login screen)
self.assertExists("//ScreenManager[@current=\"login\"]", timeout=5)
# Click on Proceed Next button to enter 'Random' Screen
self.cli.wait_click('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2)
# Checking Current Screen(Random Screen) after Clicking on Proceed Next Button
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
# Executing above function to create new address
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 TeleniumHttpException:
# Checking Current Screen(Random Screen) after Clicking on "Proceed Next" Button
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
# This method is to create random label
self.test_random_screen()
@skip_screen_checks
@ordered
def test_select_address(self):
"""Select First Address From Drawer-Box"""
# Checking current screen
self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=5)
# This is for checking the Side nav Bar is closed
self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
# This is for checking the menu button is appeared
@ -92,13 +95,11 @@ class CreateRandomAddress(TeleniumTestProcess):
self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=5)
# Click to open Address Dropdown
self.cli.wait_click('//NavigationItem[0]/CustomSpinner[0]', timeout=5)
# Checking the state of dropdown (Should be open)
self.assertNotEqual('//NavigationItem[0]/CustomSpinner[@is_open]', False)
try:
# Select address fron Address Dropdown
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
# Checking current screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
except TeleniumHttpException:
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
self.assertExists('//MySpinnerOption', timeout=5)
# Assert to check the address dropwdown open
is_open = self.cli.getattr('//NavigationItem[0]/CustomSpinner[@is_open]', 'is_open')
self.assertEqual(is_open, True)
# Select address from address dropdown
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
# Checking current screen
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)