Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 1.84 KB

File metadata and controls

48 lines (32 loc) · 1.84 KB

A small library of WebDriver locators for AngularJS, as well as a utility to interoperate with $scope variables directly.

It is only in Java for now, but I'm sure ports will make it available for .Net, Python, Ruby etc.

Status

Protractor (from where some of the JavaScript has been copied) is stable, but this Java library isn't quite released as yet despite 99% test coverage, hence the sub-1.0 version number. APIs could change!

Code Examples

All our usage examples are in a single test class:

In there are examples of:

  1. how to wait for Angular to stop being busy.
  2. how to find 'rows', 'columns' or 'cells' via Angular's ng-repeat directive.
  3. how to find elements via Angular's ng-bind directive, also used like so: {{bindingVar}}.
  4. how to find read $scope variables
  5. how to find write $scope variables

Pitfalls

If you're trying to retrieve a date object, there's a selenium bug stopping that for now. Instead bring it back as JSON and post-process it:

DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser()
                            .withChronology(ISOChronology.getInstanceUTC());
DateTime actualWhen = parser.parseDateTime(ngModel.retrieveJson(anElem, "myDateField").replace("\"", ""));

Including it in your project

Maven

<dependency>
  <groupId>com.paulhammant</groupId>
  <artifactId>ngwebdriver</artifactId>
  <version>0.9.1</version>
  <scope>test</scope>
</dependency>

<!-- you still need to have a dependency for preferred version of Selenium/WebDriver 2.35 or above -->

Non-Maven

Download from here