Running SSTTestCase on multiple browsers?

Asked by Ari on 2013-05-10

Hello,

I'm new to SST and and python too. I'd like to organise my tests as SSTTestCases, and execute them using sst-run using IE, Chrome and Firefox. However SSTTestCase uses FirefoxFactory() by default and issuing "sst-run testname -b Chrome" etc. wont help.

The above is possible of course if not using SSTTestCase, but I feel that overall readability suffers then.

from sst.actions import *
from sst import runtests

class Homepage(runtests.SSTTestCase):

    def test_ubuntu_home_page(self):
        go_to('http://www.ubuntu.com/')
        assert_title_contains('Ubuntu')

    def test_google_home_page(self):
        go_to('http://www.google.com/')
        assert_title_contains('Google')

Question information

Language:
English Edit question
Status:
Solved
For:
selenium-simple-test Edit question
Assignee:
No assignee Edit question
Solved by:
Leo Arias
Solved:
2013-05-13
Last query:
2013-05-13
Last reply:
2013-05-10
Best Leo Arias (elopio) said : #1

Hi Ari,

While using SSTTestCase, you can overwrite the default browser_factory setting the attribute on the test case.
Something like this should work: (I haven't tried it myself and I see we are missing the tests for the other factories, so please let us know if it works)

class Homepage(runtests.SSTTestCase):

    browser_factory = runtests.PhantomJSFactory()

    def test_ubuntu_home_page(self):
        go_to('http://www.ubuntu.com/')
        assert_title_contains('Ubuntu')

    def test_google_home_page(self):
        go_to('http://www.google.com/')
        assert_title_contains('Google')

Now, as you'd like to run them in multiple browsers, you could use https://launchpad.net/testscenarios to clone the test for as many browsers as you have. Or an alternate way is to get the factory at run time. You can use https://launchpad.net/configglue to pass it from command line or on a file.

Ari (arzzka) said : #2

Hi, thanks for answering. The factories work, I tried Firefox, Chrome and IE. Thank you also for the tip regarding testscenarios, with that I was able to create different test suites for different browsers.

Ari (arzzka) said : #3

Thanks Leo Arias, that solved my question.