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.

有帮助吗?

解决方案

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
        ;
    });
  });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top