zombie Package

zombie Package

browser Module

class zombie.browser.Browser(server=None)

Bases: object

A Browser object, analogous to zombie.js’ Browser.

__init__(server=None)

Start a new Browser instance.

Parameters:server – an (optional) instance of zombie.proxy.server.ZombieProxyServer.
attach(selector, filename)
back()

Navigate to the previous page in history.

Returns the zombie.browser.Browser to allow function chaining.

body

Returns a zombie.dom.DOMNode representing the body element of the current document.

check(selector)
choose(selector)

Clicks on a link. The first argument is the link text or CSS selector.

Parameters:selector – an optional string CSS selector (http://zombie.labnotes.org/selectors) or inner text

Returns the zombie.browser.Browser to allow function chaining.

css(selector, context=None)

An alias for zombie.browser.Browser.queryAll.

Parameters:
dump()

Prints a debug string including zombie.js version, current URL, history, cookies, event loop, etc. Useful for debugging and submitting error reports.

evaluate(code)
field(selector, context=None)
fill(field, value)

Fill a specified form field in the current document.

Parameters:
  • field – an instance of zombie.dom.DOMNode
  • value – any string value
Returns:

self to allow function chaining.

fire(selector, event_name)
get_resource(url)

Gets a resource and returns a json with information

html(selector=None, context=None)

Returns the HTML content (string) of the current document.

Parameters:

Finds and returns a link <a> element (zombie.dom.DOMNode). You can use a CSS selector or find a link by its text contents (case sensitive, but ignores leading/trailing spaces).

Parameters:selector – an optional string CSS selector (http://zombie.labnotes.org/selectors) or inner text
load(html)

Loads raw html

location

Returns the location of the current document (same as window.location.toString()).

post_resource(url, form_params)
pressButton(selector)

Press a specific button.

Parameters:selector – CSS selector or innerText
Returns:self to allow function chaining.
query(selector, context=None)

Evaluate a CSS selector against the document (or an optional context zombie.dom.DOMNode) and return a single zombie.dom.DOMNode object.

Parameters:
queryAll(selector, context=None)

Evaluate a CSS selector against the document (or an optional context zombie.dom.DOMNode) and return a list of zombie.dom.DOMNode objects.

Parameters:
redirected

Returns True if the page request followed a redirect.

reload()

Reloads the current page.

Returns the zombie.browser.Browser to allow function chaining.

resources

Returns a list of resources loaded by the browser, e.g.,

[{
    'method': 'GET',
    'url': 'http://www.example.com/',
    'statusCode': '200',
    'statusText': 'OK',
    'time': '200ms'
}]
select(selector, value)
selectOption(selector)
statusCode

Returns the status code returned for this page request (200, 303, etc).

success

Returns True if the status code is 2xx.

text(selector, context=None)

Returns the text content of specific elements.

Parameters:
uncheck(selector)
unselect(selector, value)
unselectOption(selector)

Unselects the given option

Special case. It seems there is a problem in Zombie: unselectOption doesn’t accept a selector.

Pull request pending in the zombie project

viewInBrowser()

Views the current document in a real Web browser. Uses the default system browser on OS X, BSD and Linux. Probably errors on Windows.

visit(url)

A shortcut to load the document from the specified URL.

Returns the zombie.browser.Browser to allow function chaining.

wait(wait_argument=None)
class zombie.browser.DOMNode(element, browser)

Bases: object

Represents a node in the current document’s DOM.

__init__(element, browser)
attach(filename)

If applicable, attaches a file to the specified input field

Parameters:filename – Filename of the file to attach.

Returns the zombie.dom.DOMNode to allow function chaining.

check()

If applicable, Checks a checkbox

Returns the zombie.dom.DOMNode to allow function chaining.

checked

The checked attribute of an <input type="checkbox">.

choose()

If applicable, chooses this radio button

click()

Fires a click event on the current node.

Returns the zombie.dom.DOMNode to allow function chaining.

css(selector)

An alias for zombie.dom.DOMNode.queryAll.

static factory(element, browser)
field()

The field of a zombie.dom.DOMNode is itself. Returns self.

fill(value)

If applicable, fill the current node’s value.

Parameters:value – any string value

Returns the zombie.dom.DOMNode to allow function chaining.

fire(event)

Fires a specified DOM event on the current node.

Parameters:event – the name of the event to fire (e.g., ‘click’).

Returns the zombie.dom.DOMNode to allow function chaining.

html

The innerHTML of the current node.

innerText

The textContent of the current node.

json
pressButton()

If applicable, press this button

Returns the zombie.dom.DOMNode to allow function chaining.

query(selector)

Evaluate a CSS selector against this element and return a single (child) zombie.dom.DOMNode object.

Parameters:selector – a string CSS selector (http://zombie.labnotes.org/selectors)
queryAll(selector)

Evaluate a CSS selector against this element and return a list of (child) zombie.dom.DOMNode objects.

Parameters:selector – a string CSS selector (http://zombie.labnotes.org/selectors)
select(value)

If applicable, selects an option

Parameters:value – Value (or label) or option to select

Returns the zombie.dom.DOMNode to allow function chaining.

selectOption()

If applicable, selects this option

Returns the zombie.dom.DOMNode to allow function chaining.

tagName

The tagName of the current node.

text

The textContent of the current node.

uncheck()

If applicable, unchecks a checkbox

Returns the zombie.dom.DOMNode to allow function chaining.

unselect(value)

If applicable, unselect an option

Parameters:value – Value (or label) or option to unselect

Returns the zombie.dom.DOMNode to allow function chaining.

unselectOption()

If applicable unselect this option

Returns the zombie.dom.DOMNode to allow function chaining.

value

The value of the current node.

dom Module

Subpackages