diff options
| author | Marlon Rodriguez Garcia <marlon.rodriguez-garcia@savoirfairelinux.com> | 2023-10-03 13:26:23 -0400 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-10-06 11:42:46 +0100 |
| commit | 3ac4694fc3b85cf23909d7e2fcc4ae97004ae927 (patch) | |
| tree | 02f3976723a9f4060127f2f679ff0349bd9e2eef /bitbake/lib/toaster/tests/browser | |
| parent | 08421d8985d968b46cfc03baf610c6d7a71f2eed (diff) | |
| download | poky-3ac4694fc3b85cf23909d7e2fcc4ae97004ae927.tar.gz | |
bitbake: toaster: update selenium version and code syntax
Updated selenium version to latest 4.13.0, changed selenum specific version syntax elements to accomplish test success
(Bitbake rev: 868c88a249ef4b9fe5a891e76e25e054e4fcd994)
Signed-off-by: Marlon Rodriguez Garcia <marlon.rodriguez-garcia@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/tests/browser')
9 files changed, 74 insertions, 49 deletions
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 644d45fe58..9a4e27a3bc 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |||
| @@ -21,6 +21,7 @@ import unittest | |||
| 21 | 21 | ||
| 22 | from selenium import webdriver | 22 | from selenium import webdriver |
| 23 | from selenium.webdriver.support.ui import WebDriverWait | 23 | from selenium.webdriver.support.ui import WebDriverWait |
| 24 | from selenium.webdriver.common.by import By | ||
| 24 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | 25 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities |
| 25 | from selenium.common.exceptions import NoSuchElementException, \ | 26 | from selenium.common.exceptions import NoSuchElementException, \ |
| 26 | StaleElementReferenceException, TimeoutException | 27 | StaleElementReferenceException, TimeoutException |
| @@ -32,9 +33,7 @@ def create_selenium_driver(cls,browser='chrome'): | |||
| 32 | browser = env_browser | 33 | browser = env_browser |
| 33 | 34 | ||
| 34 | if browser == 'chrome': | 35 | if browser == 'chrome': |
| 35 | return webdriver.Chrome( | 36 | return webdriver.Chrome() |
| 36 | service_args=["--verbose", "--log-path=selenium.log"] | ||
| 37 | ) | ||
| 38 | elif browser == 'firefox': | 37 | elif browser == 'firefox': |
| 39 | return webdriver.Firefox() | 38 | return webdriver.Firefox() |
| 40 | elif browser == 'marionette': | 39 | elif browser == 'marionette': |
| @@ -153,11 +152,11 @@ class SeleniumTestCaseBase(unittest.TestCase): | |||
| 153 | 152 | ||
| 154 | def find(self, selector): | 153 | def find(self, selector): |
| 155 | """ Find single element by CSS selector """ | 154 | """ Find single element by CSS selector """ |
| 156 | return self.driver.find_element_by_css_selector(selector) | 155 | return self.driver.find_element(By.CSS_SELECTOR, selector) |
| 157 | 156 | ||
| 158 | def find_all(self, selector): | 157 | def find_all(self, selector): |
| 159 | """ Find all elements matching CSS selector """ | 158 | """ Find all elements matching CSS selector """ |
| 160 | return self.driver.find_elements_by_css_selector(selector) | 159 | return self.driver.find_elements(By.CSS_SELECTOR, selector) |
| 161 | 160 | ||
| 162 | def element_exists(self, selector): | 161 | def element_exists(self, selector): |
| 163 | """ | 162 | """ |
diff --git a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py index 8423d3dab2..d4312bb35b 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | # SPDX-License-Identifier: GPL-2.0-only | 7 | # SPDX-License-Identifier: GPL-2.0-only |
| 8 | # | 8 | # |
| 9 | 9 | ||
| 10 | import re | 10 | import re, time |
| 11 | 11 | ||
| 12 | from django.urls import reverse | 12 | from django.urls import reverse |
| 13 | from django.utils import timezone | 13 | from django.utils import timezone |
| @@ -15,6 +15,8 @@ from tests.browser.selenium_helpers import SeleniumTestCase | |||
| 15 | 15 | ||
| 16 | from orm.models import BitbakeVersion, Release, Project, Build, Target | 16 | from orm.models import BitbakeVersion, Release, Project, Build, Target |
| 17 | 17 | ||
| 18 | from selenium.webdriver.common.by import By | ||
| 19 | |||
| 18 | 20 | ||
| 19 | class TestAllBuildsPage(SeleniumTestCase): | 21 | class TestAllBuildsPage(SeleniumTestCase): |
| 20 | """ Tests for all builds page /builds/ """ | 22 | """ Tests for all builds page /builds/ """ |
| @@ -91,7 +93,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
| 91 | found_row = None | 93 | found_row = None |
| 92 | for row in rows: | 94 | for row in rows: |
| 93 | 95 | ||
| 94 | outcome_links = row.find_elements_by_css_selector(selector) | 96 | outcome_links = row.find_elements(By.CSS_SELECTOR, selector) |
| 95 | if len(outcome_links) == 1: | 97 | if len(outcome_links) == 1: |
| 96 | found_row = row | 98 | found_row = row |
| 97 | break | 99 | break |
| @@ -131,17 +133,19 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
| 131 | url = reverse('all-builds') | 133 | url = reverse('all-builds') |
| 132 | self.get(url) | 134 | self.get(url) |
| 133 | 135 | ||
| 136 | # should see a rebuild button for non-command-line builds | ||
| 137 | selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % build1.id | ||
| 138 | time.sleep(2) | ||
| 139 | run_again_button = self.find_all(selector) | ||
| 140 | self.assertEqual(len(run_again_button), 1, | ||
| 141 | 'should see a rebuild button for non-cli builds') | ||
| 142 | |||
| 134 | # shouldn't see a rebuild button for command-line builds | 143 | # shouldn't see a rebuild button for command-line builds |
| 135 | selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % default_build.id | 144 | selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % default_build.id |
| 136 | run_again_button = self.find_all(selector) | 145 | run_again_button = self.find_all(selector) |
| 137 | self.assertEqual(len(run_again_button), 0, | 146 | self.assertEqual(len(run_again_button), 0, |
| 138 | 'should not see a rebuild button for cli builds') | 147 | 'should not see a rebuild button for cli builds') |
| 139 | 148 | ||
| 140 | # should see a rebuild button for non-command-line builds | ||
| 141 | selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % build1.id | ||
| 142 | run_again_button = self.find_all(selector) | ||
| 143 | self.assertEqual(len(run_again_button), 1, | ||
| 144 | 'should see a rebuild button for non-cli builds') | ||
| 145 | 149 | ||
| 146 | def test_tooltips_on_project_name(self): | 150 | def test_tooltips_on_project_name(self): |
| 147 | """ | 151 | """ |
| @@ -198,24 +202,24 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
| 198 | 202 | ||
| 199 | # test recent builds area for successful build | 203 | # test recent builds area for successful build |
| 200 | element = self._get_build_time_element(build1) | 204 | element = self._get_build_time_element(build1) |
| 201 | links = element.find_elements_by_css_selector('a') | 205 | links = element.find_elements(By.CSS_SELECTOR, 'a') |
| 202 | msg = 'should be a link on the build time for a successful recent build' | 206 | msg = 'should be a link on the build time for a successful recent build' |
| 203 | self.assertEquals(len(links), 1, msg) | 207 | self.assertEquals(len(links), 1, msg) |
| 204 | 208 | ||
| 205 | # test recent builds area for failed build | 209 | # test recent builds area for failed build |
| 206 | element = self._get_build_time_element(build2) | 210 | element = self._get_build_time_element(build2) |
| 207 | links = element.find_elements_by_css_selector('a') | 211 | links = element.find_elements(By.CSS_SELECTOR, 'a') |
| 208 | msg = 'should not be a link on the build time for a failed recent build' | 212 | msg = 'should not be a link on the build time for a failed recent build' |
| 209 | self.assertEquals(len(links), 0, msg) | 213 | self.assertEquals(len(links), 0, msg) |
| 210 | 214 | ||
| 211 | # test the time column for successful build | 215 | # test the time column for successful build |
| 212 | build1_row = self._get_row_for_build(build1) | 216 | build1_row = self._get_row_for_build(build1) |
| 213 | links = build1_row.find_elements_by_css_selector('td.time a') | 217 | links = build1_row.find_elements(By.CSS_SELECTOR, 'td.time a') |
| 214 | msg = 'should be a link on the build time for a successful build' | 218 | msg = 'should be a link on the build time for a successful build' |
| 215 | self.assertEquals(len(links), 1, msg) | 219 | self.assertEquals(len(links), 1, msg) |
| 216 | 220 | ||
| 217 | # test the time column for failed build | 221 | # test the time column for failed build |
| 218 | build2_row = self._get_row_for_build(build2) | 222 | build2_row = self._get_row_for_build(build2) |
| 219 | links = build2_row.find_elements_by_css_selector('td.time a') | 223 | links = build2_row.find_elements(By.CSS_SELECTOR, 'td.time a') |
| 220 | msg = 'should not be a link on the build time for a failed build' | 224 | msg = 'should not be a link on the build time for a failed build' |
| 221 | self.assertEquals(len(links), 0, msg) | 225 | self.assertEquals(len(links), 0, msg) |
diff --git a/bitbake/lib/toaster/tests/browser/test_all_projects_page.py b/bitbake/lib/toaster/tests/browser/test_all_projects_page.py index 15b03400f9..3389d32366 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_projects_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_projects_page.py | |||
| @@ -16,6 +16,8 @@ from tests.browser.selenium_helpers import SeleniumTestCase | |||
| 16 | from orm.models import BitbakeVersion, Release, Project, Build | 16 | from orm.models import BitbakeVersion, Release, Project, Build |
| 17 | from orm.models import ProjectVariable | 17 | from orm.models import ProjectVariable |
| 18 | 18 | ||
| 19 | from selenium.webdriver.common.by import By | ||
| 20 | |||
| 19 | class TestAllProjectsPage(SeleniumTestCase): | 21 | class TestAllProjectsPage(SeleniumTestCase): |
| 20 | """ Browser tests for projects page /projects/ """ | 22 | """ Browser tests for projects page /projects/ """ |
| 21 | 23 | ||
| @@ -117,7 +119,7 @@ class TestAllProjectsPage(SeleniumTestCase): | |||
| 117 | 119 | ||
| 118 | # check the release text for the default project | 120 | # check the release text for the default project |
| 119 | selector = 'span[data-project-field="release"] span.text-muted' | 121 | selector = 'span[data-project-field="release"] span.text-muted' |
| 120 | element = default_project_row.find_element_by_css_selector(selector) | 122 | element = default_project_row.find_element(By.CSS_SELECTOR, selector) |
| 121 | text = element.text.strip() | 123 | text = element.text.strip() |
| 122 | self.assertEqual(text, 'Not applicable', | 124 | self.assertEqual(text, 'Not applicable', |
| 123 | 'release should be "not applicable" for default project') | 125 | 'release should be "not applicable" for default project') |
| @@ -127,7 +129,7 @@ class TestAllProjectsPage(SeleniumTestCase): | |||
| 127 | 129 | ||
| 128 | # check the link in the release cell for the other project | 130 | # check the link in the release cell for the other project |
| 129 | selector = 'span[data-project-field="release"]' | 131 | selector = 'span[data-project-field="release"]' |
| 130 | element = other_project_row.find_element_by_css_selector(selector) | 132 | element = other_project_row.find_element(By.CSS_SELECTOR, selector) |
| 131 | text = element.text.strip() | 133 | text = element.text.strip() |
| 132 | self.assertEqual(text, self.release.name, | 134 | self.assertEqual(text, self.release.name, |
| 133 | 'release name should be shown for non-default project') | 135 | 'release name should be shown for non-default project') |
| @@ -152,7 +154,7 @@ class TestAllProjectsPage(SeleniumTestCase): | |||
| 152 | 154 | ||
| 153 | # check the machine cell for the default project | 155 | # check the machine cell for the default project |
| 154 | selector = 'span[data-project-field="machine"] span.text-muted' | 156 | selector = 'span[data-project-field="machine"] span.text-muted' |
| 155 | element = default_project_row.find_element_by_css_selector(selector) | 157 | element = default_project_row.find_element(By.CSS_SELECTOR, selector) |
| 156 | text = element.text.strip() | 158 | text = element.text.strip() |
| 157 | self.assertEqual(text, 'Not applicable', | 159 | self.assertEqual(text, 'Not applicable', |
| 158 | 'machine should be not applicable for default project') | 160 | 'machine should be not applicable for default project') |
| @@ -162,7 +164,7 @@ class TestAllProjectsPage(SeleniumTestCase): | |||
| 162 | 164 | ||
| 163 | # check the link in the machine cell for the other project | 165 | # check the link in the machine cell for the other project |
| 164 | selector = 'span[data-project-field="machine"]' | 166 | selector = 'span[data-project-field="machine"]' |
| 165 | element = other_project_row.find_element_by_css_selector(selector) | 167 | element = other_project_row.find_element(By.CSS_SELECTOR, selector) |
| 166 | text = element.text.strip() | 168 | text = element.text.strip() |
| 167 | self.assertEqual(text, self.MACHINE_NAME, | 169 | self.assertEqual(text, self.MACHINE_NAME, |
| 168 | 'machine name should be shown for non-default project') | 170 | 'machine name should be shown for non-default project') |
| @@ -187,7 +189,7 @@ class TestAllProjectsPage(SeleniumTestCase): | |||
| 187 | 189 | ||
| 188 | # check the link on the name field | 190 | # check the link on the name field |
| 189 | selector = 'span[data-project-field="name"] a' | 191 | selector = 'span[data-project-field="name"] a' |
| 190 | element = default_project_row.find_element_by_css_selector(selector) | 192 | element = default_project_row.find_element(By.CSS_SELECTOR, selector) |
| 191 | link_url = element.get_attribute('href').strip() | 193 | link_url = element.get_attribute('href').strip() |
| 192 | expected_url = reverse('projectbuilds', args=(self.default_project.id,)) | 194 | expected_url = reverse('projectbuilds', args=(self.default_project.id,)) |
| 193 | msg = 'link on default project name should point to builds but was %s' % link_url | 195 | msg = 'link on default project name should point to builds but was %s' % link_url |
| @@ -198,7 +200,7 @@ class TestAllProjectsPage(SeleniumTestCase): | |||
| 198 | 200 | ||
| 199 | # check the link for the other project | 201 | # check the link for the other project |
| 200 | selector = 'span[data-project-field="name"] a' | 202 | selector = 'span[data-project-field="name"] a' |
| 201 | element = other_project_row.find_element_by_css_selector(selector) | 203 | element = other_project_row.find_element(By.CSS_SELECTOR, selector) |
| 202 | link_url = element.get_attribute('href').strip() | 204 | link_url = element.get_attribute('href').strip() |
| 203 | expected_url = reverse('project', args=(self.project.id,)) | 205 | expected_url = reverse('project', args=(self.project.id,)) |
| 204 | msg = 'link on project name should point to configuration but was %s' % link_url | 206 | msg = 'link on project name should point to configuration but was %s' % link_url |
diff --git a/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py b/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py index efcd89b346..1afa4a4d32 100644 --- a/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py +++ b/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py | |||
| @@ -15,6 +15,8 @@ from tests.browser.selenium_helpers import SeleniumTestCase | |||
| 15 | from orm.models import Project, Release, BitbakeVersion, Build, LogMessage | 15 | from orm.models import Project, Release, BitbakeVersion, Build, LogMessage |
| 16 | from orm.models import Layer, Layer_Version, Recipe, CustomImageRecipe, Variable | 16 | from orm.models import Layer, Layer_Version, Recipe, CustomImageRecipe, Variable |
| 17 | 17 | ||
| 18 | from selenium.webdriver.common.by import By | ||
| 19 | |||
| 18 | class TestBuildDashboardPage(SeleniumTestCase): | 20 | class TestBuildDashboardPage(SeleniumTestCase): |
| 19 | """ Tests for the build dashboard /build/X """ | 21 | """ Tests for the build dashboard /build/X """ |
| 20 | 22 | ||
| @@ -183,7 +185,7 @@ class TestBuildDashboardPage(SeleniumTestCase): | |||
| 183 | 185 | ||
| 184 | found = False | 186 | found = False |
| 185 | for element in message_elements: | 187 | for element in message_elements: |
| 186 | log_message_text = element.find_element_by_tag_name('pre').text.strip() | 188 | log_message_text = element.find_element(By.TAG_NAME, 'pre').text.strip() |
| 187 | text_matches = (log_message_text == expected_text) | 189 | text_matches = (log_message_text == expected_text) |
| 188 | 190 | ||
| 189 | log_message_pk = element.get_attribute('data-log-message-id') | 191 | log_message_pk = element.get_attribute('data-log-message-id') |
| @@ -213,7 +215,7 @@ class TestBuildDashboardPage(SeleniumTestCase): | |||
| 213 | the WebElement modal match the list of text values in expected | 215 | the WebElement modal match the list of text values in expected |
| 214 | """ | 216 | """ |
| 215 | # labels containing the radio buttons we're testing for | 217 | # labels containing the radio buttons we're testing for |
| 216 | labels = modal.find_elements_by_css_selector(".radio") | 218 | labels = modal.find_elements(By.CSS_SELECTOR,".radio") |
| 217 | 219 | ||
| 218 | labels_text = [lab.text for lab in labels] | 220 | labels_text = [lab.text for lab in labels] |
| 219 | self.assertEqual(len(labels_text), len(expected)) | 221 | self.assertEqual(len(labels_text), len(expected)) |
| @@ -248,7 +250,7 @@ class TestBuildDashboardPage(SeleniumTestCase): | |||
| 248 | selector = '[data-role="edit-custom-image-trigger"]' | 250 | selector = '[data-role="edit-custom-image-trigger"]' |
| 249 | self.click(selector) | 251 | self.click(selector) |
| 250 | 252 | ||
| 251 | modal = self.driver.find_element_by_id('edit-custom-image-modal') | 253 | modal = self.driver.find_element(By.ID, 'edit-custom-image-modal') |
| 252 | self.wait_until_visible("#edit-custom-image-modal") | 254 | self.wait_until_visible("#edit-custom-image-modal") |
| 253 | 255 | ||
| 254 | # recipes we expect to see in the edit custom image modal | 256 | # recipes we expect to see in the edit custom image modal |
| @@ -270,7 +272,7 @@ class TestBuildDashboardPage(SeleniumTestCase): | |||
| 270 | selector = '[data-role="new-custom-image-trigger"]' | 272 | selector = '[data-role="new-custom-image-trigger"]' |
| 271 | self.click(selector) | 273 | self.click(selector) |
| 272 | 274 | ||
| 273 | modal = self.driver.find_element_by_id('new-custom-image-modal') | 275 | modal = self.driver.find_element(By.ID,'new-custom-image-modal') |
| 274 | self.wait_until_visible("#new-custom-image-modal") | 276 | self.wait_until_visible("#new-custom-image-modal") |
| 275 | 277 | ||
| 276 | # recipes we expect to see in the new custom image modal | 278 | # recipes we expect to see in the new custom image modal |
diff --git a/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py b/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py index 7844aaa395..a34a092884 100644 --- a/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py +++ b/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | # | 6 | # |
| 7 | # Copyright (C) 2013-2016 Intel Corporation | 7 | # Copyright (C) 2013-2016 Intel Corporation |
| 8 | # | 8 | # |
| 9 | 9 | import time | |
| 10 | from django.urls import reverse | 10 | from django.urls import reverse |
| 11 | from django.utils import timezone | 11 | from django.utils import timezone |
| 12 | from tests.browser.selenium_helpers import SeleniumTestCase | 12 | from tests.browser.selenium_helpers import SeleniumTestCase |
| @@ -14,6 +14,8 @@ from tests.browser.selenium_helpers_base import Wait | |||
| 14 | from orm.models import Project, Build, Task, Recipe, Layer, Layer_Version | 14 | from orm.models import Project, Build, Task, Recipe, Layer, Layer_Version |
| 15 | from bldcontrol.models import BuildRequest | 15 | from bldcontrol.models import BuildRequest |
| 16 | 16 | ||
| 17 | from selenium.webdriver.common.by import By | ||
| 18 | |||
| 17 | class TestMostRecentBuildsStates(SeleniumTestCase): | 19 | class TestMostRecentBuildsStates(SeleniumTestCase): |
| 18 | """ Test states update correctly in most recent builds area """ | 20 | """ Test states update correctly in most recent builds area """ |
| 19 | 21 | ||
| @@ -62,7 +64,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): | |||
| 62 | element = self.wait_until_visible(selector) | 64 | element = self.wait_until_visible(selector) |
| 63 | 65 | ||
| 64 | bar_selector = '#recipes-parsed-percentage-bar-%s' % build.id | 66 | bar_selector = '#recipes-parsed-percentage-bar-%s' % build.id |
| 65 | bar_element = element.find_element_by_css_selector(bar_selector) | 67 | bar_element = element.find_element(By.CSS_SELECTOR, bar_selector) |
| 66 | self.assertEqual(bar_element.value_of_css_property('width'), '0px', | 68 | self.assertEqual(bar_element.value_of_css_property('width'), '0px', |
| 67 | 'recipe parse progress should be at 0') | 69 | 'recipe parse progress should be at 0') |
| 68 | 70 | ||
| @@ -73,7 +75,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): | |||
| 73 | self.get(url) | 75 | self.get(url) |
| 74 | 76 | ||
| 75 | element = self.wait_until_visible(selector) | 77 | element = self.wait_until_visible(selector) |
| 76 | bar_element = element.find_element_by_css_selector(bar_selector) | 78 | bar_element = element.find_element(By.CSS_SELECTOR, bar_selector) |
| 77 | recipe_bar_updated = lambda driver: \ | 79 | recipe_bar_updated = lambda driver: \ |
| 78 | bar_element.get_attribute('style') == 'width: 50%;' | 80 | bar_element.get_attribute('style') == 'width: 50%;' |
| 79 | msg = 'recipe parse progress bar should update to 50%' | 81 | msg = 'recipe parse progress bar should update to 50%' |
| @@ -107,7 +109,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): | |||
| 107 | element = self.wait_until_visible(selector) | 109 | element = self.wait_until_visible(selector) |
| 108 | 110 | ||
| 109 | bar_selector = '#build-pc-done-bar-%s' % build.id | 111 | bar_selector = '#build-pc-done-bar-%s' % build.id |
| 110 | bar_element = element.find_element_by_css_selector(bar_selector) | 112 | bar_element = element.find_element(By.CSS_SELECTOR, bar_selector) |
| 111 | 113 | ||
| 112 | task_bar_updated = lambda driver: \ | 114 | task_bar_updated = lambda driver: \ |
| 113 | bar_element.get_attribute('style') == 'width: 50%;' | 115 | bar_element.get_attribute('style') == 'width: 50%;' |
| @@ -121,7 +123,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): | |||
| 121 | self.get(url) | 123 | self.get(url) |
| 122 | 124 | ||
| 123 | element = self.wait_until_visible(selector) | 125 | element = self.wait_until_visible(selector) |
| 124 | bar_element = element.find_element_by_css_selector(bar_selector) | 126 | bar_element = element.find_element(By.CSS_SELECTOR, bar_selector) |
| 125 | task_bar_updated = lambda driver: \ | 127 | task_bar_updated = lambda driver: \ |
| 126 | bar_element.get_attribute('style') == 'width: 100%;' | 128 | bar_element.get_attribute('style') == 'width: 100%;' |
| 127 | msg = 'tasks progress bar should update to 100%' | 129 | msg = 'tasks progress bar should update to 100%' |
diff --git a/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py b/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py index 9906ae42a9..6361f40347 100644 --- a/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py +++ b/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | # | 6 | # |
| 7 | # SPDX-License-Identifier: GPL-2.0-only | 7 | # SPDX-License-Identifier: GPL-2.0-only |
| 8 | # | 8 | # |
| 9 | from bldcontrol.models import BuildEnvironment | ||
| 9 | 10 | ||
| 10 | from django.urls import reverse | 11 | from django.urls import reverse |
| 11 | from tests.browser.selenium_helpers import SeleniumTestCase | 12 | from tests.browser.selenium_helpers import SeleniumTestCase |
| @@ -18,6 +19,9 @@ class TestNewCustomImagePage(SeleniumTestCase): | |||
| 18 | CUSTOM_IMAGE_NAME = 'roopa-doopa' | 19 | CUSTOM_IMAGE_NAME = 'roopa-doopa' |
| 19 | 20 | ||
| 20 | def setUp(self): | 21 | def setUp(self): |
| 22 | BuildEnvironment.objects.get_or_create( | ||
| 23 | betype=BuildEnvironment.TYPE_LOCAL, | ||
| 24 | ) | ||
| 21 | release = Release.objects.create( | 25 | release = Release.objects.create( |
| 22 | name='baz', | 26 | name='baz', |
| 23 | bitbake_version=BitbakeVersion.objects.create(name='v1') | 27 | bitbake_version=BitbakeVersion.objects.create(name='v1') |
diff --git a/bitbake/lib/toaster/tests/browser/test_new_project_page.py b/bitbake/lib/toaster/tests/browser/test_new_project_page.py index e20a1f686e..f4b2708f77 100644 --- a/bitbake/lib/toaster/tests/browser/test_new_project_page.py +++ b/bitbake/lib/toaster/tests/browser/test_new_project_page.py | |||
| @@ -6,11 +6,13 @@ | |||
| 6 | # | 6 | # |
| 7 | # SPDX-License-Identifier: GPL-2.0-only | 7 | # SPDX-License-Identifier: GPL-2.0-only |
| 8 | # | 8 | # |
| 9 | import time | ||
| 9 | 10 | ||
| 10 | from django.urls import reverse | 11 | from django.urls import reverse |
| 11 | from tests.browser.selenium_helpers import SeleniumTestCase | 12 | from tests.browser.selenium_helpers import SeleniumTestCase |
| 12 | from selenium.webdriver.support.ui import Select | 13 | from selenium.webdriver.support.ui import Select |
| 13 | from selenium.common.exceptions import InvalidElementStateException | 14 | from selenium.common.exceptions import InvalidElementStateException |
| 15 | from selenium.webdriver.common.by import By | ||
| 14 | 16 | ||
| 15 | from orm.models import Project, Release, BitbakeVersion | 17 | from orm.models import Project, Release, BitbakeVersion |
| 16 | 18 | ||
| @@ -47,13 +49,14 @@ class TestNewProjectPage(SeleniumTestCase): | |||
| 47 | 49 | ||
| 48 | url = reverse('newproject') | 50 | url = reverse('newproject') |
| 49 | self.get(url) | 51 | self.get(url) |
| 50 | |||
| 51 | self.enter_text('#new-project-name', project_name) | 52 | self.enter_text('#new-project-name', project_name) |
| 52 | 53 | ||
| 53 | select = Select(self.find('#projectversion')) | 54 | select = Select(self.find('#projectversion')) |
| 54 | select.select_by_value(str(self.release.pk)) | 55 | select.select_by_value(str(self.release.pk)) |
| 55 | 56 | ||
| 57 | time.sleep(1) | ||
| 56 | self.click("#create-project-button") | 58 | self.click("#create-project-button") |
| 59 | time.sleep(2) | ||
| 57 | 60 | ||
| 58 | # We should get redirected to the new project's page with the | 61 | # We should get redirected to the new project's page with the |
| 59 | # notification at the top | 62 | # notification at the top |
| @@ -84,6 +87,12 @@ class TestNewProjectPage(SeleniumTestCase): | |||
| 84 | select = Select(self.find('#projectversion')) | 87 | select = Select(self.find('#projectversion')) |
| 85 | select.select_by_value(str(self.release.pk)) | 88 | select.select_by_value(str(self.release.pk)) |
| 86 | 89 | ||
| 90 | radio = self.driver.find_element(By.ID, 'type-new') | ||
| 91 | radio.click() | ||
| 92 | |||
| 93 | self.click("#create-project-button") | ||
| 94 | time.sleep(2) | ||
| 95 | |||
| 87 | element = self.wait_until_visible('#hint-error-project-name') | 96 | element = self.wait_until_visible('#hint-error-project-name') |
| 88 | 97 | ||
| 89 | self.assertTrue(("Project names must be unique" in element.text), | 98 | self.assertTrue(("Project names must be unique" in element.text), |
| @@ -96,6 +105,7 @@ class TestNewProjectPage(SeleniumTestCase): | |||
| 96 | except InvalidElementStateException: | 105 | except InvalidElementStateException: |
| 97 | pass | 106 | pass |
| 98 | 107 | ||
| 108 | time.sleep(2) | ||
| 99 | self.assertTrue( | 109 | self.assertTrue( |
| 100 | (Project.objects.filter(name=project_name).count() == 1), | 110 | (Project.objects.filter(name=project_name).count() == 1), |
| 101 | "New project not found in database") | 111 | "New project not found in database") |
diff --git a/bitbake/lib/toaster/tests/browser/test_project_config_page.py b/bitbake/lib/toaster/tests/browser/test_project_config_page.py index 944bcb2631..7b21460e83 100644 --- a/bitbake/lib/toaster/tests/browser/test_project_config_page.py +++ b/bitbake/lib/toaster/tests/browser/test_project_config_page.py | |||
| @@ -11,6 +11,7 @@ from django.urls import reverse | |||
| 11 | from tests.browser.selenium_helpers import SeleniumTestCase | 11 | from tests.browser.selenium_helpers import SeleniumTestCase |
| 12 | 12 | ||
| 13 | from orm.models import BitbakeVersion, Release, Project, ProjectVariable | 13 | from orm.models import BitbakeVersion, Release, Project, ProjectVariable |
| 14 | from selenium.webdriver.common.by import By | ||
| 14 | 15 | ||
| 15 | class TestProjectConfigsPage(SeleniumTestCase): | 16 | class TestProjectConfigsPage(SeleniumTestCase): |
| 16 | """ Test data at /project/X/builds is displayed correctly """ | 17 | """ Test data at /project/X/builds is displayed correctly """ |
| @@ -66,7 +67,7 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 66 | 67 | ||
| 67 | self.enter_text('#new-imagefs_types', imagefs_type) | 68 | self.enter_text('#new-imagefs_types', imagefs_type) |
| 68 | 69 | ||
| 69 | checkboxes = self.driver.find_elements_by_xpath("//input[@class='fs-checkbox-fstypes']") | 70 | checkboxes = self.driver.find_elements(By.XPATH, "//input[@class='fs-checkbox-fstypes']") |
| 70 | 71 | ||
| 71 | for checkbox in checkboxes: | 72 | for checkbox in checkboxes: |
| 72 | if checkbox.get_attribute("value") == "btrfs": | 73 | if checkbox.get_attribute("value") == "btrfs": |
| @@ -95,7 +96,7 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 95 | for checkbox in checkboxes: | 96 | for checkbox in checkboxes: |
| 96 | if checkbox.get_attribute("value") == "cpio": | 97 | if checkbox.get_attribute("value") == "cpio": |
| 97 | checkbox.click() | 98 | checkbox.click() |
| 98 | element = self.driver.find_element_by_id('new-imagefs_types') | 99 | element = self.driver.find_element(By.ID, 'new-imagefs_types') |
| 99 | 100 | ||
| 100 | self.wait_until_visible('#new-imagefs_types') | 101 | self.wait_until_visible('#new-imagefs_types') |
| 101 | 102 | ||
| @@ -129,7 +130,7 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 129 | self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) | 130 | self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) |
| 130 | 131 | ||
| 131 | # downloads dir path has a space | 132 | # downloads dir path has a space |
| 132 | self.driver.find_element_by_id('new-dl_dir').clear() | 133 | self.driver.find_element(By.ID, 'new-dl_dir').clear() |
| 133 | self.enter_text('#new-dl_dir', '/foo/bar a') | 134 | self.enter_text('#new-dl_dir', '/foo/bar a') |
| 134 | 135 | ||
| 135 | element = self.wait_until_visible('#hintError-dl_dir') | 136 | element = self.wait_until_visible('#hintError-dl_dir') |
| @@ -137,7 +138,7 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 137 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) | 138 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) |
| 138 | 139 | ||
| 139 | # downloads dir path starts with ${...} but has a space | 140 | # downloads dir path starts with ${...} but has a space |
| 140 | self.driver.find_element_by_id('new-dl_dir').clear() | 141 | self.driver.find_element(By.ID,'new-dl_dir').clear() |
| 141 | self.enter_text('#new-dl_dir', '${TOPDIR}/down foo') | 142 | self.enter_text('#new-dl_dir', '${TOPDIR}/down foo') |
| 142 | 143 | ||
| 143 | element = self.wait_until_visible('#hintError-dl_dir') | 144 | element = self.wait_until_visible('#hintError-dl_dir') |
| @@ -145,18 +146,18 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 145 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) | 146 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) |
| 146 | 147 | ||
| 147 | # downloads dir path starts with / | 148 | # downloads dir path starts with / |
| 148 | self.driver.find_element_by_id('new-dl_dir').clear() | 149 | self.driver.find_element(By.ID,'new-dl_dir').clear() |
| 149 | self.enter_text('#new-dl_dir', '/bar/foo') | 150 | self.enter_text('#new-dl_dir', '/bar/foo') |
| 150 | 151 | ||
| 151 | hidden_element = self.driver.find_element_by_id('hintError-dl_dir') | 152 | hidden_element = self.driver.find_element(By.ID,'hintError-dl_dir') |
| 152 | self.assertEqual(hidden_element.is_displayed(), False, | 153 | self.assertEqual(hidden_element.is_displayed(), False, |
| 153 | 'downloads directory path valid but treated as invalid') | 154 | 'downloads directory path valid but treated as invalid') |
| 154 | 155 | ||
| 155 | # downloads dir path starts with ${...} | 156 | # downloads dir path starts with ${...} |
| 156 | self.driver.find_element_by_id('new-dl_dir').clear() | 157 | self.driver.find_element(By.ID,'new-dl_dir').clear() |
| 157 | self.enter_text('#new-dl_dir', '${TOPDIR}/down') | 158 | self.enter_text('#new-dl_dir', '${TOPDIR}/down') |
| 158 | 159 | ||
| 159 | hidden_element = self.driver.find_element_by_id('hintError-dl_dir') | 160 | hidden_element = self.driver.find_element(By.ID,'hintError-dl_dir') |
| 160 | self.assertEqual(hidden_element.is_displayed(), False, | 161 | self.assertEqual(hidden_element.is_displayed(), False, |
| 161 | 'downloads directory path valid but treated as invalid') | 162 | 'downloads directory path valid but treated as invalid') |
| 162 | 163 | ||
| @@ -184,7 +185,7 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 184 | self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) | 185 | self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) |
| 185 | 186 | ||
| 186 | # path has a space | 187 | # path has a space |
| 187 | self.driver.find_element_by_id('new-sstate_dir').clear() | 188 | self.driver.find_element(By.ID, 'new-sstate_dir').clear() |
| 188 | self.enter_text('#new-sstate_dir', '/foo/bar a') | 189 | self.enter_text('#new-sstate_dir', '/foo/bar a') |
| 189 | 190 | ||
| 190 | element = self.wait_until_visible('#hintError-sstate_dir') | 191 | element = self.wait_until_visible('#hintError-sstate_dir') |
| @@ -192,7 +193,7 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 192 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) | 193 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) |
| 193 | 194 | ||
| 194 | # path starts with ${...} but has a space | 195 | # path starts with ${...} but has a space |
| 195 | self.driver.find_element_by_id('new-sstate_dir').clear() | 196 | self.driver.find_element(By.ID,'new-sstate_dir').clear() |
| 196 | self.enter_text('#new-sstate_dir', '${TOPDIR}/down foo') | 197 | self.enter_text('#new-sstate_dir', '${TOPDIR}/down foo') |
| 197 | 198 | ||
| 198 | element = self.wait_until_visible('#hintError-sstate_dir') | 199 | element = self.wait_until_visible('#hintError-sstate_dir') |
| @@ -200,18 +201,18 @@ class TestProjectConfigsPage(SeleniumTestCase): | |||
| 200 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) | 201 | self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) |
| 201 | 202 | ||
| 202 | # path starts with / | 203 | # path starts with / |
| 203 | self.driver.find_element_by_id('new-sstate_dir').clear() | 204 | self.driver.find_element(By.ID,'new-sstate_dir').clear() |
| 204 | self.enter_text('#new-sstate_dir', '/bar/foo') | 205 | self.enter_text('#new-sstate_dir', '/bar/foo') |
| 205 | 206 | ||
| 206 | hidden_element = self.driver.find_element_by_id('hintError-sstate_dir') | 207 | hidden_element = self.driver.find_element(By.ID, 'hintError-sstate_dir') |
| 207 | self.assertEqual(hidden_element.is_displayed(), False, | 208 | self.assertEqual(hidden_element.is_displayed(), False, |
| 208 | 'sstate directory path valid but treated as invalid') | 209 | 'sstate directory path valid but treated as invalid') |
| 209 | 210 | ||
| 210 | # paths starts with ${...} | 211 | # paths starts with ${...} |
| 211 | self.driver.find_element_by_id('new-sstate_dir').clear() | 212 | self.driver.find_element(By.ID, 'new-sstate_dir').clear() |
| 212 | self.enter_text('#new-sstate_dir', '${TOPDIR}/down') | 213 | self.enter_text('#new-sstate_dir', '${TOPDIR}/down') |
| 213 | 214 | ||
| 214 | hidden_element = self.driver.find_element_by_id('hintError-sstate_dir') | 215 | hidden_element = self.driver.find_element(By.ID, 'hintError-sstate_dir') |
| 215 | self.assertEqual(hidden_element.is_displayed(), False, | 216 | self.assertEqual(hidden_element.is_displayed(), False, |
| 216 | 'sstate directory path valid but treated as invalid') | 217 | 'sstate directory path valid but treated as invalid') |
| 217 | 218 | ||
diff --git a/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py b/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py index e82d5ec654..e00c30a8a3 100644 --- a/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py +++ b/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py | |||
| @@ -13,6 +13,7 @@ from django.urls import reverse | |||
| 13 | from django.utils import timezone | 13 | from django.utils import timezone |
| 14 | from tests.browser.selenium_helpers import SeleniumTestCase | 14 | from tests.browser.selenium_helpers import SeleniumTestCase |
| 15 | from orm.models import BitbakeVersion, Release, Project, Build | 15 | from orm.models import BitbakeVersion, Release, Project, Build |
| 16 | from selenium.webdriver.common.by import By | ||
| 16 | 17 | ||
| 17 | class TestToasterTableUI(SeleniumTestCase): | 18 | class TestToasterTableUI(SeleniumTestCase): |
| 18 | """ | 19 | """ |
| @@ -33,7 +34,7 @@ class TestToasterTableUI(SeleniumTestCase): | |||
| 33 | table: WebElement for a ToasterTable | 34 | table: WebElement for a ToasterTable |
| 34 | """ | 35 | """ |
| 35 | selector = 'thead a.sorted' | 36 | selector = 'thead a.sorted' |
| 36 | heading = table.find_element_by_css_selector(selector) | 37 | heading = table.find_element(By.CSS_SELECTOR, selector) |
| 37 | return heading.get_attribute('innerHTML').strip() | 38 | return heading.get_attribute('innerHTML').strip() |
| 38 | 39 | ||
| 39 | def _get_datetime_from_cell(self, row, selector): | 40 | def _get_datetime_from_cell(self, row, selector): |
| @@ -45,7 +46,7 @@ class TestToasterTableUI(SeleniumTestCase): | |||
| 45 | selector: CSS selector to use to find the cell containing the date time | 46 | selector: CSS selector to use to find the cell containing the date time |
| 46 | string | 47 | string |
| 47 | """ | 48 | """ |
| 48 | cell = row.find_element_by_css_selector(selector) | 49 | cell = row.find_element(By.CSS_SELECTOR, selector) |
| 49 | cell_text = cell.get_attribute('innerHTML').strip() | 50 | cell_text = cell.get_attribute('innerHTML').strip() |
| 50 | return datetime.strptime(cell_text, '%d/%m/%y %H:%M') | 51 | return datetime.strptime(cell_text, '%d/%m/%y %H:%M') |
| 51 | 52 | ||
| @@ -105,7 +106,7 @@ class TestToasterTableUI(SeleniumTestCase): | |||
| 105 | self.click('#checkbox-started_on') | 106 | self.click('#checkbox-started_on') |
| 106 | 107 | ||
| 107 | # sort by started_on column | 108 | # sort by started_on column |
| 108 | links = table.find_elements_by_css_selector('th.started_on a') | 109 | links = table.find_elements(By.CSS_SELECTOR, 'th.started_on a') |
| 109 | for link in links: | 110 | for link in links: |
| 110 | if link.get_attribute('innerHTML').strip() == 'Started on': | 111 | if link.get_attribute('innerHTML').strip() == 'Started on': |
| 111 | link.click() | 112 | link.click() |
