Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lawrencec/horace
A page object pattern based tool to automate browsers
https://github.com/lawrencec/horace
Last synced: 12 days ago
JSON representation
A page object pattern based tool to automate browsers
- Host: GitHub
- URL: https://github.com/lawrencec/horace
- Owner: lawrencec
- License: mit
- Created: 2013-04-14T16:25:11.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-31T14:38:46.000Z (over 11 years ago)
- Last Synced: 2024-11-13T01:37:45.568Z (2 months ago)
- Language: Python
- Size: 148 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Horace [![Build Status](https://travis-ci.org/lawrencec/horace.png?branch=master)](https://travis-ci.org/lawrencec/horace)
A page object based interface around webdriver to help with automating of browser
navigation, screen scraping and testing. Inspired by [Geb](http://gebish.org).
A simple example usage can be seen below:# Go to www.duckduckgo.com
ddgPage = DuckDuckGoPage(driver)# Enter a query into the search box
ddgPage.searchModule.searchInput.value('my search query')## Pages and Modules
Page content is specified using lists. The keys in that list can then be directly
used as attributes for the page objects.class DuckDuckGoPage(Page):
url = 'http://duckduckgo.com/'
title = 'DuckDuckGo'content = {
'searchModule' : {
'base': searchModule, #module
'required': False
}
}class SearchModule(Module):
base = '#search_wrapper_homepage'
required = Truecontent = {
'searchInput': {'selector': '#search_form_input_homepage'}
}Usage of the above Page and Module:
# Go to www.duckduckgo.com
ddgPage = DuckDuckGoPage(driver)# Enter a query into the search box
ddgPage.searchModule.searchInput.value('my search query')Optionally, you can explicitly define a property using the @property decorator
in order to help with code completion tools in python consoles and IDE's:@property
def searchModule(self):
return self._getContent('searchModule')## Examples
See the DuckDuckGo and Angular examples in the test directory. You'll probably need to install Horace first via python
setup.py or pip.The DDG example performs a search query on the DDG home page and then shows how many search results were found.
The Angular example loads up the ToDoMVC angular page and adds two todo items to the todo list.
Both examples only tested and phantomjs and Firefox so far (Mac).
## Tests
The tests require an install of firefox or phantomjs. The test/config.py file
by default states phantomjs as the default browser to use. Change it to firefox
if you don't have phantomjs installed.If you have phantomjs installed, first run it in webdriver mode:
phantomjs --webdriver=8910 --local-storage-path=./
The localstorage path is only required if you want to run the angular todomvc app example.Tests can be run using nose like so:
cd tests
export BROWSER=phantomjs && PLATFORM=MAC && nosetestswith coverage if you have [coverage.py](http://nedbatchelder.com/code/coverage/) installed
nosetests --with-coverage --cover-package=horace
or if you want a html coverage report:
nosetests --with-coverage --cover-html --cover-html-dir=./coverage --cover-erase --cover-package=horace
### Selenium Grid
Start the Selenium Grid
java -jar selenium-server-standalone-2.33.0.jar -role hub
Start the selenium nodes e.g. Mac browsers
java -jar selenium-server-standalone-2.33.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 4445 -browser browserName=firefox,maxInstances=5,platform=MAC -browser browserName=chrome,maxInstances=5,platform=MAC
## Why Horace?
As this project is inspired by [Geb](http://gebish.org) and as Geb is apparently
named after an Egytpian god, I thought it would be nice if I named this project in
a similar vein. A god-based name is out of the question so I thought
I'd name it after my favourite god-based quote. The quote,
['Deus ex machina'](http://en.wikipedia.org/wiki/Deus_ex_machina) comes from the
Roman poet [Horace's](http://en.wikipedia.org/wiki/Horace) book about writing poetry
where he instructs poets to not invoke an outside plot device or
'god from the machine' to solve insoluble plot problems. As this project
is about control and automation, I thought it was an apt name (despite the
tenuous link).The fact that one of my favourite games happens to be called 'Deus Ex' (the original!)
is purely coincidental.