INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Get the type of an image from the file s extension (. jpg etc. )
def bitmap_type(filename): """ Get the type of an image from the file's extension ( .jpg, etc. ) """ if filename == '': return None name, ext = os.path.splitext(filename) ext = ext[1:].upper() if ext == 'BMP': return wx.BITMAP_TYPE_BMP elif ext == 'GIF': ...
Get the type of an image from the file s extension (. jpg etc. )
def _getbitmap_type( self, filename ) : """ Get the type of an image from the file's extension ( .jpg, etc. ) """ # KEA 2001-07-27 # was #name, ext = filename.split( '.' ) #ext = ext.upper() if filename is None or filename == '': retur...
Set icon based on resource values
def _set_icon(self, icon=None): """Set icon based on resource values""" if icon is not None: try: wx_icon = wx.Icon(icon, wx.BITMAP_TYPE_ICO) self.wx_obj.SetIcon(wx_icon) except: pass
Display or hide the window optionally disabling all other windows
def show(self, value=True, modal=None): "Display or hide the window, optionally disabling all other windows" self.wx_obj.Show(value) if modal: # disable all top level windows of this application (MakeModal) disabler = wx.WindowDisabler(self.wx_obj) # cre...
Draws an arc of a circle centered on ( xc yc ) with starting point ( x1 y1 ) and ending at ( x2 y2 ). The current pen is used for the outline and the current brush for filling the shape.
def draw_arc(self, x1y1, x2y2, xcyc): """ Draws an arc of a circle, centered on (xc, yc), with starting point (x1, y1) and ending at (x2, y2). The current pen is used for the outline and the current brush for filling the shape. The arc is drawn in an anticlockwise direction from...
automatically adjust relative pos and size of children controls
def resize(self, evt=None): "automatically adjust relative pos and size of children controls" for child in self: if isinstance(child, Control): child.resize(evt) # call original handler (wx.HtmlWindow) if evt: evt.Skip()
Open read and eval the resource from the source file
def parse(filename=""): "Open, read and eval the resource from the source file" # use the provided resource file: s = open(filename).read() ##s.decode("latin1").encode("utf8") import datetime, decimal rsrc = eval(s) return rsrc
Save the resource to the source file
def save(filename, rsrc): "Save the resource to the source file" s = pprint.pformat(rsrc) ## s = s.encode("utf8") open(filename, "w").write(s)
Create the GUI objects defined in the resource ( filename or python struct )
def load(controller=None, filename="", name=None, rsrc=None): "Create the GUI objects defined in the resource (filename or python struct)" # if no filename is given, search for the rsrc.py with the same module name: if not filename and not rsrc: if isinstance(controller, types.ClassType): ...
Create a gui2py window based on the python resource
def build_window(res): "Create a gui2py window based on the python resource" # windows specs (parameters) kwargs = dict(res.items()) wintype = kwargs.pop('type') menubar = kwargs.pop('menubar', None) components = kwargs.pop('components') panel = kwargs.pop('panel', {}) from gui...
Create a gui2py control based on the python resource
def build_component(res, parent=None): "Create a gui2py control based on the python resource" # control specs (parameters) kwargs = dict(res.items()) comtype = kwargs.pop('type') if 'components' in res: components = kwargs.pop('components') elif comtype == 'Menu' and 'items' in res: ...
Recursive convert a live GUI object to a resource list/ dict
def dump(obj): "Recursive convert a live GUI object to a resource list/dict" from .spec import InitSpec, DimensionSpec, StyleSpec, InternalSpec import decimal, datetime from .font import Font from .graphic import Bitmap, Color from . import registry ret = {'type': obj.__class__.__name_...
Associate event handlers
def connect(component, controller=None): "Associate event handlers " # get the controller functions and names (module or class) if not controller or isinstance(controller, dict): if not controller: controller = util.get_caller_module_dict() controller_name = controller['__na...
translate gui2py attribute name from pythoncard legacy code
def convert(self, name): "translate gui2py attribute name from pythoncard legacy code" new_name = PYTHONCARD_PROPERTY_MAP.get(name) if new_name: print "WARNING: property %s should be %s (%s)" % (name, new_name, self.obj.name) return new_name else: retu...
Read from the clipboard content return a suitable object ( string or bitmap )
def get_data(): "Read from the clipboard content, return a suitable object (string or bitmap)" data = None try: if wx.TheClipboard.Open(): if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)): do = wx.TextDataObject() wx.TheClipboard.GetData(do) ...
Write content to the clipboard data can be either a string or a bitmap
def set_data(data): "Write content to the clipboard, data can be either a string or a bitmap" try: if wx.TheClipboard.Open(): if isinstance(data, (str, unicode)): do = wx.TextDataObject() do.SetText(data) wx.TheClipboard.SetData(do) ...
Find out what items are documented in source/ *. rst.
def find_autosummary_in_files(filenames): """Find out what items are documented in source/*.rst. See `find_autosummary_in_lines`. """ documented = [] for filename in filenames: f = open(filename, 'r') lines = f.read().splitlines() documented.extend(find_autosummary_in_lines(...
Find out what items are documented in the given object s docstring.
def find_autosummary_in_docstring(name, module=None, filename=None): """Find out what items are documented in the given object's docstring. See `find_autosummary_in_lines`. """ try: real_name, obj, parent = import_by_name(name) lines = pydoc.getdoc(obj).splitlines() return find_...
Find out what items appear in autosummary:: directives in the given lines.
def find_autosummary_in_lines(lines, module=None, filename=None): """Find out what items appear in autosummary:: directives in the given lines. Returns a list of (name, toctree, template) where *name* is a name of an object and *toctree* the :toctree: path of the corresponding autosummary directive...
Add the object and all their childs
def load_object(self, obj=None): "Add the object and all their childs" # if not obj is given, do a full reload using the current root if obj: self.root_obj = obj else: obj = self.root_obj self.tree.DeleteAllItems() self.root = self.tree.AddRoot("ap...
Select the object and show its properties
def inspect(self, obj, context_menu=False, edit_prop=False, mouse_pos=None): "Select the object and show its properties" child = self.tree.FindItem(self.root, obj.name) if DEBUG: print "inspect child", child if child: self.tree.ScrollTo(child) self.tree.SetCurrent...
load the selected item in the property editor
def activate_item(self, child, edit_prop=False, select=False): "load the selected item in the property editor" d = self.tree.GetItemData(child) if d: o = d.GetData() self.selected_obj = o callback = lambda o=o, **kwargs: self.update(o, **kwargs) se...
Update the tree item when the object name changes
def update(self, obj, **kwargs): "Update the tree item when the object name changes" # search for the old name: child = self.tree.FindItem(self.root, kwargs['name']) if DEBUG: print "update child", child, kwargs if child: self.tree.ScrollTo(child) self.tre...
Open a popup menu with options regarding the selected object
def show_context_menu(self, item, mouse_pos=None): "Open a popup menu with options regarding the selected object" if item: d = self.tree.GetItemData(item) if d: obj = d.GetData() if obj: # highligh and store the selected object:...
Re - parent a child control with the new wx_obj parent ( owner )
def set_parent(self, new_parent, init=False): "Re-parent a child control with the new wx_obj parent (owner)" ##SubComponent.set_parent(self, new_parent, init) self.wx_obj.SetOwner(new_parent.wx_obj.GetEventHandler())
Perform the actual serialization.
def to_representation(self, value): """ Perform the actual serialization. Args: value: the image to transform Returns: a url pointing at a scaled and cached image """ if not value: return None image = get_thumbnail(value, self...
Builds and registers a: class: Selector object with the given name and configuration.
def add_selector(name): """ Builds and registers a :class:`Selector` object with the given name and configuration. Args: name (str): The name of the selector. Yields: SelectorFactory: The factory that will build the :class:`Selector`. """ factory = SelectorFactory(name) yi...
Dict [ str ExpressionFilter ]: Returns the expression filters for this selector.
def expression_filters(self): """ Dict[str, ExpressionFilter]: Returns the expression filters for this selector. """ return { name: filter for name, filter in iter(self.filters.items()) if isinstance(filter, ExpressionFilter)}
Dict [ str NodeFilter ]: Returns the node filters for this selector.
def node_filters(self): """ Dict[str, NodeFilter]: Returns the node filters for this selector. """ return { name: filter for name, filter in iter(self.filters.items()) if isinstance(filter, NodeFilter)}
Returns a decorator function for adding an expression filter.
def expression_filter(self, name, **kwargs): """ Returns a decorator function for adding an expression filter. Args: name (str): The name of the filter. **kwargs: Variable keyword arguments for the filter. Returns: Callable[[Callable[[AbstractExpress...
Returns a decorator function for adding a node filter.
def node_filter(self, name, **kwargs): """ Returns a decorator function for adding a node filter. Args: name (str): The name of the filter. **kwargs: Variable keyword arguments for the filter. Returns: Callable[[Callable[[Element, Any], bool]]]: A de...
Adds filters from a particular global: class: FilterSet.
def filter_set(self, name): """ Adds filters from a particular global :class:`FilterSet`. Args: name (str): The name of the set whose filters should be added. """ filter_set = filter_sets[name] for name, filter in iter(filter_set.filters.items()): ...
Selector: Returns a new: class: Selector instance with the current configuration.
def build_selector(self): """ Selector: Returns a new :class:`Selector` instance with the current configuration. """ kwargs = { 'label': self.label, 'descriptions': self.descriptions, 'filters': self.filters} if self.format == "xpath": kwargs['xpa...
Resolves this query relative to the given node.
def resolves_for(self, node): """ Resolves this query relative to the given node. Args: node (node.Base): The node to be evaluated. Returns: int: The number of matches found. """ self.node = node self.actual_styles = node.style(*self.exp...
str: A message describing the query failure.
def failure_message(self): """ str: A message describing the query failure. """ return ( "Expected node to have styles {expected}. " "Actual styles were {actual}").format( expected=desc(self.expected_styles), actual=desc(self.actual_styles))
Asserts that the page has the given path. By default this will compare against the path + query portion of the full URL.
def assert_current_path(self, path, **kwargs): """ Asserts that the page has the given path. By default this will compare against the path+query portion of the full URL. Args: path (str | RegexObject): The string or regex that the current "path" should match. **k...
Asserts that the page doesn t have the given path.
def assert_no_current_path(self, path, **kwargs): """ Asserts that the page doesn't have the given path. Args: path (str | RegexObject): The string or regex that the current "path" should match. **kwargs: Arbitrary keyword arguments for :class:`CurrentPathQuery`. ...
Checks if the page has the given path.
def has_current_path(self, path, **kwargs): """ Checks if the page has the given path. Args: path (str | RegexObject): The string or regex that the current "path" should match. **kwargs: Arbitrary keyword arguments for :class:`CurrentPathQuery`. Returns: ...
Checks if the page doesn t have the given path.
def has_no_current_path(self, path, **kwargs): """ Checks if the page doesn't have the given path. Args: path (str | RegexObject): The string or regex that the current "path" should match. **kwargs: Arbitrary keyword arguments for :class:`CurrentPathQuery`. Retu...
Retrieve the text of the element. If: data: capybara. ignore_hidden_elements is True which it is by default then this will return only text which is visible. The exact semantics of this may differ between drivers but generally any text within elements with display: none is ignored.
def text(self): """ Retrieve the text of the element. If :data:`capybara.ignore_hidden_elements` is ``True``, which it is by default, then this will return only text which is visible. The exact semantics of this may differ between drivers, but generally any text within elements with ...
Select this node if it is an option element inside a select tag.
def select_option(self): """ Select this node if it is an option element inside a select tag. """ if self.disabled: warn("Attempt to select disabled option: {}".format(self.value or self.text)) self.base.select_option()
Returns the given expression filtered by the given value.
def apply_filter(self, expr, value): """ Returns the given expression filtered by the given value. Args: expr (xpath.expression.AbstractExpression): The expression to filter. value (object): The desired value with which the expression should be filtered. Returns...
Returns an instance of the given browser with the given capabilities.
def get_browser(browser_name, capabilities=None, **options): """ Returns an instance of the given browser with the given capabilities. Args: browser_name (str): The name of the desired browser. capabilities (Dict[str, str | bool], optional): The desired capabilities of the browser. ...
Dict [ str Any ]: The keyword arguments with which this query was initialized.
def kwargs(self): """ Dict[str, Any]: The keyword arguments with which this query was initialized. """ kwargs = {} kwargs.update(self.options) kwargs.update(self.filter_options) return kwargs
str: A long description of this query.
def description(self): """ str: A long description of this query. """ description = self.label if self.locator: description += " {}".format(desc(self.locator)) if self.options["text"] is not None: description += " with text {}".format(desc(self.options["text"]))...
str: The desired element visibility.
def visible(self): """ str: The desired element visibility. """ if self.options["visible"] is not None: if self.options["visible"] is True: return "visible" elif self.options["visible"] is False: return "all" else: retur...
Returns the XPath query for this selector.
def xpath(self, exact=None): """ Returns the XPath query for this selector. Args: exact (bool, optional): Whether to exactly match text. Returns: str: The XPath query for this selector. """ exact = exact if exact is not None else self.exact ...
Resolves this query relative to the given node.
def resolve_for(self, node, exact=None): """ Resolves this query relative to the given node. Args: node (node.Base): The node relative to which this query should be resolved. exact (bool, optional): Whether to exactly match text. Returns: list[Elemen...
Returns whether the given node matches all filters.
def matches_filters(self, node): """ Returns whether the given node matches all filters. Args: node (Element): The node to evaluate. Returns: bool: Whether the given node matches. """ visible = self.visible if self.options["text"]: ...
node. Base: The current node relative to which all interaction will be scoped.
def current_scope(self): """ node.Base: The current node relative to which all interaction will be scoped. """ scope = self._scopes[-1] if scope in [None, "frame"]: scope = self.document return scope
str: Path of the current page without any domain information.
def current_path(self): """ str: Path of the current page, without any domain information. """ if not self.current_url: return path = urlparse(self.current_url).path return path if path else None
str: Host of the current page.
def current_host(self): """ str: Host of the current page. """ if not self.current_url: return result = urlparse(self.current_url) scheme, netloc = result.scheme, result.netloc host = netloc.split(":")[0] if netloc else None return "{0}://{1}".format(scheme,...
Navigate to the given URL. The URL can either be a relative URL or an absolute URL. The behavior of either depends on the driver.::
def visit(self, visit_uri): """ Navigate to the given URL. The URL can either be a relative URL or an absolute URL. The behavior of either depends on the driver. :: session.visit("/foo") session.visit("http://google.com") For drivers which can run against an ext...
Executes the wrapped code within the context of a node. scope takes the same options as: meth: find. For the duration of the context any command to Capybara will be handled as though it were scoped to the given element.::
def scope(self, *args, **kwargs): """ Executes the wrapped code within the context of a node. ``scope`` takes the same options as :meth:`find`. For the duration of the context, any command to Capybara will be handled as though it were scoped to the given element. :: with sco...
Execute the wrapped code within the given iframe using the given frame or frame name/ id. May not be supported by all drivers.
def frame(self, locator=None, *args, **kwargs): """ Execute the wrapped code within the given iframe using the given frame or frame name/id. May not be supported by all drivers. Args: locator (str | Element, optional): The name/id of the frame or the frame's element. ...
Switch to the given frame.
def switch_to_frame(self, frame): """ Switch to the given frame. If you use this method you are responsible for making sure you switch back to the parent frame when done in the frame changed to. :meth:`frame` is preferred over this method and should be used when possible. May no...
If window is a lambda it switches to the first window for which window returns a value other than False or None. If a window that matches can t be found the window will be switched back and: exc: WindowError will be raised.
def switch_to_window(self, window, wait=None): """ If ``window`` is a lambda, it switches to the first window for which ``window`` returns a value other than False or None. If a window that matches can't be found, the window will be switched back and :exc:`WindowError` will be raised. ...
This method does the following:
def window(self, window): """ This method does the following: 1. Switches to the given window (it can be located by window instance/lambda/string). 2. Executes the given block (within window located at previous step). 3. Switches back (this step will be invoked even if exception...
Get the window that has been opened by the passed lambda. It will wait for it to be opened ( in the same way as other Capybara methods wait ). It s better to use this method than windows [ - 1 ] as order of windows isn t defined in some drivers __.
def window_opened_by(self, trigger_func, wait=None): """ Get the window that has been opened by the passed lambda. It will wait for it to be opened (in the same way as other Capybara methods wait). It's better to use this method than ``windows[-1]`` `as order of windows isn't defined in ...
Execute the given script not returning a result. This is useful for scripts that return complex objects such as jQuery statements. execute_script should be used over: meth: evaluate_script whenever possible.
def execute_script(self, script, *args): """ Execute the given script, not returning a result. This is useful for scripts that return complex objects, such as jQuery statements. ``execute_script`` should be used over :meth:`evaluate_script` whenever possible. Args: s...
Evaluate the given JavaScript and return the result. Be careful when using this with scripts that return complex objects such as jQuery statements.: meth: execute_script might be a better alternative.
def evaluate_script(self, script, *args): """ Evaluate the given JavaScript and return the result. Be careful when using this with scripts that return complex objects, such as jQuery statements. :meth:`execute_script` might be a better alternative. Args: script (str)...
Execute the wrapped code accepting an alert.
def accept_alert(self, text=None, wait=None): """ Execute the wrapped code, accepting an alert. Args: text (str | RegexObject, optional): Text to match against the text in the modal. wait (int | float, optional): Maximum time to wait for the modal to appear after ...
Execute the wrapped code accepting a confirm.
def accept_confirm(self, text=None, wait=None): """ Execute the wrapped code, accepting a confirm. Args: text (str | RegexObject, optional): Text to match against the text in the modal. wait (int | float, optional): Maximum time to wait for the modal to appear after ...
Execute the wrapped code dismissing a confirm.
def dismiss_confirm(self, text=None, wait=None): """ Execute the wrapped code, dismissing a confirm. Args: text (str | RegexObject, optional): Text to match against the text in the modal. wait (int | float, optional): Maximum time to wait for the modal to appear after ...
Execute the wrapped code accepting a prompt optionally responding to the prompt.
def accept_prompt(self, text=None, response=None, wait=None): """ Execute the wrapped code, accepting a prompt, optionally responding to the prompt. Args: text (str | RegexObject, optional): Text to match against the text in the modal. response (str, optional): Response ...
Execute the wrapped code dismissing a prompt.
def dismiss_prompt(self, text=None, wait=None): """ Execute the wrapped code, dismissing a prompt. Args: text (str | RegexObject, optional): Text to match against the text in the modal. wait (int | float, optional): Maximum time to wait for the modal to appear after ...
Save a snapshot of the page.
def save_page(self, path=None): """ Save a snapshot of the page. If invoked without arguments, it will save a file to :data:`capybara.save_path` and the file will be given a randomly generated filename. If invoked with a relative path, the path will be relative to :data:`capybar...
Save a screenshot of the page.
def save_screenshot(self, path=None, **kwargs): """ Save a screenshot of the page. If invoked without arguments, it will save a file to :data:`capybara.save_path` and the file will be given a randomly generated filename. If invoked with a relative path, the path will be relative...
Reset the session ( i. e. remove cookies and navigate to a blank page ).
def reset(self): """ Reset the session (i.e., remove cookies and navigate to a blank page). This method does not: * accept modal dialogs if they are present (the Selenium driver does, but others may not), * clear the browser cache/HTML 5 local storage/IndexedDB/Web SQL database/...
Raise errors encountered by the server.
def raise_server_error(self): """ Raise errors encountered by the server. """ if self.server and self.server.error: try: if capybara.raise_server_errors: raise self.server.error finally: self.server.reset_error()
Returns whether the given node matches the filter rule with the given value.
def matches(self, node, value): """ Returns whether the given node matches the filter rule with the given value. Args: node (Element): The node to filter. value (object): The desired value with which the node should be evaluated. Returns: bool: Wheth...
str: The package version.
def get_version(): """ str: The package version. """ global_vars = {} # Compile and execute the individual file to prevent # the package from being automatically loaded. source = read(os.path.join("capybara", "version.py")) code = compile(source, "version.py", "exec") exec(code, global_var...
Resolves this query relative to the given node.
def resolves_for(self, node): """ Resolves this query relative to the given node. Args: node (node.Document): The node to be evaluated. Returns: bool: Whether the given node matches this query. """ self.actual_title = normalize_text(node.title) ...
str: The title for the current frame.
def frame_title(self): """ str: The title for the current frame. """ elements = self._find_xpath("/html/head/title") titles = [element.all_text for element in elements] return titles[0] if len(titles) else ""
str: The value of the form element.
def value(self): """ str: The value of the form element. """ if self.tag_name == "textarea": return inner_content(self.native) elif self.tag_name == "select": if self["multiple"] == "multiple": selected_options = self._find_xpath(".//option[@selected='sel...
Builds and registers a global: class: FilterSet.
def add_filter_set(name): """ Builds and registers a global :class:`FilterSet`. Args: name (str): The name of the set. Yields: FilterSetFactory: A configurable factory for building a :class:`FilterSet`. """ factory = FilterSetFactory(name) yield factory filter_sets[nam...
Returns the: class: Session for the current driver and app instantiating one if needed.
def current_session(): """ Returns the :class:`Session` for the current driver and app, instantiating one if needed. Returns: Session: The :class:`Session` for the current driver and app. """ driver = current_driver or default_driver session_key = "{driver}:{session}:{app}".format( ...
Checks if allof the provided selectors are present on the given page or descendants of the current node. If options are provided the assertion will check that each locator is present with those options as well ( other than wait ).::
def has_all_of_selectors(self, selector, *locators, **kwargs): """ Checks if allof the provided selectors are present on the given page or descendants of the current node. If options are provided, the assertion will check that each locator is present with those options as well (other tha...
Checks if none of the provided selectors are present on the given page or descendants of the current node. If options are provided the assertion will check that each locator is present with those options as well ( other than wait ).::
def has_none_of_selectors(self, selector, *locators, **kwargs): """ Checks if none of the provided selectors are present on the given page or descendants of the current node. If options are provided, the assertion will check that each locator is present with those options as well (other ...
Asserts that a given selector is on the page or a descendant of the current node.::
def assert_selector(self, *args, **kwargs): """ Asserts that a given selector is on the page or a descendant of the current node. :: page.assert_selector("p#foo") By default it will check if the expression occurs at least once, but a different number can be specified. :: ...
Asserts that an element has the specified CSS styles.::
def assert_style(self, styles, **kwargs): """ Asserts that an element has the specified CSS styles. :: element.assert_style({"color": "rgb(0,0,255)", "font-size": re.compile(r"px")}) Args: styles (Dict[str, str | RegexObject]): The expected styles. Returns: ...
Asserts that all of the provided selectors are present on the given page or descendants of the current node. If options are provided the assertion will check that each locator is present with those options as well ( other than wait ).::
def assert_all_of_selectors(self, selector, *locators, **kwargs): """ Asserts that all of the provided selectors are present on the given page or descendants of the current node. If options are provided, the assertion will check that each locator is present with those options as well (ot...
Asserts that none of the provided selectors are present on the given page or descendants of the current node. If options are provided the assertion will check that each locator is present with those options as well ( other than wait ).::
def assert_none_of_selectors(self, selector, *locators, **kwargs): """ Asserts that none of the provided selectors are present on the given page or descendants of the current node. If options are provided, the assertion will check that each locator is present with those options as well (...
Asserts that a given selector is not on the page or a descendant of the current node. Usage is identical to: meth: assert_selector.
def assert_no_selector(self, *args, **kwargs): """ Asserts that a given selector is not on the page or a descendant of the current node. Usage is identical to :meth:`assert_selector`. Query options such as ``count``, ``minimum``, and ``between`` are considered to be an integral ...
Asserts that the current node matches a given selector.::
def assert_matches_selector(self, *args, **kwargs): """ Asserts that the current node matches a given selector. :: node.assert_matches_selector("p#foo") node.assert_matches_selector("xpath", "//p[@id='foo']") It also accepts all options that :meth:`find_all` accepts, su...
Checks if the page or current node has a radio button or checkbox with the given label value or id that is currently checked.
def has_checked_field(self, locator, **kwargs): """ Checks if the page or current node has a radio button or checkbox with the given label, value, or id, that is currently checked. Args: locator (str): The label, name, or id of a checked field. **kwargs: Arbitrar...
Checks if the page or current node has no radio button or checkbox with the given label value or id that is currently checked.
def has_no_checked_field(self, locator, **kwargs): """ Checks if the page or current node has no radio button or checkbox with the given label, value, or id that is currently checked. Args: locator (str): The label, name, or id of a checked field. **kwargs: Arbit...
Checks if the page or current node has a radio button or checkbox with the given label value or id that is currently unchecked.
def has_unchecked_field(self, locator, **kwargs): """ Checks if the page or current node has a radio button or checkbox with the given label, value, or id, that is currently unchecked. Args: locator (str): The label, name, or id of an unchecked field. **kwargs: A...
Checks if the page or current node has no radio button or checkbox with the given label value or id that is currently unchecked.
def has_no_unchecked_field(self, locator, **kwargs): """ Checks if the page or current node has no radio button or checkbox with the given label, value, or id, that is currently unchecked. Args: locator (str): The label, name, or id of an unchecked field. **kwarg...
Asserts that the page or current node has the given text content ignoring any HTML tags.
def assert_text(self, *args, **kwargs): """ Asserts that the page or current node has the given text content, ignoring any HTML tags. Args: *args: Variable length argument list for :class:`TextQuery`. **kwargs: Arbitrary keyword arguments for :class:`TextQuery`. ...
Asserts that the page or current node doesn t have the given text content ignoring any HTML tags.
def assert_no_text(self, *args, **kwargs): """ Asserts that the page or current node doesn't have the given text content, ignoring any HTML tags. Args: *args: Variable length argument list for :class:`TextQuery`. **kwargs: Arbitrary keyword arguments for :class:`...
Asserts that the page has the given title.
def assert_title(self, title, **kwargs): """ Asserts that the page has the given title. Args: title (str | RegexObject): The string or regex that the title should match. **kwargs: Arbitrary keyword arguments for :class:`TitleQuery`. Returns: True ...
Asserts that the page doesn t have the given title.
def assert_no_title(self, title, **kwargs): """ Asserts that the page doesn't have the given title. Args: title (str | RegexObject): The string that the title should include. **kwargs: Arbitrary keyword arguments for :class:`TitleQuery`. Returns: Tru...
Checks if the page has the given title.
def has_title(self, title, **kwargs): """ Checks if the page has the given title. Args: title (str | RegexObject): The string or regex that the title should match. **kwargs: Arbitrary keyword arguments for :class:`TitleQuery`. Returns: bool: Whether ...
Checks if the page doesn t have the given title.
def has_no_title(self, title, **kwargs): """ Checks if the page doesn't have the given title. Args: title (str | RegexObject): The string that the title should include. **kwargs: Arbitrary keyword arguments for :class:`TitleQuery`. Returns: bool: Whe...
Find all elements on the page matching the given selector and options.
def find_all(self, *args, **kwargs): """ Find all elements on the page matching the given selector and options. Both XPath and CSS expressions are supported, but Capybara does not try to automatically distinguish between them. The following statements are equivalent:: page....
Find the first element on the page matching the given selector and options or None if no element matches.
def find_first(self, *args, **kwargs): """ Find the first element on the page matching the given selector and options, or None if no element matches. By default, no waiting behavior occurs. However, if ``capybara.wait_on_first_by_default`` is set to true, it will trigger Capybar...
Resolves this query relative to the given node.
def resolve_for(self, node): """ Resolves this query relative to the given node. Args: node (node.Base): The node to be evaluated. Returns: int: The number of matches found. """ self.node = node self.actual_text = normalize_text( ...
Returns the inner content of a given XML node including tags.
def inner_content(node): """ Returns the inner content of a given XML node, including tags. Args: node (lxml.etree.Element): The node whose inner content is desired. Returns: str: The inner content of the node. """ from lxml import etree # Include text content at the star...
Returns the inner text of a given XML node excluding tags.
def inner_text(node): """ Returns the inner text of a given XML node, excluding tags. Args: node: (lxml.etree.Element): The node whose inner text is desired. Returns: str: The inner text of the node. """ from lxml import etree # Include text content at the start of the no...