Skip to main content

browser abstraction for web acceptance testing

Project description

splinter - Python acceptance testing for web applications

development

Pull requests are very welcome! Make sure your patches are well tested.

running the tests

if you are using a virtualenv, all you need is:

$ make test

community

#cobrateam channel on irc.freenode.net

documentation

Browser

To use splinter you need create a Browser instance:

from splinter.browser import Browser
browser = Browser()

Browser.title

You can get the title of the visited page using the title attribute:

browser.title

Verifying page content with Browser.html

You can use the html attribute to get the html content of the visited page:

browser.html

Verifying page url with Browser.url

The visited page’s url can be accessed by the url attribute:

browser.url

Finding elements

For finding elements you can use five methods, one for each selector type css_selector, xpath, tag, name, id:

browser.find_by_css_selector('h1')
browser.find_by_xpath('//h1')
browser.find_by_tag('h1')
browser.find_by_name('name')
browser.find_by_id('firstheader')

Get element value

In order to retrieve an element’s value, use the value property:

browser.find_by_css_selector('h1').value

or

element = browser.find_by_css_selector('h1')
element.value

Interacting with forms

browser.fill_in('query', 'my name')
browser.attach_file('file', '/path/to/file/somefile.jpg')
browser.choose('some-radio')
browser.check('some-check')
browser.uncheck('some-check')

Verifying if element is visible or invisible

To check if an element is visible or invisible, use the visible property. For instance:

browser.find_by_css_selector('h1').visible

will be True if the element is visible, or False if it is invisible.

Executing javascript

You can easily execute JavaScript, in drivers which support it:

browser.execute_script("$('body').empty()")

You can return the result of the script:

browser.evaluate_script("4+4") == 8

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

splinter-0.0.1.tar.gz (5.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page