Reputation: 100000
I see this in my HTML after it is generated, in the browser:
<!-- ngRepeat: (promptId, q) in questions -->
I want to get the first element, so I use:
it('add new comment thread', function () {
element.all(by.repeater('(promptId, q) in questions')).first().click();
});
But I get an error:
Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("(promptId, q) in questions")
There is clearly at least one child element here, so am I using by.repeater incorrectly?
Upvotes: 1
Views: 555
Reputation: 473833
It is, generally speaking, difficult to answer questions like this without seeing what is actually happening in your particular test for your particular application.
First of all, note that this comment would be there even if no repeater elements are present.
This can be a "timing problem", waiting for presence of an element helps:
var prompt = element.all(by.repeater('(promptId, q) in questions')).first();
var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(prompt), 5000);
prompt.click();
// TODO: your expectation here
And, of course, make sure you are on the expected page when you try to click the element and the repeater is actually contains/fed with data.
Upvotes: 1