semvec/pypi-packages huggingface dataset:
glance_dom 0.11.5
Quickly reference DOM elements with minimal inspection.
Keywords: testing

Glance DOM
==========

Quickly reference DOM elements with minimal inspection.

To learn more about Glance DOM visit the `Glance Website <http://quasimatic.org/glance>`_.

Installation
************

Installation requires ``pip``::

    pip install glance-dom

Usage
*****

Instantiate Glance DOM using a browser driver (for example,
`WebDriver <http://www.seleniumhq.org/projects/webdriver/>`_).

.. code-block:: python

    from selenium import webdriver
    from glance_dom import GlanceDom

    def test_glance():
        driver = webdriver.Firefox()
        driver.get('http://quasimatic.org/glance')

        # Using the old way
        languages = driver.find_element_by_css_selector('h2#other-languages + ul > li')

        # Using Glance
        glance = GlanceDom(driver)
        languages = glance.get_element('Other Languages > li')

        print(languages.text)

You can also get a list of matching elements using ``get_elements``

Exceptions
__________

``get_element`` will raise ``NoReferenceError`` if the ``reference`` did not match any elements.
Similarly it will raise ``TooBroadReferenceError`` it there are more than one match.