Angular.js for the testing goat: Utilities for testing Angular.js applications with Selenium for Python.
This project has been abandoned!
Unfortunately, due to lack of time and a switch to robotframework-extendedselenium2library this project has been abandoned. Please contact me if you want to take over.
pytractor is an extension to the Selenium bindings for Python. Its goal is to make testing of angular.js applications easier with Python.
It is assumed that you are familiar with with the Selenium bindings for Python.
Drivers containing the helper methods for testing Angular.js can be found in the
The constructor expects the base URL of your application.
from pytractor.webdriver import Firefox driver = Firefox('http://localhost:8080/base_url')
The base URL will be prepended to each URL you pass to the
get() method (using
The constructor also accepts the parameters:
- A selector for the DOM element that is the root of your Angular.js app (default:
- The amount of seconds (default: 10) to wait for a script executing asynchroneously (see selenium's
- The amount of seconds (default: 10) to wait for the script which verifies whether Angular.js is indeed used on the page.
If no Angular.js app can be found,
get() will raise an exception.
The usual selenium webdriver methods can be used, but pytractor will wait for Angular.js to finish processing for some of them.
Finding elements by binding
find_element(s)_by_binding() methods retrieve the element(s) which use the specified binding.
Suppose your Angular app contains a binding of the form
Then you can locate the
<div /> with
find_element(s)_by_binding() will also find elements if only part of the binding
name is specified.
In other words, the binding
can be found with
If you want to locate the binding by its exact name, use
Finding elements by model
find_element(s)_by_model('model_name') can be used to locate elements that
use the expression
Suppose you have the element
<input type="text" ng-model="person.name">
<input> element can be found with
Finding elements by repeater
find_element(s)_by_repeater('item in list') can be used to locate elements that
use the expression
ng-repeat="item in list".
Other Methods and Properties
Refreshing a page
refresh() will perform a full reload of the current page. It assumes that
the page uses Angular.js.
Using in-page navigation
set_location(url) will use the in-page navigation (just as
Retrieving the absolute URL
location_abs_url property will retrieve the absolute URL from angular.
- Button text, and options locators.
- Script/mock module injection.
pytractor is licensed under the the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
protractor is Copyright (c) 2010-2014 Google, Inc. and licensed under the MIT license. See the respective directory for a copy of the license.
Credits for the client-side scripts go to the protractor project for their fine framework.