Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created July 7, 2013 23:39
Show Gist options
  • Save vojtajina/5945394 to your computer and use it in GitHub Desktop.
Save vojtajina/5945394 to your computer and use it in GitHub Desktop.
Protractor proposal... I can run it with: $ protractor my.conf.js
// This is my TEST...
describe('angularjs homepage', function() {
beforeEach(function() {
navigateTo('http://angularjs.org/');
});
it('should greet', function() {
// any css selector
element('input[ng-model=yourName]').sendKeys('Julie');
// or APIs, whatever we want
element.binding('yourName').click();
// in the same way I can extend Jasmine's matchers (in beforeEach),
// I can extend - define my own element DSL
element('.something').myCustomClick();
expect(element.binding('Hello {{yourName}}!').text()).toBe('Hello Julie!');
});
});
// PSEUDO CODE of protractor
// init/config webdriver instance, protractor
var config = loadConfigFromFileAndMergeWithCLIargs();
var webdriverInstance = new WebDriverInstance(config);
var protractor = new ProtractorInstance(config, webdriverInstance);
// expose this single global instance of protractor
global.protractor = protractor;
// exposing the APIs (optional, I can disable this)
global.element = protractor.element;
global.navigateTo = protractor.navigateTo;
// patch/expose Jasmine APIs to work with promises
global.expect = patchExpect(protractor, webdriverInstance, global.expect);
// require all the test files and kick off Jasmine run, probably through jasmine-node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment