Skip to main content

Ghostly

Lightweight API around Selenium Webdriver and helpers for end to end testing with Django.

This package is alpha, the API will most likely change!

It supports Django 1.6-1.8 for Python versions 2.7, 3.3, 3.4, 3.5 and pypy (where the Django version supports said Python version).

Build Status Code Health Code Coverage Documentation Status Latest Version Supported Python versions Downloads

Docs

Available at ghostly.readthedocs.org

Installation

You can install ghostly either via the Python Package Index (PyPI) or from github.

To install using pip;

pip install ghostly

From github;

$ pip install git+https://github.com/alexhayes/ghostly.git

Usage

You can use use this package outside of Django however it has limited use.

Essentially there are two components, as follows;

  • Ghostly - A lightweight wrapper and helper methods for Selenium Webdriver. Presently it provides a handful of methods that utilise xpath to deal with a page, such as xpath, xpath_wait et al.

  • GhostlyDjangoTestCase - A lightweight test case that extends StaticLiveServerTestCase and sets up an instance of Ghostly. It provides methods such as assertCurrentUrl, assertXpathEqual et al.

GhostlyDjangoTestCase

GhostlyDjangoTestCase inherits StaticLiveServerTestCase and thus fires up a WSGI server that handles requests.

Given you have a named URL home with a <h1>Hello World</h1> visible in the source, you can do the following;

class MyTestCase(GhostlyDjangoTestCase):

    def test_homepage(self):
        self.goto(reverse('home'))

        # Assert that an element is equal to something
        self.assertXpathEqual('//h1', 'Hello World')

        # Assert the current url, relative or absolute
        self.assertCurrentUrl('/home')

Working with SVG

To traverse SVG with Selenium web driver you must use xpath.

class MyTestCase(GhostlyDjangoTestCase):

    def test_homepage(self):
        self.goto(reverse('home'))

        # Click on an element, or example, in an SVG.
        self.ghostly.xpath_click('//*[@id="refresh"]')

        # Assert that an Xpath is equal to something
        self.assertXpathEqual('//h2', 'Hello World')

        # Wait for xpath to exist
        self.ghostly.xpath_wait('//div[@id="something"]')

History

This package started out as a simple way to construct browser tests using YAML, written by Brenton Cleeland.

The focus of this fork is to allow the developer to write programmatic unit tests in the style of unittest.

Currently this fork does not contain any of the CSS selector style methods that were originally available as the focus has been on xpath only support until a more robust CSS selector toolkit can be provided.

License

This software is licensed under the MIT License. See the LICENSE file in the top distribution directory for the full license text.

Author

Metadata

Release files for ghostly 0.2.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 ghostly 0.2.4
File Size Uploaded Provenance Actions
ghostly-0.2.4.tar.gz 913.3 kB Without provenance Details for ghostly-0.2.4.tar.gz

Release files / ghostly-0.2.4.tar.gz

Download URL ghostly-0.2.4.tar.gz
Size 913.3 kB
Tags Source
SHA-256 checksum
How to use checksums
beb4bcd9ed2857dbbb28b20e9993e74653138c154d7a9c12b63751ebb7865ac2
BLAKE2b-256 checksum
How to use checksums
c2a68d92909b8c37ce451573d4aa18098beef9e0d763b02f0871a5564ff4821e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ghostly 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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