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 Akshesh Doshi, 9 years ago

Owner: changed from nobody to Akshesh Doshi
Status: newassigned

comment:3 by Tim Graham, 9 years ago

Left comments for improvement on the pull request.

comment:4 by Tim Graham, 9 years ago

Patch needs improvement: set

comment:5 by Akshesh Doshi, 9 years ago

Patch needs improvement: unset

comment:6 by Tim Graham, 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 Moritz Sichert, 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:8 by Tim Graham, 9 years ago

Yes, I agree that would be better.

comment:9 by Moritz Sichert, 9 years ago

Cc: moritz.sichert@… 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 Simon Charette, 9 years ago

Cc: Simon Charette added
Patch needs improvement: unset

comment:11 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:12 by Simon Charette <charette.s@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 44c0ecdd:

Fixed #25364 -- Added generic way to test on all browsers supported by selenium.

Browser names should be passed as a comma separated list to the --selenium flag.

Thanks Tim Graham, Simon Charette and Moritz Sichert for review and discussion.

Note: See TracTickets for help on using tickets.
Back to Top