2

When I execute the statements without using promises, it just returns a promise.

Like the following does not work:

devices = element.all(devicesRepeater)
expect(devices.length).toEqual factories.devices.length

But promise style works:

element.all(devicesRepeater).then (devices)->
  expect(devices.length).toEqual factories.devices.length

But its shown in the protractor API that it should resolve e.g.: http://angular.github.io/protractor/#/api?view=ProtractorBy.prototype.

// Returns a promise that resolves to an array var rows = element.all(by.repeater('cat in pets'))

Same is true for waiting and all. Like in the following question, waiting blocks and then the expect call works:

How can I wait for a condition?

Whereas in my project, I have to put all the logic inside the promise callback block.

Should I write a then block for each of them or is there a way to block until promise resolves.

Community
  • 1
  • 1
bugdayci
  • 948
  • 7
  • 15
  • Hope this gets some attention, I'm having issues with promises not resolving as well, even if I have use `expect()` with them. – Aaron Dec 23 '14 at 15:02
  • length is not a property of ElementArrayFinder. Use count() instead: `devices = element.all(devicesRepeater) expect(devices.count()).toEqual factories.devices.length` – Bill Poitras Apr 04 '17 at 15:14

1 Answers1

0

length is not a property of ElementArrayFinder. Use count() instead:

devices = element.all(devicesRepeater) expect(devices.count()).toEqual factories.devices.length

Bill Poitras
  • 667
  • 4
  • 15
  • Yes I have been using count since then. But thanks for adding it here so that others can find the answer – bugdayci Jul 25 '17 at 09:26