diff options
author | Richard Jones <r1chardj0n3s@gmail.com> | 2015-11-09 15:35:48 +1100 |
---|---|---|
committer | Richard Jones <r1chardj0n3s@gmail.com> | 2015-11-25 11:25:51 +1100 |
commit | 861f9c2c4afff891978cbe787b46528f5216a93c (patch) | |
tree | 343f977ba025ca1728534fe7a7bb19c807d55d6b /openstack_dashboard | |
parent | ab7d5c3ec5317dea2495b958c9f82b2716ba4b5a (diff) | |
download | horizon-861f9c2c4afff891978cbe787b46528f5216a93c.tar.gz |
Enable PhantomJS for running Selenium tests
This patch enables the PhantomJS webdriver for running
the Selenium test suite.
Use it with the --selenium-phantomjs command-line switch
when executing the selenium and integration suite.
Change-Id: I443e6f6d7d1911df500b360f7c22686b417fbeae
Blueprint: enable-phantomjs-selenium
Diffstat (limited to 'openstack_dashboard')
-rw-r--r-- | openstack_dashboard/dashboards/project/images/tests.py | 6 | ||||
-rw-r--r-- | openstack_dashboard/test/integration_tests/webdriver.py | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/openstack_dashboard/dashboards/project/images/tests.py b/openstack_dashboard/dashboards/project/images/tests.py index a1878eafa..e7d989e3a 100644 --- a/openstack_dashboard/dashboards/project/images/tests.py +++ b/openstack_dashboard/dashboards/project/images/tests.py @@ -17,7 +17,9 @@ # License for the specific language governing permissions and limitations # under the License. +import os from socket import timeout as socket_timeout # noqa +import unittest from django.core.urlresolvers import reverse from django import http @@ -411,6 +413,8 @@ class SeleniumTests(test.SeleniumTestCase): self.assertTrue("ISO" in body.text, "ISO should be selected when the extension is *.iso") + @unittest.skipIf(os.environ.get('SELENIUM_PHANTOMJS'), + "PhantomJS cannot test file upload widgets.") @test.create_stubs({api.glance: ('image_list_detailed',)}) def test_modal_create_image_from_file(self): driver = self.selenium @@ -471,6 +475,8 @@ class SeleniumTests(test.SeleniumTestCase): self.assertTrue("ISO" in body.text, "ISO should be selected when the extension is *.iso") + @unittest.skipIf(os.environ.get('SELENIUM_PHANTOMJS'), + "PhantomJS cannot test file upload widgets.") @test.create_stubs({api.glance: ('image_list_detailed',)}) def test_create_image_from_file(self): driver = self.selenium diff --git a/openstack_dashboard/test/integration_tests/webdriver.py b/openstack_dashboard/test/integration_tests/webdriver.py index 84fb78ac6..34e89ee68 100644 --- a/openstack_dashboard/test/integration_tests/webdriver.py +++ b/openstack_dashboard/test/integration_tests/webdriver.py @@ -9,6 +9,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import os import time from selenium.common import exceptions @@ -145,7 +146,14 @@ class WebElementWrapper(WrapperFindOverride, webelement.WebElement): return result -class WebDriverWrapper(WrapperFindOverride, webdriver.Firefox): +# select the active webdriver based on whether we --selenium-phantomjs or not +if os.environ.get('SELENIUM_PHANTOMJS'): + WebDriver = webdriver.PhantomJS +else: + WebDriver = webdriver.Firefox + + +class WebDriverWrapper(WrapperFindOverride, WebDriver): """Wrapper for webdriver to return WebElementWrapper on find_element.""" def __init__(self, logging_prefs=None, capabilities=None, **kwargs): if capabilities is None: |