Use wait_until_visible instead of time.sleep to delay driver actions
Signed-off-by: Alassane Yattara <[email protected]>
---
 .../tests/functional/test_functional_basic.py | 39 ++++++++++---------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/lib/toaster/tests/functional/test_functional_basic.py 
b/lib/toaster/tests/functional/test_functional_basic.py
index dcd84c3f..5d7a86bb 100644
--- a/lib/toaster/tests/functional/test_functional_basic.py
+++ b/lib/toaster/tests/functional/test_functional_basic.py
@@ -15,7 +15,7 @@ from orm.models import Project
 from selenium.webdriver.common.by import By
 
 
[email protected]("last")
[email protected]("second_to_last")
 class FuntionalTestBasic(SeleniumFunctionalTestCase):
 
 #   testcase (1514)
@@ -26,7 +26,6 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
         self.driver.find_element(By.ID, 
"new-project-name").send_keys(project_name)
         self.driver.find_element(By.ID, 'projectversion').click()
         self.driver.find_element(By.ID, "create-project-button").click()
-        time.sleep(2)
         element = self.wait_until_visible('#project-created-notification')
         
self.assertTrue(self.element_exists('#project-created-notification'),'Project 
creation notification not shown')
         self.assertTrue(project_name in element.text,
@@ -39,45 +38,50 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
         self.get(reverse('all-projects'))
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
-        time.sleep(2)
+        self.wait_until_visible('#config-nav')
         self.assertTrue(self.element_exists('#config-nav'),'Configuration Tab 
does not exist')
         project_URL=self.get_URL()
         self.driver.find_element(By.XPATH, 
'//a[@href="'+project_URL+'"]').click()
-        time.sleep(2)
+        self.wait_until_visible('#config-nav')
 
         try:
             self.driver.find_element(By.XPATH, 
"//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'customimages/"'+"]").click()
-            time.sleep(2)
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Custom 
images",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'Custom images information is not loading 
properly')
         except:
             self.fail(msg='No Custom images tab available')
 
         try:
             self.driver.find_element(By.XPATH, 
"//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'images/"'+"]").click()
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Compatible image 
recipes",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'The Compatible image recipes information is 
not loading properly')
         except:
             self.fail(msg='No Compatible image tab available')
 
         try:
             self.driver.find_element(By.XPATH, 
"//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'softwarerecipes/"'+"]").click()
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Compatible software 
recipes",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'The Compatible software recipe information 
is not loading properly')
         except:
             self.fail(msg='No Compatible software recipe tab available')
 
         try:
             self.driver.find_element(By.XPATH, 
"//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'machines/"'+"]").click()
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Compatible 
machines",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'The Compatible machine information is not 
loading properly')
         except:
             self.fail(msg='No Compatible machines tab available')
 
         try:
             self.driver.find_element(By.XPATH, 
"//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'layers/"'+"]").click()
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Compatible 
layers",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'The Compatible layer information is not 
loading properly')
         except:
             self.fail(msg='No Compatible layers tab available')
 
         try:
             self.driver.find_element(By.XPATH, 
"//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'configuration"'+"]").click()
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Bitbake 
variables",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'The Bitbake variables information is not 
loading properly')
         except:
             self.fail(msg='No Bitbake variables tab available')
@@ -86,16 +90,14 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
     def test_review_configuration_information(self):
         self.get('')
         self.driver.find_element(By.XPATH, 
"//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click()
-        time.sleep(2)
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
         project_URL=self.get_URL()
-        time.sleep(2)
+        self.wait_until_visible('#config-nav')
         try:
            self.assertTrue(self.element_exists('#machine-section'),'Machine 
section for the project configuration page does not exist')
            
self.assertTrue(re.search("qemux86-64",self.driver.find_element(By.XPATH, 
"//span[@id='project-machine-name']").text),'The machine type is not assigned')
            self.driver.find_element(By.XPATH, 
"//span[@id='change-machine-toggle']").click()
-           time.sleep(2)
            self.wait_until_visible('#select-machine-form')
            self.wait_until_visible('#cancel-machine-change')
            self.driver.find_element(By.XPATH, 
"//form[@id='select-machine-form']/a[@id='cancel-machine-change']").click()
@@ -133,16 +135,14 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
     def test_verify_machine_information(self):
         self.get('')
         self.driver.find_element(By.XPATH, 
"//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click()
-        time.sleep(2)
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
-        time.sleep(2)
+        self.wait_until_visible('#config-nav')
 
         try:
             self.assertTrue(self.element_exists('#machine-section'),'Machine 
section for the project configuration page does not exist')
             
self.assertTrue(re.search("qemux86-64",self.driver.find_element(By.ID, 
"project-machine-name").text),'The machine type is not assigned')
             self.driver.find_element(By.ID, "change-machine-toggle").click()
-            time.sleep(2)
             self.wait_until_visible('#select-machine-form')
             self.wait_until_visible('#cancel-machine-change')
             self.driver.find_element(By.ID, "cancel-machine-change").click()
@@ -153,15 +153,14 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
     def test_verify_most_built_recipes_information(self):
         self.get('')
         self.driver.find_element(By.XPATH, 
"//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click()
-        time.sleep(2)
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
+        self.wait_until_visible('#config-nav')
         project_URL=self.get_URL()
-        time.sleep(2)
         try:
             self.assertTrue(re.search("You haven't built any recipes 
yet",self.driver.find_element(By.ID, "no-most-built").text),'Default message of 
no builds is not present')
             self.driver.find_element(By.XPATH, 
"//div[@id='no-most-built']/p/a[@href="+'"'+project_URL+'images/"'+"]").click()
-            time.sleep(2)
+            self.wait_until_visible('#config-nav')
             self.assertTrue(re.search("Compatible image 
recipes",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-10']").text),'The Choose a recipe to build link  is not 
working  properly')
         except:
             self.fail(msg='No Most built information in project detail page')
@@ -170,10 +169,9 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
     def test_verify_project_release_information(self):
         self.get('')
         self.driver.find_element(By.XPATH, 
"//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click()
-        time.sleep(2)
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
-        time.sleep(2)
+        self.wait_until_visible('#config-nav')
 
         try:
             self.assertTrue(re.search("Yocto Project 
master",self.driver.find_element(By.ID, "project-release-title").text),'The 
project release is not defined')
@@ -186,8 +184,8 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
         self.driver.find_element(By.XPATH, 
"//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click()
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
+        self.wait_until_visible('#config-nav')
         project_URL=self.get_URL()
-        time.sleep(2)
         try:
            self.driver.find_element(By.XPATH, "//div[@id='layer-container']")
            self.assertTrue(re.search("3",self.driver.find_element(By.ID, 
"project-layers-count").text),'There should be 3 layers listed in the layer 
count')
@@ -215,16 +213,17 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
     def test_verify_project_detail_links(self):
         self.get('')
         self.driver.find_element(By.XPATH, 
"//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click()
-        time.sleep(2)
         self.wait_until_visible('#projectstable')
         self.find_element_by_link_text_in_table('projectstable', 
'selenium-project').click()
+        self.wait_until_visible('#config-nav')
         project_URL=self.get_URL()
-        time.sleep(2)
         self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li[@id='topbar-configuration-tab']/a[@href="+'"'+project_URL+'"'+"]").click()
+        self.wait_until_visible('#config-nav')
         
self.assertTrue(re.search("Configuration",self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li[@id='topbar-configuration-tab']/a[@href="+'"'+project_URL+'"'+"]").text),
 'Configuration tab in project topbar is misspelled')
 
         try:
             self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li/a[@href="+'"'+project_URL+'builds/"'+"]").click()
+            self.wait_until_visible('#project-topbar')
             
self.assertTrue(re.search("Builds",self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li/a[@href="+'"'+project_URL+'builds/"'+"]").text), 'Builds tab in 
project topbar is misspelled')
             self.driver.find_element(By.XPATH, 
"//div[@id='empty-state-projectbuildstable']")
         except:
@@ -232,6 +231,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
 
         try:
             self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li/a[@href="+'"'+project_URL+'importlayer"'+"]").click()
+            self.wait_until_visible('#project-topbar')
             self.assertTrue(re.search("Import 
layer",self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li/a[@href="+'"'+project_URL+'importlayer"'+"]").text), 'Import 
layer tab in project topbar is misspelled')
             self.driver.find_element(By.XPATH, "//fieldset[@id='repo-select']")
             self.driver.find_element(By.XPATH, "//fieldset[@id='git-repo']")
@@ -240,6 +240,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase):
 
         try:
             self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li/a[@href="+'"'+project_URL+'newcustomimage/"'+"]").click()
+            self.wait_until_visible('#project-topbar')
             self.assertTrue(re.search("New custom 
image",self.driver.find_element(By.XPATH, 
"//div[@id='project-topbar']/ul[@class='nav 
nav-tabs']/li/a[@href="+'"'+project_URL+'newcustomimage/"'+"]").text), 'New 
custom image tab in project topbar is misspelled')
             self.assertTrue(re.search("Select the image recipe you want to 
customise",self.driver.find_element(By.XPATH, 
"//div[@class='col-md-12']/h2").text),'The new custom image tab is not loading 
correctly')
         except:
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#6099): https://lists.yoctoproject.org/g/toaster/message/6099
Mute This Topic: https://lists.yoctoproject.org/mt/103179870/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/toaster/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to