Dart API Referencewebdriver

webdriver library

Functions

void writeBytesToFile(String fileName, List<int> contents) #

void writeBytesToFile(String fileName, List<int> contents) {
  var file = new File(fileName);
  var ostream = file.openOutputStream(FileMode.WRITE);
  ostream.write(contents);
  ostream.close();
}

void writeStringToFile(String fileName, String contents) #

WebDriver bindings for Dart.

These bindings are based on the WebDriver JSON wire protocol spec (http://code.google.com/p/selenium/wiki/JsonWireProtocol). Not all of these commands are implemented yet by WebDriver itself. Nontheless this is a complete implementation of the spec as the unsupported commands may be supported in the future. Currently, there are known issues with local and session storage, script execution, and log access.

To use these bindings, the Selenium standalone server must be running. You can download it at http://code.google.com/p/selenium/downloads/list.

There are a number of commands that use ids to access page elements. These ids are not the HTML ids; they are opaque ids internal to WebDriver. To get the id for an element you would first need to do a search, get the results, and extract the WebDriver id from the returned Map using the 'ELEMENT' key. For example:

String id;
WebDriverSession session;
Future f = web_driver.newSession('chrome');
f.chain((_session) {
  session = _session;
  return session.setUrl('http://my.web.site.com');

}).chain((_) {

 return session.findElement('id', 'username');

}).chain((element) {

 id = element['ELEMENT'];
 return session.sendKeyStrokesToElement(id,
     [ 'j', 'o', 'e', ' ', 'u', 's', 'e', 'r' ]);

}).chain((_) {

 return session.submit(id);

}).chain((_) {

 return session.close();

}).then((_) {

 session = null;

});

void writeStringToFile(String fileName, String contents) {
  var file = new File(fileName);
  var ostream = file.openOutputStream(FileMode.WRITE);
  ostream.writeString(contents);
  ostream.close();
}

Classes