From 589013f4b78d4f1e119aa06ea43473b7749acbeb Mon Sep 17 00:00:00 2001 From: jsfehler Date: Thu, 30 May 2024 08:57:18 -0400 Subject: [PATCH] fix: Various errors when building docs (#1287) --- docs/cookies.rst | 51 ++++++++++++++++----------- docs/install/external.rst | 10 +++--- splinter/abc/cookie_manager.py | 11 ++---- splinter/driver/__init__.py | 9 ++--- splinter/driver/lxmldriver.py | 6 ++-- splinter/driver/webdriver/__init__.py | 4 +-- splinter/driver/zopetestbrowser.py | 6 ++-- 7 files changed, 51 insertions(+), 46 deletions(-) diff --git a/docs/cookies.rst b/docs/cookies.rst index 882edfa14..9a5b2b357 100644 --- a/docs/cookies.rst +++ b/docs/cookies.rst @@ -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 -------------------- @@ -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 ` 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 ` class. diff --git a/docs/install/external.rst b/docs/install/external.rst index 2ba2f59cf..7f6998a08 100644 --- a/docs/install/external.rst +++ b/docs/install/external.rst @@ -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 `_: @@ -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. diff --git a/splinter/abc/cookie_manager.py b/splinter/abc/cookie_manager.py index 2c1b4733f..13d4d09e1 100644 --- a/splinter/abc/cookie_manager.py +++ b/splinter/abc/cookie_manager.py @@ -6,12 +6,7 @@ class CookieManagerAPI(ABC): - """Specification for how a Splinter driver deals with cookies. - - Add cookies using the :meth:`add ` method, - and remove cookies using - the :meth:`delete ` and - :meth:`delete `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: @@ -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: diff --git a/splinter/driver/__init__.py b/splinter/driver/__init__.py index 831326fc5..a57ea263f 100644 --- a/splinter/driver/__init__.py +++ b/splinter/driver/__init__.py @@ -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 ` 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, @@ -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. @@ -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: @@ -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: diff --git a/splinter/driver/lxmldriver.py b/splinter/driver/lxmldriver.py index ff31dc0df..2e7dcc559 100644 --- a/splinter/driver/lxmldriver.py +++ b/splinter/driver/lxmldriver.py @@ -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 diff --git a/splinter/driver/webdriver/__init__.py b/splinter/driver/webdriver/__init__.py index a4bf95db6..cd8049f9c 100644 --- a/splinter/driver/webdriver/__init__.py +++ b/splinter/driver/webdriver/__init__.py @@ -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, ) diff --git a/splinter/driver/zopetestbrowser.py b/splinter/driver/zopetestbrowser.py index 6fd179c85..3126c50f8 100644 --- a/splinter/driver/zopetestbrowser.py +++ b/splinter/driver/zopetestbrowser.py @@ -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