behave_manners.pagelems.base_parsers module¶
-
class
BaseDPOParser
(root_element)¶ Bases:
html.parser.HTMLParser
,object
-
close
()¶ Handle any buffered data.
-
get_result
()¶
-
handle_charref
(name)¶
-
handle_comment
(data)¶ Comments are ignored
-
handle_data
(data)¶ Reject any non-whitespace text in elements
-
handle_decl
(decl)¶
-
handle_endtag
(tag)¶
-
handle_entityref
(name)¶
-
handle_pi
(data)¶
-
handle_starttag
(tag, attrs)¶
-
logger
= None¶
-
unknown_decl
(data)¶
-
-
class
DBaseLinkElement
(tag, attrs)¶ Bases:
behave_manners.pagelems.base_parsers.DPageElement
Baseclass for <link> elements in any pagelem document
Links have mandatory “rel”, “href” attributes and optional “url”, “title”.
-
consume
(element)¶
-
is_empty
= True¶
-
reduce
(site=None)¶ Cleanup internally, possibly merging nested elements
None can be returned, in case this element is no longer useful. reduce() shall be called after all children have been scanned and appended to this; after thet have been reduced.
If site is provided, this should be a context object, which provides (or consumes) additional resources from this element.
-
-
class
DOMScope
(parent, templates=None)¶ Bases:
object
A simple holder of shared components or variables across DOM levels
-
class
Component
¶ Bases:
object
-
clear
()¶ Clears the text if it’s a text entry element.
-
click
()¶ Clicks the element.
-
get_attribute
(name)¶ Gets the given attribute or property of the element.
This method will first try to return the value of a property with the given name. If a property with that name doesn’t exist, it returns the value of the attribute with the same name. If there’s no attribute with that name,
None
is returned.Values which are considered truthy, that is equals “true” or “false”, are returned as booleans. All other non-
None
values are returned as strings. For attributes or properties which do not exist,None
is returned.Args: - name - Name of the attribute/property to retrieve.
Example:
# Check if the "active" CSS class is applied to an element. is_active = "active" in target_element.get_attribute("class")
-
get_property
(name)¶ Gets the given property of the element.
Args: - name - Name of the property to retrieve.
Usage: text_length = target_element.get_property("text_length")
-
is_displayed
()¶ Whether the element is visible to a user.
-
is_enabled
()¶ Returns whether the element is enabled.
-
is_selected
()¶ Returns whether the element is selected.
Can be used to check if a checkbox or radio button is selected.
-
send_keys
(*value)¶ Simulates typing into the element.
Args: - value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path.
Use this to send simple key events or to fill out form fields:
form_textfield = driver.find_element_by_name('username') form_textfield.send_keys("admin")
This can also be used to set file inputs.
file_input = driver.find_element_by_name('profilePic') file_input.send_keys("path/to/profilepic.gif") # Generally it's better to wrap the file path in one of the methods # in os.path to return the actual path to support cross OS testing. # file_input.send_keys(os.path.abspath("path/to/profilepic.gif"))
-
submit
()¶ Submits a form.
-
-
child
()¶ Return a child scope linked to this one
-
get_template
(key)¶
-
root_component
¶
-
take_component
(comp)¶
-
timeouts
= {}¶
-
wait_js_conditions
= []¶
-
class
-
class
DPageElement
(tag=None, attrs=())¶ Bases:
object
Base class for elements scanned in pagetemplate html
This is an abstract class, only subclasses shall be instantiated.
-
consume
(element)¶
-
is_empty
= False¶
-
iter_attrs
(webelem=None, scope=None, xpath_prefix='')¶ Iterate names of possible attributes
returns iterator of (name, descriptor)
-
iter_items
(remote, scope, xpath_prefix='', match=None)¶ Iterate possible children components
Parameters: - remote – remote WebElement to work on
- scope – DOMScope under which to operate
- xpath_prefix – hanging xpath from parent element
- match – if provided, only look for those items currently only a string is expected in match
Returns: tuple (name, welem, ptmpl, scope)
-
pretty_dom
()¶ Walk this template, generate (indent, name, xpath) sets of each node
Used for debugging, pretty-printing of parsed structure
-
reduce
(site=None)¶ Cleanup internally, possibly merging nested elements
None can be returned, in case this element is no longer useful. reduce() shall be called after all children have been scanned and appended to this; after thet have been reduced.
If site is provided, this should be a context object, which provides (or consumes) additional resources from this element.
-
tag
= ''¶
-
xpath
¶
-
xpath_locator
(score, top=False)¶ Return xpath locator of this and any child elements
Parameters: - score – mutable Integer, decrement depending on precision of locators
- top – locate exactly this (the top) element, or else any of its children
Returns: str
-
-
class
DataElement
(data)¶ Bases:
behave_manners.pagelems.base_parsers.DPageElement
-
append
(other)¶
-
consume
(element)¶
-
is_empty
= True¶
-
set_full
(full)¶
-
xpath_locator
(score, top=False)¶ Return xpath locator of this and any child elements
Parameters: - score – mutable Integer, decrement depending on precision of locators
- top – locate exactly this (the top) element, or else any of its children
Returns: str
-