Skip to main content

Framework for running unit tests with Selenium on Browserstack

Project description

pybrowserstack extends the unittest framework to make selenium/browserstack automated tests really easy.

Example:

import pybrowserstack
import unittest

class SeleniumTestCase(pybrowserstack.testBase,unittest.TestCase):

    def setUp(self):
        self.api_keys['user'] = '<your username>'
        self.api_keys['pass'] = '<api key provided by browserstack>'
        self.workers = 2
        self.windows_7.ie()
        self.windows_8.firefox()
        self.mobile()

    @selenium_django.browserstack
    def test_firefox(self):
        self.driver.get("http://google.com")
        print(self.driver.title)

if __name__ == '__main__':
    unittest.main()

The above example will use two workers and test IE on windows 7, firefox on windows 8, and one browser on each mobile device available. The test_firefox block will be run, which will print “Google” once for each test.

In the setUp method, include all of the browsers you want to run. To include the latest version of every browser, you could use the following shortcut:

self.desktop()
self.mobile()
self.tablet()

To include all windows 7 browsers, you could run:

self.desktop.windows_7()

To include only the newest available IE on windows 7:

self.desktop.windows_7.ie()

for an older version of firefox, say version 32 on Windows 8 you could run:

self.desktop.windows_8.firefox(version=32)

If you would like to test on the three newest versions of chrome on OS X Yosemite, you could try this:

self.desktop.yosemite.chrome(versions=3)

In order to specify your resolution, pass it in as a parameter. For example:

self.desktop.windows_8.chrome(resolution='1024x768')

If the resolution you specified could not be found, pybrowserstack will find the closest match and throw a warning. Note that many of the above parameters are not available on mobile.

You can test on every IOS tablet device with this command:

self.tablet.apple()

Or, if you simply want to test on the iphone 5

self.mobile.apple.iphone5()

If you would like to run through a local proxy, start your local session as you normally would (using ./BrowserStackLocal ACCESS_KEY localhost,3000,0) then, in your setUp method, include these lines:

self.local = True
self.local_id = '<your test id>'

Need other custom options? Add those to the self._global_caps dictionary

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybrowserstack-0.1.2dev.tar.gz (5.9 kB view details)

Uploaded Source

File details

Details for the file pybrowserstack-0.1.2dev.tar.gz.

File metadata

File hashes

Hashes for pybrowserstack-0.1.2dev.tar.gz
Algorithm Hash digest
SHA256 d43a08a5ad8fb2a5cc3cefad2bce8bdf7c1399457deda117e4c98d8ede0497dd
MD5 4fb8405ffeec8351664a63a18f4717bf
BLAKE2b-256 0fa80a329ce3777d14d709b656916f48301434d05f6f7764bd5ee83f06730550

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page