Skip to main content
Sulfur is a simplified web driver interface for python-selenium. Sulfur has
a more pleasant (and less java-esque) interface and also uses BeautifulSoup
to make an even tastier API.

Sulfur's main goal is to help writing tests for Web applications. It has
a builtin pytest plugin that defines a few useful fixtures, but it can also be
used with other testing libraries.

You can use Sulfur anywhere that Selenium would be used. Besides the obvious
use case of writing integration tests for web development, Sulfur can be used on
automation, data-mining, presentations, etc.


Basic Usage
===========

Let us start a new webdriver (sulfur uses PhantomJS by default):

>>> from sulfur import Driver
>>> driver = Driver('chrome', home='http://www.python.org') # doctest: +SKIP

.. invisible-code-block:: python
driver = Driver('phantomjs', home='http://www.python.org')

The driver object is used to control the web browser. Now you can send commands,
inspect the page, and interact with the browser in many ways. First say hello :)

>>> driver.script('alert("Hello World!")')

And now goodbye!

>>> driver.close()

Basic actions
=============

Sulfur supports basic navegations actions by the :meth:`sulfur.Driver.back`,
:meth:`sulfur.Driver.forward`, :func:`sulfur.Driver.home`, :meth:`sulfur.Driver.refresh`, and
:meth:`sulfur.Driver.open` methods.

User input can be simulated with the :meth:`sulfur.Driver.click`,
:meth:`sulfur.Driver.send_keys` methods. Sulfur also makes it possible to execute
scripts (:meth:`sulfur.Driver.script`), take screen shots (:meth:`Driver.screenshot`)
and fetch the page HTML source (:meth:`sulfur.Driver.source`).

The full API is covered at :class:`sufur.Driver`.

Selectors and queries
=====================

You can query elements in the current web page using the familiar CSS selector
syntax. The :meth:`driver.Driver.elem` method retrieves a single element and
:meth:`driver.Driver.query` returns a queryset with all matches to that query
selector.

>>> driver.find('p') # fetches all <p>'s in page # doctest: +SKIP
<QuerySet: [...]>

Queries can be nested in a way similar to jQuery.

>>> driver.query('div').find('p').filter('.emph') # doctest: +SKIP
<QuerySet: [...]>

This finds all <divs>'s in page, then selects their <p>'s children and then
filters the result to paragraphs with the "emph" class.



selector.

>>> driver.find('p') # fetches all <p>'s in page # doctest: +SKIP
<QuerySet: [...]>

Queries can be nested in a way similar to jQuery.

>>> driver.query('div').find('p').filter('.emph') # doctest: +SKIP
<QuerySet: [...]>

This finds all <divs>'s in page, then selects their <p>'s children and then
filters the result to paragraphs with the "emph" class.



selector.

>>> driver.query('p') # fetches all <p>'s in page # doctest: +SKIP
<QuerySet: [...]>

Queries can be nested in a way similar to jQuery.

>>> driver.find('div').find('p').filter('.emph') # doctest: +SKIP
<QuerySet: [...]>

This finds all <divs>'s in page, then selects their <p>'s children and then
filters the result to paragraphs with the "emph" class.



selector.

>>> driver.query('p') # fetches all <p>'s in page # doctest: +SKIP
<QuerySet: [...]>

Queries can be nested in a way similar to jQuery.

>>> driver.find('div').find('p').filter('.emph') # doctest: +SKIP
<QuerySet: [...]>

This finds all <divs>'s in page, then selects their <p>'s children and then
filters the result to paragraphs with the "emph" class.



selector.

>>> driver.query('p') # fetches all <p>'s in page # doctest: +SKIP
<QuerySet: [...]>

Queries can be nested in a way similar to jQuery.

>>> driver.query('div').find('p').filter('.emph') # doctest: +SKIP
<QuerySet: [...]>

This finds all <divs>'s in page, then selects their <p>'s children and then
filters the result to paragraphs with the "emph" class.


What's up with this name?
=========================

Sulfur is the element that sits just on top of Selenium in the periodic table.
Elements within the same column share many chemical and electronic properties,
but since Sulfur has an atomic number of only 16 (vs. 34 for Selenium), it is
considerably lighter ;)

Release files for sulfur 0.1.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 sulfur 0.1.4
File Size Uploaded
sulfur-0.1.4.tar.gz 27.9 kB Details

Release files / sulfur-0.1.4.tar.gz

Download URL sulfur-0.1.4.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
682ab43faaadf2689e9d7c1d0994ba0542dc284fb1f8bfc7b46c04317d3277cd
BLAKE2b-256 checksum
How to use checksums
c4f69e6f451e35b2568cb28fb94457963fccecd551d2577792f1d4a301bd890f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

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