Skip to main content

A simple boilerplate app for selenium testing in Django with LiveServerTestCase.

Installation:

pip install django-selenium-boilerplate

Usage

This app provides a SeleniumBase class that extends LiveServerTestCase. It sets up selenium, and provides several helper methods for testing.

  • SeleniumBase.url(route, *args, **kwargs): Returns the full live server URL to the given route. If rotue starts with “/”, it’s interpreted as a full path. Otherwise, it’s interpreted as a reversible route name, which is resolved using reverse(route, args=args, kwargs=kwargs).

  • SeleniumBase.by_css(selector): Shortcut for self.selenium.find_element_by_css_selector.

  • SeleniumBase.by_csss(selector): Shortcut for self.selenium.find_elements_by_css_selector.

  • SeleniumBase.await_selector(selector, timeout=30): Polls for the presence of the given CSS selector, until the timeout. Returns when at least one element matching that selector is found.

  • SeleniumBase.select_option(selector, visible_text): Shortcut for selecting the <option> with the given visible text within the <select> that matches the given CSS selector.

Optional setting: - SELENIUM_FIREFOX_BIN: Optional path to the firefox binary to use when building the Selenium driver. Use this to constrain to a particular selenium-supported Firefox release.

Example:

from selenium_boilerplate import SeleniumBase

class MyTestCase(SeleniumBase):
    def test_home(self):
        # Look up the route named "home"
        self.selenium.get(self.selenium.url("home"))
        # Pause until the selector "h1" appears
        self.await_selector("h1")
        self.assertEquals(self.by_css("h1").text, "Hello, World")

License

BSD License.

Copyright (c) 2014, Charlie DeTar All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Release files for django-selenium-boilerplate 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-selenium-boilerplate 0.0.4
File Size Uploaded
django-selenium-boilerplate-0.0.4.tar.gz 3.6 kB Details

Release files / django-selenium-boilerplate-0.0.4.tar.gz

Download URL django-selenium-boilerplate-0.0.4.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f3694a1ba655914bbfd65b6b3f21699871da0c91c3ccf0c45c3564f49014552c
BLAKE2b-256 checksum
How to use checksums
9ddc2aa114aba0bc2df5176780232ad41cb988b5ab1904c4a440e99fcaad62bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.6

1 release file

0.0.5

1 release file

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page