.. _filtering:
Filtering
=========
.filter(*selector*)
-------------------
Filters the ``WebElementSet`` to only include elements that match the selector.
.. code-block:: python
>>> import webdriverplus
>>> driver = webdriverplus.Firefox()
>>> snippet = """
...
... - 1
... - 2
... - 3
... - 4
... - 5
...
"""
>>> driver.open(snippet).find('li').filter(class_name='selected').html
['2', '5']
.exclude(*selector*)
--------------------
Filters the ``WebElementSet`` to only include elements that do not match the
selector.
.. code-block:: python
>>> import webdriverplus
>>> driver = webdriverplus.Firefox()
>>> snippet = """
...
... - 1
... - 2
... - 3
... - 4
... - 5
...
"""
>>> driver.open(snippet).find('li').exclude(class_name='selected').html
['1', '3', '4']
.closest(*selector*)
--------------------