Skip to content

Commit

Permalink
fix: Various errors when building docs (#1287)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfehler authored May 30, 2024
1 parent 6c97fab commit 589013f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 46 deletions.
51 changes: 31 additions & 20 deletions docs/cookies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@
:description: Cookies
:keywords: splinter, python, tutorial, documentation, cookies

++++++++++++++
Handle Cookies
++++++++++++++
+++++++
Cookies
+++++++

It is possible to manipulate cookies using the `cookies` attribute from a
`Browser` instance. The `cookies` attribute is an instance of the `CookieManager`
class that manipulates cookies (ie: adding and deleting).
`Browser` instance.


Add a cookie
------------

.. code-block:: python
browser.cookies.add({'cookie_name': 'cookie_value'})
browser.cookies.add({'chocolate_chip': '200'})
Extra Arguments
~~~~~~~~~~~~~~~

Each driver accepts various parameters when creating cookies.
These can be used with browser.cookies.add as extra arguments.
For example, WebDriver can use `path`, `domain`, `secure`, and `expiry`:

.. code-block:: python
browser.cookies.add({'chocolate_chip': '200'}, path='/cookiePath')
Retrieve all cookies
--------------------
Expand All @@ -31,28 +42,28 @@ Retrieve all cookies
Delete a cookie
---------------

Given a cookie named `chocolate_chip`, we can delete it by passing the name
to the `delete` method:

.. code-block:: python
browser.cookies.delete('cookie_name') # delete the cookie 'cookie_name'
browser.cookies.delete('cookies_name_1', 'cookies_name_2') # delete two cookies
browser.cookies.delete('chocolate_chip')
Delete all cookies
------------------
Multiple cookie names can be passed to `delete`:

.. code-block:: python
browser.cookies.delete_all()
browser.cookies.delete('chocolate_chip', 'blueberry')
Delete all cookies
------------------

For more details check the API reference of the
:class:`CookieManager <splinter.cookie_manager.CookieManagerAPI>` class.
.. code-block:: python
Extra Arguments
~~~~~~~~~~~~~~~
browser.cookies.delete_all()
Each driver accepts various parameters when creating cookies.
These can be used with browser.cookies.add as extra arguments.
For example, WebDriver can use `path`, `domain`, `secure`, and `expiry`:
Further Reading
---------------

::
browser.cookies.add({'cookie_name': 'cookie_value'}, path='/cookiePath')
For more details see the API reference for the
:class:`CookieManager <splinter.abc.cookie_manager.CookieManagerAPI>` class.
10 changes: 5 additions & 5 deletions docs/install/external.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ Geckodriver must also be available on your operating system's `PATH` environment


Install
+++++++
-------

Mac OS X
--------
~~~~~~~~

The recommended way is by using `Homebrew <http://mxcl.github.com/homebrew/>`_:

Expand All @@ -102,17 +102,17 @@ Microsoft Edge Driver must also be available on your operating system's `PATH` e


Install
+++++++
-------

Mac OS X
--------
~~~~~~~~

Modern versions of Edge (79+) are available for Mac OS X.
However, no versions of Edge Legacy are available.


Linux
-----
~~~~~

Neither version of Edge is available for Linux, and thus Edge WebDriver
cannot be used on Linux systems.
11 changes: 2 additions & 9 deletions splinter/abc/cookie_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@


class CookieManagerAPI(ABC):
"""Specification for how a Splinter driver deals with cookies.
Add cookies using the :meth:`add <CookieManagerAPI.add>` method,
and remove cookies using
the :meth:`delete <CookieManagerAPI.delete>` and
:meth:`delete <CookieManagerAPI.delete_all>`methods.
"""Specification for how a Splinter driver handles cookies.
A CookieManager acts like a ``dict``, so you can access the value of a
cookie through the [] operator, passing the cookie identifier:
Expand Down Expand Up @@ -45,10 +40,8 @@ def add(self, cookie, **kwargs) -> None:
def delete(self, *cookies: str) -> None:
"""Delete one or more cookies.
You can pass all the cookies identifier that you want to delete.
Arguments:
cookies (list): Identifiers for each cookie to delete.
cookies (str): Identifiers for each cookie to delete.
Examples:
Expand Down
9 changes: 5 additions & 4 deletions splinter/driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ def find_by_name(self, name: str) -> ElementList:
"%s doesn't support finding elements by name." % self.driver_name,
)

def find_by_id(self, id: str) -> ElementList: # NOQA: A002
def find_by_id(self, id_value: str) -> ElementList: # NOQA: A002
"""Find an element on the current page by its id.
Even when only one element is find, this method returns an instance of
:class:`ElementList <splinter.element_list.ElementList>`
Arguments:
id (str): id to use in the search query.
id_value (str): id to use in the search query.
"""
raise NotImplementedError(
"%s doesn't support finding elements by id." % self.driver_name,
Expand Down Expand Up @@ -322,6 +322,7 @@ def fill_form(
field_values,
form_id: Optional[str] = None,
name: Optional[str] = None,
ignore_missing: bool = False,
) -> None:
"""
Fill the fields identified by ``name`` with the content specified by ``value`` in a dict.
Expand Down Expand Up @@ -425,7 +426,7 @@ def is_element_present_by_css(
"""Verify if an element is present in the current page.
Arguments:
css (str): css selector for the element.
css_selector (str): css selector for the element.
wait_time (int): Number of seconds to search.
Returns:
Expand All @@ -443,7 +444,7 @@ def is_element_not_present_by_css(
"""Verify if an element is not present in the current page.
Arguments:
css (str): css selector for the element.
css_selector (str): css selector for the element.
wait_time (int): Number of seconds to search.
Returns:
Expand Down
6 changes: 3 additions & 3 deletions splinter/driver/lxmldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def find_option_by_text(self, text):
query=text,
)

def find_by_css(self, selector):
xpath = CSSSelector(selector).path
return self.find_by_xpath(xpath, original_find="css", original_query=selector)
def find_by_css(self, css_selector):
xpath = CSSSelector(css_selector).path
return self.find_by_xpath(xpath, original_find="css", original_query=css_selector)

def find_by_xpath(self, xpath, original_find=None, original_query=None):
html = self.htmltree
Expand Down
4 changes: 2 additions & 2 deletions splinter/driver/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ def find_by_text(self, text=None, wait_time=None):
wait_time=wait_time,
)

def find_by_id(self, id, wait_time=None): # NOQA: A002
def find_by_id(self, id_value, wait_time=None): # NOQA: A002
return self.find_by(
self.driver.find_element,
finder_kwargs={"by": By.ID, "value": id},
finder_kwargs={"by": By.ID, "value": id_value},
wait_time=wait_time,
)

Expand Down
6 changes: 3 additions & 3 deletions splinter/driver/zopetestbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ def find_option_by_text(self, text):
query=text,
)

def find_by_css(self, selector):
xpath = CSSSelector(selector).path
return self.find_by_xpath(xpath, original_find="css", original_query=selector)
def find_by_css(self, css_selector):
xpath = CSSSelector(css_selector).path
return self.find_by_xpath(xpath, original_find="css", original_query=css_selector)

def get_control(self, xpath_element):
return xpath_element
Expand Down

0 comments on commit 589013f

Please sign in to comment.