This repository has been archived by the owner. It is now read-only.
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
101 lines (73 sloc) 2.76 KB

AngularJS extensions to Arquillian Graphene


  • synchronization of AngularJS calls
  • @FindByNg annotation support


This extension implements a WebDriver event listener that after each navigation, click or typing event makes sure that there are no other oustanding Angular requests in progress.

This ensures that application-specific computations are finished before the control is passed over to your test.

In order to use this extension, you don't need to do anything - it is registered and used automatically.

Selectors - @FindByNg

Often you won't find any other meaningful selectors in AngularJS generated DOM than ng- attributes.

Angular annotations can offer you a stable way to describe

  • form inputs that binds to model values (@FindByNg(model = "..."))
  • repeated DOM blocks (@FindByNg(repeat = "..."))
  • buttons, links or forms that are a source of actions (@FindByNg(action = "..."))


public class AngularTest {

    public static WebArchive createTestArchive() {
        return ...;

    WebDriver browser;

    URL contextRoot;

    @FindByNg(model = "todo.done")
    List<WebElement> todos;

    @FindByNg(model = "todoText")
    WebElement todoEntry;

    @FindByNg(action = "archive()")
    WebElement archive;

    @FindByNg(action = "addTodo()")
    WebElement addTodo;

    @FindByNg(repeat = "todo in todos")
    List<WebElement> todoRepeat;

    public void loadPage() {
        browser.navigate().to(contextRoot + "index.html");

    public void testNumberOfTodos() {
        assertEquals(2, todos.size());

    public void testArchive() {
        assertEquals(2, todos.size());;
        assertEquals(1, todos.size());

    public void testAddTodo() {
        assertEquals(2, todos.size());
        todoEntry.sendKeys("This is a new TODO item");
        assertEquals(3, todos.size());

    public void testRepeater() {
        assertEquals(2, todoRepeat.size());
        WebElement secondRow = todoRepeat.get(1);
        WebElement checkbox = secondRow.findElement(By.tagName("input"));
        WebElement todoItem = secondRow.findElement(By.tagName("span"));
        assertEquals("second todo", todoItem.getText());;;

        assertEquals(0, todoRepeat.size());