Opened 9 years ago
Closed 9 years ago
#25364 closed New feature (fixed)
Provide a more generic way to test different browsers in selenium tests
Reported by: | Tim Graham | Owned by: | Akshesh Doshi |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | moritz.sichert@…, Simon Charette | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There is some work in Julien Phalip's sauce branch which allows running the tests against different browsers without having to creating separate FooBar<Browser>Tests
classes. It would be nice to bring this patch current and merge it (we can defer the work in progress in that branch that allows running the tests on Sauce Labs).
Change History (12)
comment:1 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 9 years ago
Has patch: | set |
---|
comment:4 by , 9 years ago
Patch needs improvement: | set |
---|
comment:5 by , 9 years ago
Patch needs improvement: | unset |
---|
comment:6 by , 9 years ago
Patch needs improvement: | set |
---|
Multiple browsers aren't working on Python 3. Zero tests are run for --selenium=firefox,chrome
.
comment:7 by , 9 years ago
I may be a bit late for this, but I see a problem with this approach. Right now the selenium browser is started in setUpClass()
and closed in tearDownClass()
. This means that the browser has to be started once for every test class.
This new approach does a bit of Meta class and method copying hacking to provide a new method test_foo__browser
for all test functions and browsers. But then a single test class has tests for different browsers. This means that the selenium browser started can't be started in setUpClass()
so the logic for starting it was moved to setUp()
. That however means that the browser is started and closed once for every test case. If you consider that starting the browser can take up to a few seconds (especially on the CI system), I'd say that solution is not acceptable.
I can think of a solution that works by creating a new test class for each browser in the meta class' __new__()
method and then return a proxy class containing those newly created classes that knows how to run the tests on all of them.
comment:9 by , 9 years ago
Cc: | added |
---|
I ran all selenium tests with firefox and chrome on my 4-core machine and got the following numbers:
On master branch:
Ran 67 tests in 124.703s
On the PR:
Ran 68 tests in 173.816s
That's an increase of about 40% even on a powerful desktop machine.
comment:10 by , 9 years ago
Cc: | added |
---|---|
Patch needs improvement: | unset |
comment:11 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR: https://github.com/django/django/pull/6099