1#! /usr/bin/env python3 2# 3# BitBake Toaster functional tests implementation 4# 5# Copyright (C) 2017 Intel Corporation 6# 7# SPDX-License-Identifier: GPL-2.0-only 8# 9 10import re 11from tests.functional.functional_helpers import SeleniumFunctionalTestCase 12from orm.models import Project 13 14class FuntionalTestBasic(SeleniumFunctionalTestCase): 15 16# testcase (1514) 17 def test_create_slenium_project(self): 18 project_name = 'selenium-project' 19 self.get('') 20 self.driver.find_element_by_link_text("To start building, create your first Toaster project").click() 21 self.driver.find_element_by_id("new-project-name").send_keys(project_name) 22 self.driver.find_element_by_id('projectversion').click() 23 self.driver.find_element_by_id("create-project-button").click() 24 element = self.wait_until_visible('#project-created-notification') 25 self.assertTrue(self.element_exists('#project-created-notification'),'Project creation notification not shown') 26 self.assertTrue(project_name in element.text, 27 "New project name not in new project notification") 28 self.assertTrue(Project.objects.filter(name=project_name).count(), 29 "New project not found in database") 30 31 # testcase (1515) 32 def test_verify_left_bar_menu(self): 33 self.get('') 34 self.wait_until_visible('#projectstable') 35 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 36 self.assertTrue(self.element_exists('#config-nav'),'Configuration Tab does not exist') 37 project_URL=self.get_URL() 38 self.driver.find_element_by_xpath('//a[@href="'+project_URL+'"]').click() 39 40 try: 41 self.driver.find_element_by_xpath("//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'customimages/"'+"]").click() 42 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') 43 except: 44 self.fail(msg='No Custom images tab available') 45 46 try: 47 self.driver.find_element_by_xpath("//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'images/"'+"]").click() 48 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') 49 except: 50 self.fail(msg='No Compatible image tab available') 51 52 try: 53 self.driver.find_element_by_xpath("//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'softwarerecipes/"'+"]").click() 54 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') 55 except: 56 self.fail(msg='No Compatible software recipe tab available') 57 58 try: 59 self.driver.find_element_by_xpath("//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'machines/"'+"]").click() 60 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') 61 except: 62 self.fail(msg='No Compatible machines tab available') 63 64 try: 65 self.driver.find_element_by_xpath("//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'layers/"'+"]").click() 66 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') 67 except: 68 self.fail(msg='No Compatible layers tab available') 69 70 try: 71 self.driver.find_element_by_xpath("//*[@id='config-nav']/ul/li/a[@href="+'"'+project_URL+'configuration"'+"]").click() 72 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') 73 except: 74 self.fail(msg='No Bitbake variables tab available') 75 76# testcase (1516) 77 def test_review_configuration_information(self): 78 self.get('') 79 self.driver.find_element_by_xpath("//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() 80 self.wait_until_visible('#projectstable') 81 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 82 project_URL=self.get_URL() 83 84 try: 85 self.assertTrue(self.element_exists('#machine-section'),'Machine section for the project configuration page does not exist') 86 self.assertTrue(re.search("qemux86",self.driver.find_element_by_xpath("//span[@id='project-machine-name']").text),'The machine type is not assigned') 87 self.driver.find_element_by_xpath("//span[@id='change-machine-toggle']").click() 88 self.wait_until_visible('#select-machine-form') 89 self.wait_until_visible('#cancel-machine-change') 90 self.driver.find_element_by_xpath("//form[@id='select-machine-form']/a[@id='cancel-machine-change']").click() 91 except: 92 self.fail(msg='The machine information is wrong in the configuration page') 93 94 try: 95 self.driver.find_element_by_id('no-most-built') 96 except: 97 self.fail(msg='No Most built information in project detail page') 98 99 try: 100 self.assertTrue(re.search("Yocto Project master",self.driver.find_element_by_xpath("//span[@id='project-release-title']").text),'The project release is not defined') 101 except: 102 self.fail(msg='No project release title information in project detail page') 103 104 try: 105 self.driver.find_element_by_xpath("//div[@id='layer-container']") 106 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') 107 layer_list = self.driver.find_element_by_id("layers-in-project-list") 108 layers = layer_list.find_elements_by_tag_name("li") 109 for layer in layers: 110 if re.match ("openembedded-core",layer.text): 111 print ("openembedded-core layer is a default layer in the project configuration") 112 elif re.match ("meta-poky",layer.text): 113 print ("meta-poky layer is a default layer in the project configuration") 114 elif re.match ("meta-yocto-bsp",layer.text): 115 print ("meta-yocto-bsp is a default layer in the project configuratoin") 116 else: 117 self.fail(msg='default layers are missing from the project configuration') 118 except: 119 self.fail(msg='No Layer information in project detail page') 120 121# testcase (1517) 122 def test_verify_machine_information(self): 123 self.get('') 124 self.driver.find_element_by_xpath("//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() 125 self.wait_until_visible('#projectstable') 126 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 127 128 try: 129 self.assertTrue(self.element_exists('#machine-section'),'Machine section for the project configuration page does not exist') 130 self.assertTrue(re.search("qemux86",self.driver.find_element_by_id("project-machine-name").text),'The machine type is not assigned') 131 self.driver.find_element_by_id("change-machine-toggle").click() 132 self.wait_until_visible('#select-machine-form') 133 self.wait_until_visible('#cancel-machine-change') 134 self.driver.find_element_by_id("cancel-machine-change").click() 135 except: 136 self.fail(msg='The machine information is wrong in the configuration page') 137 138# testcase (1518) 139 def test_verify_most_built_recipes_information(self): 140 self.get('') 141 self.driver.find_element_by_xpath("//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() 142 self.wait_until_visible('#projectstable') 143 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 144 project_URL=self.get_URL() 145 146 try: 147 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') 148 self.driver.find_element_by_xpath("//div[@id='no-most-built']/p/a[@href="+'"'+project_URL+'images/"'+"]").click() 149 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') 150 except: 151 self.fail(msg='No Most built information in project detail page') 152 153# testcase (1519) 154 def test_verify_project_release_information(self): 155 self.get('') 156 self.driver.find_element_by_xpath("//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() 157 self.wait_until_visible('#projectstable') 158 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 159 160 try: 161 self.assertTrue(re.search("Yocto Project master",self.driver.find_element_by_id("project-release-title").text),'The project release is not defined') 162 except: 163 self.fail(msg='No project release title information in project detail page') 164 165# testcase (1520) 166 def test_verify_layer_information(self): 167 self.get('') 168 self.driver.find_element_by_xpath("//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() 169 self.wait_until_visible('#projectstable') 170 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 171 project_URL=self.get_URL() 172 173 try: 174 self.driver.find_element_by_xpath("//div[@id='layer-container']") 175 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') 176 layer_list = self.driver.find_element_by_id("layers-in-project-list") 177 layers = layer_list.find_elements_by_tag_name("li") 178 179 for layer in layers: 180 if re.match ("openembedded-core",layer.text): 181 print ("openembedded-core layer is a default layer in the project configuration") 182 elif re.match ("meta-poky",layer.text): 183 print ("meta-poky layer is a default layer in the project configuration") 184 elif re.match ("meta-yocto-bsp",layer.text): 185 print ("meta-yocto-bsp is a default layer in the project configuratoin") 186 else: 187 self.fail(msg='default layers are missing from the project configuration') 188 189 self.driver.find_element_by_xpath("//input[@id='layer-add-input']") 190 self.driver.find_element_by_xpath("//button[@id='add-layer-btn']") 191 self.driver.find_element_by_xpath("//div[@id='layer-container']/form[@class='form-inline']/p/a[@id='view-compatible-layers']") 192 self.driver.find_element_by_xpath("//div[@id='layer-container']/form[@class='form-inline']/p/a[@href="+'"'+project_URL+'importlayer"'+"]") 193 except: 194 self.fail(msg='No Layer information in project detail page') 195 196# testcase (1521) 197 def test_verify_project_detail_links(self): 198 self.get('') 199 self.driver.find_element_by_xpath("//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() 200 self.wait_until_visible('#projectstable') 201 self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() 202 project_URL=self.get_URL() 203 204 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() 205 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') 206 207 try: 208 self.driver.find_element_by_xpath("//div[@id='project-topbar']/ul[@class='nav nav-tabs']/li/a[@href="+'"'+project_URL+'builds/"'+"]").click() 209 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') 210 self.driver.find_element_by_xpath("//div[@id='empty-state-projectbuildstable']") 211 except: 212 self.fail(msg='Builds tab information is not present') 213 214 try: 215 self.driver.find_element_by_xpath("//div[@id='project-topbar']/ul[@class='nav nav-tabs']/li/a[@href="+'"'+project_URL+'importlayer"'+"]").click() 216 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') 217 self.driver.find_element_by_xpath("//fieldset[@id='repo-select']") 218 self.driver.find_element_by_xpath("//fieldset[@id='git-repo']") 219 except: 220 self.fail(msg='Import layer tab not loading properly') 221 222 try: 223 self.driver.find_element_by_xpath("//div[@id='project-topbar']/ul[@class='nav nav-tabs']/li/a[@href="+'"'+project_URL+'newcustomimage/"'+"]").click() 224 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') 225 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') 226 except: 227 self.fail(msg='New custom image tab not loading properly') 228 229 230 231