1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +00:00

bitbake: toaster: tests browser Fix selenium tests after bootstrap3 breakage

Fix a number of selectors which have changed after the port to
bootstrap3. Also fix the modal wait_until_visible and returning of the
text for the radio buttons in the modals for edit custom image and new
custom image on the build dashboard.

(Bitbake rev: 5f80dac65f419825bd81a734273a2465d5a01bab)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood
2016-06-13 14:32:16 +01:00
committed by Richard Purdie
parent 234a625f40
commit 7e54da0581
3 changed files with 27 additions and 24 deletions
@@ -27,6 +27,7 @@ from tests.browser.selenium_helpers import SeleniumTestCase
from orm.models import BitbakeVersion, Release, Project, Build, Target from orm.models import BitbakeVersion, Release, Project, Build, Target
class TestAllBuildsPage(SeleniumTestCase): class TestAllBuildsPage(SeleniumTestCase):
""" Tests for all builds page /builds/ """ """ Tests for all builds page /builds/ """
@@ -95,17 +96,17 @@ class TestAllBuildsPage(SeleniumTestCase):
url = reverse('all-builds') url = reverse('all-builds')
self.get(url) self.get(url)
# shouldn't see a run again button for command-line builds # shouldn't see a rebuild button for command-line builds
selector = 'div[data-latest-build-result="%s"] button' % default_build.id selector = 'div[data-latest-build-result="%s"] a.run-again-btn' % default_build.id
run_again_button = self.find_all(selector) run_again_button = self.find_all(selector)
self.assertEqual(len(run_again_button), 0, self.assertEqual(len(run_again_button), 0,
'should not see a run again button for cli builds') 'should not see a rebuild button for cli builds')
# should see a run again button for non-command-line builds # should see a rebuild button for non-command-line builds
selector = 'div[data-latest-build-result="%s"] button' % build1.id selector = 'div[data-latest-build-result="%s"] a.run-again-btn' % build1.id
run_again_button = self.find_all(selector) run_again_button = self.find_all(selector)
self.assertEqual(len(run_again_button), 1, self.assertEqual(len(run_again_button), 1,
'should see a run again button for non-cli builds') 'should see a rebuild button for non-cli builds')
def test_tooltips_on_project_name(self): def test_tooltips_on_project_name(self):
""" """
@@ -124,7 +125,7 @@ class TestAllBuildsPage(SeleniumTestCase):
# get the project name cells from the table # get the project name cells from the table
cells = self.find_all('#allbuildstable td[class="project"]') cells = self.find_all('#allbuildstable td[class="project"]')
selector = 'i.get-help' selector = 'span.get-help'
for cell in cells: for cell in cells:
content = cell.get_attribute('innerHTML') content = cell.get_attribute('innerHTML')
@@ -140,7 +140,7 @@ class TestBuildDashboardPage(SeleniumTestCase):
dashboard for the Build object build dashboard for the Build object build
""" """
self._get_build_dashboard(build) self._get_build_dashboard(build)
return self.find_all('#errors div.alert-error') return self.find_all('#errors div.alert-danger')
def _check_for_log_message(self, build, log_message): def _check_for_log_message(self, build, log_message):
""" """
@@ -179,23 +179,15 @@ class TestBuildDashboardPage(SeleniumTestCase):
the WebElement modal match the list of text values in expected the WebElement modal match the list of text values in expected
""" """
# labels containing the radio buttons we're testing for # labels containing the radio buttons we're testing for
labels = modal.find_elements_by_tag_name('label') labels = modal.find_elements_by_css_selector(".radio")
# because the label content has the structure
# label text
# <input...>
# we have to regex on its innerHTML, as we can't just retrieve the
# "label text" on its own via the Selenium API
labels_text = sorted(map(
lambda label: label.get_attribute('innerHTML'), labels
))
expected = sorted(expected)
labels_text = [lab.text for lab in labels]
self.assertEqual(len(labels_text), len(expected)) self.assertEqual(len(labels_text), len(expected))
for idx, label_text in enumerate(labels_text): for expected_text in expected:
self.assertRegexpMatches(label_text, expected[idx]) self.assertTrue(expected_text in labels_text,
"Could not find %s in %s" % (expected_text,
labels_text))
def test_exceptions_show_as_errors(self): def test_exceptions_show_as_errors(self):
""" """
@@ -217,7 +209,13 @@ class TestBuildDashboardPage(SeleniumTestCase):
the user choose one of them to edit the user choose one of them to edit
""" """
self._get_build_dashboard(self.build1) self._get_build_dashboard(self.build1)
# click the "edit custom image" button, which populates the modal
selector = '[data-role="edit-custom-image-trigger"]'
self.click(selector)
modal = self.driver.find_element_by_id('edit-custom-image-modal') modal = self.driver.find_element_by_id('edit-custom-image-modal')
self.wait_until_visible("#edit-custom-image-modal")
# recipes we expect to see in the edit custom image modal # recipes we expect to see in the edit custom image modal
expected_recipes = [ expected_recipes = [
@@ -235,10 +233,11 @@ class TestBuildDashboardPage(SeleniumTestCase):
self._get_build_dashboard(self.build1) self._get_build_dashboard(self.build1)
# click the "new custom image" button, which populates the modal # click the "new custom image" button, which populates the modal
selector = '[data-role="new-custom-image-trigger"] button' selector = '[data-role="new-custom-image-trigger"]'
self.click(selector) self.click(selector)
modal = self.driver.find_element_by_id('new-custom-image-modal') modal = self.driver.find_element_by_id('new-custom-image-modal')
self.wait_until_visible("#new-custom-image-modal")
# recipes we expect to see in the new custom image modal # recipes we expect to see in the new custom image modal
expected_recipes = [ expected_recipes = [
@@ -99,7 +99,10 @@ class TestProjectConfigsPage(SeleniumTestCase):
self.wait_until_visible('#new-imagefs_types') self.wait_until_visible('#new-imagefs_types')
checkboxes = self.driver.find_elements_by_xpath("//input[@class='fs-checkbox-fstypes']") checkboxes_selector = '.fs-checkbox-fstypes'
self.wait_until_visible(checkboxes_selector)
checkboxes = self.find_all(checkboxes_selector)
for checkbox in checkboxes: for checkbox in checkboxes:
if checkbox.get_attribute("value") == "cpio": if checkbox.get_attribute("value") == "cpio":