Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finding elements by index should begin with '1' #8

Closed
siaynoq opened this issue Jun 4, 2010 · 3 comments
Closed

finding elements by index should begin with '1' #8

siaynoq opened this issue Jun 4, 2010 · 3 comments

Comments

@siaynoq
Copy link

siaynoq commented Jun 4, 2010

In Watir, when you try to find an element by index, it should begin with 1, instead of 0 (this limitation comes from Internet Explorer DOM, where indexing begins with 1).
To maintain compatibility, this should be changed in watir-webdriver.

Please comment :)

@jarib
Copy link
Member

jarib commented Jun 4, 2010

This is a deliberate break in compatibility. We've worked around it in while transitioning by doing this:

class Integer
  if System.webdriver?
    def as_index() self - 1 end
  else
    def as_index() self end
  end
end

browser.div(:index, 1.as_index)

See http://wiki.github.com/jarib/watir-webdriver/comparison-with-watir-1x for more changes.

@siaynoq
Copy link
Author

siaynoq commented Jun 4, 2010

This might be a big limitation for users (like me) with couple of thousand line of existing Watir code. Btw, I did a local workaround in normalized_selector()
I wonder if we could introduce something during startup, like new(symb, index_offset = 0) to make it even more compatible with Watir?

@jarib
Copy link
Member

jarib commented Jun 4, 2010

Making it configurable (which is what Celerity does) sounds like a sane approach. Please open a new bug for that.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants