zope.testbrowser¶
Usage¶
To use the zope.testbrowser
driver, all you need to do is pass the string zope.testbrowser
when you create
the Browser
instance:
from splinter import Browser
browser = Browser('zope.testbrowser')
Note: if you don’t provide any driver to Browser
function, firefox
will be used.
API docs¶
- class splinter.driver.zopetestbrowser.ZopeTestBrowser(wait_time=2, config: Config | None = None)[source]¶
- back()[source]¶
The browser will navigate to the previous URL in the history.
If there is no previous URL, this method does nothing.
- check(name)[source]¶
Check a checkbox by its name.
Example
>>> browser.check("agree-with-terms")
If you call
browser.check
n times, the checkbox keeps checked, it never get unchecked.To uncheck a checkbox, take a look in the
uncheck
method.
- choose(name, value)[source]¶
Choose a value in a radio buttons group.
Example
You have two radio buttons in a page, with the name
gender
and values ‘F’ and ‘M’.>>> browser.choose('gender', 'F')
Then the female gender will be chosen.
- property cookies¶
A
CookieManager
instance.For more details, check the cookies manipulation section.
- fill_form(field_values, form_id=None, name=None, ignore_missing=False)[source]¶
Fill the fields identified by
name
with the content specified byvalue
in a dict.Currently, fill_form supports the following fields: text, password, textarea, checkbox, radio and select.
Checkboxes should be specified as a boolean in the dict.
- find(locator)[source]¶
Find an element.
The default strategy used is ‘name’. To change the strategy, see: browser.set_find_strategy()
- find_by_css(selector)[source]¶
Return an instance of
ElementList
, using a CSS selector to query the current page content.- Parameters:¶
- css_selector : str
CSS Selector to use in the search query.
- find_by_id(id_value)[source]¶
Find an element on the current page by its id.
Even when only one element is find, this method returns an instance of
ElementList
- Parameters:¶
- id : str
id to use in the search query.
- find_by_name(name)[source]¶
Find elements on the current page by their name.
Return an instance of
ElementList
.
- find_by_tag(tag)[source]¶
Find all elements of a given tag in current page.
Returns an instance of
ElementList
- find_by_text(text)[source]¶
Find elements on the current page by their text.
Returns an instance of
ElementList
- find_by_value(value)[source]¶
Find elements on the current page by their value.
Returns an instance of
ElementList
- find_by_xpath(xpath, original_find=None, original_query=None)[source]¶
Return an instance of
ElementList
, using a xpath selector to query the current page content.
- find_option_by_text(text)[source]¶
Finds
<option>
elements by their text.Returns an instance of
ElementList
- find_option_by_value(value)[source]¶
Find
<option>
elements by their value.Returns an instance of
ElementList
- forward()[source]¶
The browser will navigate to the next URL in the history.
If there is no URL to forward, this method does nothing.
- get_alert() Any ¶
Change the context for working with alerts and prompts.
For more details, check the docs about iframes, alerts and prompts
- get_iframe(name: Any) Any ¶
Change the context for working with iframes.
For more details, check the docs about iframes, alerts and prompts
- property html¶
Source of current page.
- html_snapshot(name: str = '', suffix: str = '.html', encoding: str = 'utf-8', unique_file: bool = True) str ¶
Write the current html to a file.
- is_element_not_present_by_css(css_selector, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_not_present_by_id(id, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_not_present_by_name(name, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_not_present_by_tag(tag, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_not_present_by_text(text, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_not_present_by_value(value, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_not_present_by_xpath(xpath, wait_time=None)¶
Verify if an element is not present in the current page.
- is_element_present_by_css(css_selector, wait_time=None)¶
Verify if an element is present in the current page.
- is_element_present_by_name(name, wait_time=None)¶
Verify if an element is present in the current page.
- is_element_present_by_tag(tag, wait_time=None)¶
Verify if an element is present in the current page.
- is_element_present_by_text(text, wait_time=None)¶
Verify if an element is present in the current page.
- is_element_present_by_value(value, wait_time=None)¶
Verify if an element is present in the current page.
- is_element_present_by_xpath(xpath, wait_time=None)¶
Verify if an element is present in the current page.
- screenshot(name: str | None = None, suffix: str | None = None, full: bool = False, unique_file: bool = True) str ¶
Take a screenshot of the current page and save it locally.
- Parameters:¶
- name : str¶
File name for the screenshot.
- suffix : str¶
File extension for the screenshot.
- full : bool¶
If the screenshot should be full screen or not.
- unique_file : bool¶
If true, the filename will include a path to the system temp directory and extra characters at the end to ensure the file is unique.
- Returns:¶
Full file name of the created screenshot.
- Return type:¶
str
- select(name, value)[source]¶
Select an
<option>
element in an<select>
element using thename
of the<select>
and thevalue
of the<option>
.Example
>>> browser.select("state", "NY")
- property title¶
Title of current page.
- type(name: str, value: str, slowly: bool = False) str ¶
Type a value into an element.
It’s useful to test javascript events like keyPress, keyUp, keyDown, etc.
- uncheck(name)[source]¶
Uncheck a checkbox by its name.
Example
>>> browser.uncheck("send-me-emails")
If you call
brower.uncheck
n times, the checkbox keeps unchecked, it never get checked.To check a checkbox, take a look in the
check
method.
- property url¶
URL of current page.