Question

I'm trying to decide whether to use intern or protractor for my e2e test with SauceLabs, and I find really helpful these "by"s that protractor provides (by.model, by.binding, by.repeater) and I was wondering if such locator strategies are also possible to use in intern.

Était-ce utile?

La solution

Protractor uses the WebDriverJS library, not the WD.js library, so it is not likely to be directly compatible, but the idea behind how Protractor works would be possible just as well in Intern by writing the same kinds of helper functions that Protractor provides:

define([ 'intern!tdd', 'tests/support/locators' ], function (tdd, locators) {
  tdd.suite('suite', function () {
    tdd.test('test', function () {
      var remote = this.remote;
      remote.get('http://example.com')
        .then(locators.by.model('foo'))
        .then(function (model) {})
        // ...etc
        ;
    });
  });

Where, in the above, locators.by.model is a method like:

function model(modelId) {
  return this.execute(function () {
    return document.querySelectorAll(['ng-model=' + modelId + ']');
  });
}

EDIT: You can also use Protractor’s clientsidescripts module directly:

define([ 'intern!tdd', 'intern/dojo/node!protractor/lib/clientsidescripts' ], function (tdd, scripts) {
  tdd.suite('suite', function () {
    tdd.test('test', function () {
      var remote = this.remote;
      remote.get('http://example.com')
        .execute(scripts.findByModel, [ 'foo' ])
        .then(function (model) {})
        // ...etc
        ;
    });
  });
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top