Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Repeater locators use a 1-based index? #90

Closed
kirbarn opened this issue Sep 13, 2013 · 3 comments
Closed

Repeater locators use a 1-based index? #90

kirbarn opened this issue Sep 13, 2013 · 3 comments
Milestone

Comments

@kirbarn
Copy link

kirbarn commented Sep 13, 2013

I've started using Protractor not long ago and still studying it. I've found out that the repeater locators seem to use a 1-based index. E.g. ptor.findElement(By.repeater('row in renderedRows').row(1)) finds the first row, not the second as I would expect. It was quite surprising to me, since an old and pretty common convention is to use 0-based indices for arrays or lists of data.

So I was wondering, if there was any particular reason behind this. Wouldn't it be better to have a 0-based index which is more intuitive to the majority of programmers?

@juliemr
Copy link
Member

juliemr commented Sep 13, 2013

Confession - don't remember why I decided to 1-based index. I'll consider making a breaking change before 1.0 to this.

@kirbarn
Copy link
Author

kirbarn commented Sep 15, 2013

Julie,

Cool, thanks.

@juliemr juliemr closed this as completed in 421d623 Oct 9, 2013
@scottrice10
Copy link

Something I'm noticing that may or may not be related to this issue:

Xpath in Chrome is 1-based. When I right click an html element in the Chrome console and select "Copy XPath," it is 1-based. However, it seems that my application and/or Protractor's Xpath functionality is 0-based. Right now, when using the By.xpath locator, Protractor seems to be one off (behind) when locating web elements by xpath.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants