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