Skip to contentSkip to conversation

toaster-tests: remove click on disabled element in test

PATCH Superseded Elliot Smith 2 participants 5 messages Jun 17, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 toaster-tests: remove click on disabled element in test

On Firefox 47, attempting to click on the "Submit" button in the test which attempts to create a project with a duplicate name fails, as the button is not enabled if the name is a duplicate. This also causes the test to fail.

Remove the call to the click() method which causes the test to fail.

---
 bitbake/lib/toaster/tests/browser/test_new_project_page.py | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
bitbake/lib/toaster/tests/browser/test_new_project_page.py +2 -6
index 1b038ac..180a690 100644
@@ -80,7 +80,7 @@ class TestNewProjectPage(SeleniumTestCase):
         """
         Should not be able to create a new project whose name is the same
         as an existing project
-       """
+        """
 
         project_name = "dupproject"
 
@@ -100,10 +100,6 @@ class TestNewProjectPage(SeleniumTestCase):
         self.assertTrue(("Project names must be unique" in element.text),
                         "Did not find unique project name error message")
 
-        # Try and click it anyway, if it submits we'll have a new project in
-        # the db and assert then
-        self.click("#create-project-button")
-
         self.assertTrue(
             (Project.objects.filter(name=project_name).count() == 1),
-            "New project not found in database")
+            "New project not found in database")
\ No newline at end of file
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 toaster-tests: define capabilities for latest Firefox driver

The Firefox 47 WebDriver requires a download of a separate binary and an additional capability to be defined on the driver.

Modify our tests so that when Firefox 47 is set as the browser for the tests, this capability is defined. Also add a note to the README about the additional installation steps required.

---
 bitbake/lib/toaster/tests/browser/README              | 9 ++++++++-
 bitbake/lib/toaster/tests/browser/selenium_helpers.py | 5 ++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
bitbake/lib/toaster/tests/browser/README +8 -1
index f57154e..43e14c5 100644
@@ -24,7 +24,14 @@ To run tests against PhantomJS (headless):
 * On *nix systems, put phantomjs on PATH
 * Not tested on Windows
 
-Firefox should work without requiring additional software to be installed.
+To run tests against Firefox:
+
+* Firefox versions 46 or earlier should work without requiring additional
+software to be installed.
+* Firefox version 47 requires manual installation of the Marionette driver;
+see https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
+Ensure that the Marionette executable (wires on Linux, wires.exe on Windows)
+is on your PATH.
 
 The test case will instantiate a Selenium driver set by the
 TOASTER_TESTS_BROWSER environment variable, or Chrome if this is not specified.
bitbake/lib/toaster/tests/browser/selenium_helpers.py +4 -1
index 54db2e8..f3bb1a3 100644
@@ -34,6 +34,7 @@ import time
 from django.contrib.staticfiles.testing import StaticLiveServerTestCase
 from selenium import webdriver
 from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
 from selenium.common.exceptions import NoSuchElementException, \
         StaleElementReferenceException, TimeoutException
 
@@ -48,7 +49,9 @@ def create_selenium_driver(browser='chrome'):
             service_args=["--verbose", "--log-path=selenium.log"]
         )
     elif browser == 'firefox':
-        return webdriver.Firefox()
+        capabilities = DesiredCapabilities.FIREFOX
+        capabilities['marionette'] = True
+        return webdriver.Firefox(capabilities=capabilities)
     elif browser == 'ie':
         return webdriver.Ie()
     elif browser == 'phantomjs':
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] toaster-tests: define capabilities for latest Firefox driver

Quoted 46 lines · Elliot Smith

The Firefox 47 WebDriver requires a download of a separate binary and an additional capability to be defined on the driver.

Modify our tests so that when Firefox 47 is set as the browser for the tests, this capability is defined. Also add a note to the README about the additional installation steps required.

---
  bitbake/lib/toaster/tests/browser/README              | 9 ++++++++-
  bitbake/lib/toaster/tests/browser/selenium_helpers.py | 5 ++++-
  2 files changed, 12 insertions(+), 2 deletions(-)
bitbake/lib/toaster/tests/browser/README +8 -1
index f57154e..43e14c5 100644
@@ -24,7 +24,14 @@ To run tests against PhantomJS (headless):
  * On *nix systems, put phantomjs on PATH
  * Not tested on Windows
 
-Firefox should work without requiring additional software to be installed.
+To run tests against Firefox:
+
+* Firefox versions 46 or earlier should work without requiring additional
+software to be installed.
+* Firefox version 47 requires manual installation of the Marionette driver;
+see https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
+Ensure that the Marionette executable (wires on Linux, wires.exe on Windows)
+is on your PATH.
 
  The test case will instantiate a Selenium driver set by the
  TOASTER_TESTS_BROWSER environment variable, or Chrome if this is not specified.
bitbake/lib/toaster/tests/browser/selenium_helpers.py +1 -0
index 54db2e8..f3bb1a3 100644
@@ -34,6 +34,7 @@ import time
  from django.contrib.staticfiles.testing import StaticLiveServerTestCase
  from selenium import webdriver
  from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  from selenium.common.exceptions import NoSuchElementException, \
          StaleElementReferenceException, TimeoutException
 

bitbake/lib/toaster/tests/browser/selenium_helpers.py def create_selenium_driver(browser='chrome'): · line 54

Quoted 7 lines
bitbake/lib/toaster/tests/browser/selenium_helpers.py +3 -1
@@ -48,7 +49,9 @@ def create_selenium_driver(browser='chrome'):
              service_args=["--verbose", "--log-path=selenium.log"]
          )
      elif browser == 'firefox':
-        return webdriver.Firefox()
+        capabilities = DesiredCapabilities.FIREFOX
+        capabilities['marionette'] = True
+        return webdriver.Firefox(capabilities=capabilities)

This will force the use of the marionette/geckodriver/wires for all versions of firefox (apparently it works with v45 onwards) too so, either we need to switch those capabilities depending on the version of firefox we find or we will need to clarify that you'll always need this external driver.

Quoted 3 lines
bitbake/lib/toaster/tests/browser/selenium_helpers.py +0 -0
      elif browser == 'ie':
          return webdriver.Ie()
      elif browser == 'phantomjs':
#3 lore raw

Re: [PATCH 2/2] toaster-tests: define capabilities for latest Firefox driver

Surely setting the capabilities to marionette=true will not make a difference with older versions of Firefox? I tried setting a spurious capability with Firefox 47 and it was just ignored; I assumed that the 'marionette' capability would equally be ignored by older Firefoxes.

I can get an older version of Firefox and test this assumption if you think it's critical.

Elliot

Quoted 80 lines · Michael Wood
Quoted 55 lines · Elliot Smith

The Firefox 47 WebDriver requires a download of a separate binary and an additional capability to be defined on the driver.

Modify our tests so that when Firefox 47 is set as the browser for the tests, this capability is defined. Also add a note to the README about the additional installation steps required.

---
  bitbake/lib/toaster/tests/browser/README              | 9 ++++++++-
  bitbake/lib/toaster/tests/browser/selenium_helpers.py | 5 ++++-
  2 files changed, 12 insertions(+), 2 deletions(-)
bitbake/lib/toaster/tests/browser/README +0 -0
index f57154e..43e14c5 100644
@@ -24,7 +24,14 @@ To run tests against PhantomJS (headless):
  * On *nix systems, put phantomjs on PATH
  * Not tested on Windows
  -Firefox should work without requiring additional software to be

installed.

bitbake/lib/toaster/tests/browser/README +5 -0
+To run tests against Firefox:
+
+* Firefox versions 46 or earlier should work without requiring additional
+software to be installed.
+* Firefox version 47 requires manual installation of the Marionette

driver;
+see
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
+Ensure that the Marionette executable (wires on Linux, wires.exe on Windows)
+is on your PATH.
The test case will instantiate a Selenium driver set by the
TOASTER_TESTS_BROWSER environment variable, or Chrome if this is not
specified.

bitbake/lib/toaster/tests/browser/selenium_helpers.py +1 -0
index 54db2e8..f3bb1a3 100644
@@ -34,6 +34,7 @@ import time
  from django.contrib.staticfiles.testing import StaticLiveServerTestCase
  from selenium import webdriver
  from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.desired_capabilities import

DesiredCapabilities
from selenium.common.exceptions import NoSuchElementException, \
StaleElementReferenceException, TimeoutException
@@ -48,7 +49,9 @@ def create_selenium_driver(browser='chrome'):

              service_args=["--verbose", "--log-path=selenium.log"]
          )
      elif browser == 'firefox':

bitbake/lib/toaster/tests/browser/selenium_helpers.py def create_selenium_driver(browser='chrome'): · line 54

Quoted 4 lines
bitbake/lib/toaster/tests/browser/selenium_helpers.py +3 -1
-        return webdriver.Firefox()
+        capabilities = DesiredCapabilities.FIREFOX
+        capabilities['marionette'] = True
+        return webdriver.Firefox(capabilities=capabilities)

This will force the use of the marionette/geckodriver/wires for all versions of firefox (apparently it works with v45 onwards) too so, either we need to switch those capabilities depending on the version of firefox we find or we will need to clarify that you'll always need this external driver.

      elif browser == 'ie':
Quoted 3 lines
          return webdriver.Ie()
      elif browser == 'phantomjs':

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#4 lore raw

Re: [PATCH 2/2] toaster-tests: define capabilities for latest Firefox driver

This is the traceback with no wires executable and firefox 47 :

(bothpythons) michael@orion:~/dev/yocto/poky/bitbake/lib/toaster(toaster-next %)$ TOASTER_TESTS_BROWSER=firefox ./manage.py test tests.browser --failfast Creating test database for alias 'default'...
EException ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f8558fb36a0>> Traceback (most recent call last):
File
"/home/michael/dev/yocto/poky/bothpythons/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 162, in __del__

    self.stop()

File
"/home/michael/dev/yocto/poky/bothpythons/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 134, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

======================================================================
ERROR: setUpClass (tests.browser.test_all_builds_page.TestAllBuildsPage)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/michael/dev/yocto/poky/bothpythons/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 62, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1541, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'wires'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File
"/home/michael/dev/yocto/poky/bitbake/lib/toaster/tests/browser/selenium_helpers.py", line 135, in setUpClass
cls.driver = create_selenium_driver()
File
"/home/michael/dev/yocto/poky/bitbake/lib/toaster/tests/browser/selenium_helpers.py", line 54, in create_selenium_driver
return webdriver.Firefox(capabilities=capabilities)
File
"/home/michael/dev/yocto/poky/bothpythons/local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 66, in __init__
self.service.start()
File
"/home/michael/dev/yocto/poky/bothpythons/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 69, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'wires' executable needs to be in PATH.

Michael

Quoted 112 lines · Elliot

Surely setting the capabilities to marionette=true will not make a difference with older versions of Firefox? I tried setting a spurious capability with Firefox 47 and it was just ignored; I assumed that the 'marionette' capability would equally be ignored by older Firefoxes.

I can get an older version of Firefox and test this assumption if you think it's critical.

Elliot

On 17 June 2016 at 12:16, Michael Wood <[email protected] <mailto:[email protected]>> wrote:

On 17/06/16 10:41, Elliot Smith wrote:

The Firefox 47 WebDriver requires a download of a separate binary and an additional capability to be defined on the driver.

Modify our tests so that when Firefox 47 is set as the browser for the tests, this capability is defined. Also add a note to the README about the additional installation steps required.

<mailto:[email protected]>>
---
bitbake/lib/toaster/tests/browser/README | 9 ++++++++-
bitbake/lib/toaster/tests/browser/selenium_helpers.py | 5 ++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/toaster/tests/browser/README b/bitbake/lib/toaster/tests/browser/README
index f57154e..43e14c5 100644
--- a/bitbake/lib/toaster/tests/browser/README
+++ b/bitbake/lib/toaster/tests/browser/README
@@ -24,7 +24,14 @@ To run tests against PhantomJS (headless):
* On *nix systems, put phantomjs on PATH
* Not tested on Windows
-Firefox should work without requiring additional software
to be installed.
+To run tests against Firefox:
+
+* Firefox versions 46 or earlier should work without requiring additional
+software to be installed.
+* Firefox version 47 requires manual installation of the Marionette driver;
+see
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
+Ensure that the Marionette executable (wires on Linux, wires.exe on Windows)
+is on your PATH.
The test case will instantiate a Selenium driver set by the
TOASTER_TESTS_BROWSER environment variable, or Chrome if
this is not specified.
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers.py b/bitbake/lib/toaster/tests/browser/selenium_helpers.py index 54db2e8..f3bb1a3 100644
--- a/bitbake/lib/toaster/tests/browser/selenium_helpers.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers.py @@ -34,6 +34,7 @@ import time
from django.contrib.staticfiles.testing import
StaticLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.common.exceptions import NoSuchElementException, \
StaleElementReferenceException, TimeoutException
@@ -48,7 +49,9 @@ def create_selenium_driver(browser='chrome'):
service_args=["--verbose",
"--log-path=selenium.log"]
)
elif browser == 'firefox':
- return webdriver.Firefox()
+ capabilities = DesiredCapabilities.FIREFOX
+ capabilities['marionette'] = True
+ return webdriver.Firefox(capabilities=capabilities)

This will force the use of the marionette/geckodriver/wires for all versions of firefox (apparently it works with v45 onwards) too so, either we need to switch those capabilities depending on the version of firefox we find or we will need to clarify that you'll always need this external driver.

elif browser == 'ie':
return webdriver.Ie()
elif browser == 'phantomjs':

--
_______________________________________________
toaster mailing list
[email protected] <mailto:[email protected]>
https://lists.yoctoproject.org/listinfo/toaster

Signature · 14 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.