[gnome-continuous-yocto/gnomeostree-3.28-rocko: 918/8267] bitbake: toaster: tests browser Fix selenium tests after bootstrap3 breakage



commit 7e54da0581faaafa9bfb13680ad6618c4c8f9831
Author: Michael Wood <michael g wood intel com>
Date:   Mon Jun 13 14:32:16 2016 +0100

    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>

 .../toaster/tests/browser/test_all_builds_page.py  |   15 +++++----
 .../tests/browser/test_builddashboard_page.py      |   31 +++++++++----------
 .../tests/browser/test_project_config_page.py      |    5 ++-
 3 files changed, 27 insertions(+), 24 deletions(-)
---
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 e4223f4..5ea6532 100644
--- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
@@ -27,6 +27,7 @@ from tests.browser.selenium_helpers import SeleniumTestCase
 
 from orm.models import BitbakeVersion, Release, Project, Build, Target
 
+
 class TestAllBuildsPage(SeleniumTestCase):
     """ Tests for all builds page /builds/ """
 
@@ -95,17 +96,17 @@ class TestAllBuildsPage(SeleniumTestCase):
         url = reverse('all-builds')
         self.get(url)
 
-        # shouldn't see a run again button for command-line builds
-        selector = 'div[data-latest-build-result="%s"] button' % default_build.id
+        # shouldn't see a rebuild button for command-line builds
+        selector = 'div[data-latest-build-result="%s"] a.run-again-btn' % default_build.id
         run_again_button = self.find_all(selector)
         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
-        selector = 'div[data-latest-build-result="%s"] button' % build1.id
+        # should see a rebuild button for non-command-line builds
+        selector = 'div[data-latest-build-result="%s"] a.run-again-btn' % build1.id
         run_again_button = self.find_all(selector)
         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):
         """
@@ -124,7 +125,7 @@ class TestAllBuildsPage(SeleniumTestCase):
         # get the project name cells from the table
         cells = self.find_all('#allbuildstable td[class="project"]')
 
-        selector = 'i.get-help'
+        selector = 'span.get-help'
 
         for cell in cells:
             content = cell.get_attribute('innerHTML')
diff --git a/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py 
b/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
index 0d39abb..cdb0616 100644
--- a/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
@@ -140,7 +140,7 @@ class TestBuildDashboardPage(SeleniumTestCase):
         dashboard for the Build object 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):
         """
@@ -179,23 +179,15 @@ class TestBuildDashboardPage(SeleniumTestCase):
         the WebElement modal match the list of text values in expected
         """
         # labels containing the radio buttons we're testing for
-        labels = modal.find_elements_by_tag_name('label')
-
-        # 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 = modal.find_elements_by_css_selector(".radio")
 
+        labels_text = [lab.text for lab in labels]
         self.assertEqual(len(labels_text), len(expected))
 
-        for idx, label_text in enumerate(labels_text):
-            self.assertRegexpMatches(label_text, expected[idx])
+        for expected_text in expected:
+            self.assertTrue(expected_text in labels_text,
+                            "Could not find %s in %s" % (expected_text,
+                                                         labels_text))
 
     def test_exceptions_show_as_errors(self):
         """
@@ -217,7 +209,13 @@ class TestBuildDashboardPage(SeleniumTestCase):
         the user choose one of them to edit
         """
         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')
+        self.wait_until_visible("#edit-custom-image-modal")
 
         # recipes we expect to see in the edit custom image modal
         expected_recipes = [
@@ -235,10 +233,11 @@ class TestBuildDashboardPage(SeleniumTestCase):
         self._get_build_dashboard(self.build1)
 
         # 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)
 
         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
         expected_recipes = [
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 ede53b6..7fc1252 100644
--- a/bitbake/lib/toaster/tests/browser/test_project_config_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_project_config_page.py
@@ -99,7 +99,10 @@ class TestProjectConfigsPage(SeleniumTestCase):
 
         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:
             if checkbox.get_attribute("value") == "cpio":


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]