From 861f9c2c4afff891978cbe787b46528f5216a93c Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 9 Nov 2015 15:35:48 +1100 Subject: 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 --- openstack_dashboard/dashboards/project/images/tests.py | 6 ++++++ openstack_dashboard/test/integration_tests/webdriver.py | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'openstack_dashboard') 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: -- cgit v1.2.1