cobrateam / splinter Goto Github PK
View Code? Open in Web Editor NEWsplinter - python test framework for web applications
Home Page: http://splinter.readthedocs.org/en/stable/index.html
License: BSD 3-Clause "New" or "Revised" License
splinter - python test framework for web applications
Home Page: http://splinter.readthedocs.org/en/stable/index.html
License: BSD 3-Clause "New" or "Revised" License
Support back and advance on history. It is important to note that some websites may block history.back() (from javascript), so I think we can't just do:
browser.execute_script('history.back();')
create a warning for deprecated method
this feature is out of splinter's scope, hence should be implemented as an external package
Create a django plugin to return django template exceptions.
Now find use one method for find by css_selector, xpath, tag, name or id:
browser.find(css_selector='h1')
browser.find(xpath='//h1')
browser.find(tag='h1')
browser.find(name='name')
browser.find(id='firstheader')
Other pattern is use one method for each selector type. Ex:
browser.find_by_css('.my-class')
In documentation explain with a little more details what Splinter is and why you should consider use this tool.
Nowadays splinter tests occur visiting always the same web page.
This approach shades a problem with chrome:
let's say we are logging into a Django website:
browser = Browser('webdriver.chrome')
browser.visit("http://localhost:8000/admin/")
browser.find_by_id("login-form") # returns the login form
browser.fill("username", "johndoe")
browser.fill("password", "123456")
browser.find_by_id("login").first.click()
browser.visit("http://localhost:8000/some-other-page/")
browser.find_by_id("login-form") # should not see the login form, since I already logged in
What happens is that every single time I use browser.visit(), chrome opens a new tab, and all the next calls browser.find_by_something effects the first tab, not the new one.
In order to workaround this behaviour I had to hack splinter to use a javascript call to "location.href".
Below I put an example from my django project (using lettuce):
# -*- coding: utf-8 -*-
import urlparse
import warnings
from lettuce import before, after, world
from splinter.browser import Browser
warnings.simplefilter('ignore')
@before.harvest
def setup_browser(variables):
world.browser = Browser('webdriver.chrome')
world._old_visit = world.browser.visit
_base = 'http://localhost:8000/'
_redirect = 'window.location.href="%s/";'
def navigate(path):
current_path = world.browser.url.replace(_base, '/', 1)
if path == current_path:
script = 'window.location.href=window.location.href;'
else:
script = _redirect % path.rstrip('/')
return world.browser.execute_script(script)
world.browser.visit = navigate
world._old_visit(_base)
world.current_path = lambda: urlparse.urlsplit(world.browser.url).path
@after.harvest
def teardown_browser(results):
world.browser.quit()
Is need a method for execute script ex:
execute_script("$('body').empty()")
The type
method is used to slowly type the values to the text field.
Useful to test fields autocompletion.
It would be nice to be able to customize some settings on Firefox profile. Something like this code for Capybara:
class Capybara::Driver::Selenium
def self.driver
unless @driver
profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.manage-offline-status'] = false
@driver = Selenium::WebDriver.for :firefox, :profile => profile
at_exit do
@driver.quit
end
end
@driver
end
end
Selenium WebDriver for Python provides a FirefoxProfile
class, so it's possible to create a new WebDriver instance with some customizations by hacking FirefoxProfile
class. Here is an example, extracted from Rodrigo Manhẽs blog:
from selenium.firefox.firefox_profile import FirefoxProfile
prefs = FirefoxProfile._get_webdriver_prefs()
prefs['network.manage-offline-status'] = 'false'
@staticmethod
def prefs_func():
return prefs
FirefoxProfile._get_webdriver_prefs = prefs_func
This hack looks ugly, because FirefoxProfile
API has a bad design, it is just impossible to create a new FirefoxProfile
instance and change some options, as in Capybara :(
create a new driver for windmill.
more informations about windmill in http://www.getwindmill.com/
lxml can be declared as a dependence in setup.py, so it would be installed together with splinter when installing with pip.
add this method to driver
like this:
It needs a method for reload a page. Like:
browser.reload()
It needs a driver for selenium 2 remote.
With selenium remote is possible use htmlunit driver.
More informations in http://code.google.com/p/selenium/
Hi,
I can't install splinter because when I run 'pip install splinter' I get the following error:
Downloading/unpacking splinter
Running setup.py egg_info for package splinter
Traceback (most recent call last):
File "", line 14, in
File "/home/cillian/.virtualenvs/batucada/build/splinter/setup.py", line 4, in
README = open('README.rst').read()
IOError: [Errno 2] No such file or directory: 'README.rst'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):File "", line 14, in
File "/home/cillian/.virtualenvs/batucada/build/splinter/setup.py", line 4, in
README = open('README.rst').read()
IOError: [Errno 2] No such file or directory: 'README.rst'
Command python setup.py egg_info failed with error code 1
I think it's because the package at http://pypi.python.org/pypi/splinter/0.0.2 does not contain the README.rst file. Looks like a good package by the way.
I heard people coming back to webrat just because capybara does not have a good way to change headers.
we should allow people do do something like:
browser.headers['Content-Type'] = 'application/pdf'
is need create a website for splinter
Enable support to google chrome browser
splinter have finders by name, id, css_select, tag and xpath. But check, fill_in, choose get elements by name:
browser.choose("some-radio")
It's need change this, moving these methods from browser class to element class:
checkbox = find_by_name('my-checkbox')
checkbox.check()
create a new driver for mechanize.
more informations about mechanize in http://wwwsearch.sourceforge.net/mechanize/
Create method for manipulate input files like:
attach_file('Image', '/path/to/image.jpg')
Enable support to any browser, like googlechrome, opera
create a new driver for zombie.js
more informations about zombie.js in http://zombie.labnotes.org/
splinter should support iframes
Some script can return the result of the script. Ex:
evaluate_script('2+2') #returns 4
To click a link (http://splinter.cobrateam.info/#clicking-links), the docs says that we have in Browser class, the methods: click_link_by_href and click_link_by_text, but it doesn't exists.
To click a link, I have to use browser.find_link_by_text('My Text').first.click()
Is this a problem with the docs, with the source code or with me? :-)
Implement a way to execute actions on specific content areas.
Say you have many forms in a page, with similar fields, and want to select a field from a specific form, you could to something like:
in('#form-1').check('foo')
Add support to Internet Explorer using the webdriver Splinter driver.
Provide methods for mouse events: mouse over, mouse out, and others.
Splinter should be able to suport JavaScript alert.
Chrome tests are very unstable, we need to inspect it to understand what to do.
Method to return a list with all specifieds tags. Ex:
browser.find_all_tags('p')
['Foo', 'Bar', 'Test']
Flask fake web app need down in the end of tests running
method for manage select fields
create a new driver for django test client
more information in http://docs.djangoproject.com/en/1.2/topics/testing/#module-django.test.client
Well, as I've saw, those methods just look for an objet using it's name. But, what if we, in example, there're 2 radio options to choose and both have the same name?
The point it's not the reason, but how to deal with that case. I think Splinter must have another options to search controls, like by id, class or even xpath too.
is need create some documentation for the splinter
for this let's use sphinx http://sphinx.pocoo.org/
find in chain for find a element in other element. Ex:
browser.find_by_id('my-id-1').find_by_tag('a')
We need to change our markdown text to rst, because it will be easier to maintain the docs and the pypi page.
It's need implements a method for waiting for elements to appear or to disappear on the page.
New driver for phantomjs: http://dev.umaclan.com/projects/pyphantomjs/
Provide a drag and drop method.
splinter should support multi tabs
It's need create all method, for find more than one element in a page.
all will be provide find by css_selector, xpath, id, tag and name.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.