8000 Element location with label: doesn't work if control is nested · Issue #979 · watir/watir · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Element location with label: doesn't work if control is nested #979

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

Open
mpalmer opened this issue Nov 12, 2024 · 0 comments
Open

Element location with label: doesn't work if control is nested #979

mpalmer opened this issue Nov 12, 2024 · 0 comments

Comments

@mpalmer
Copy link
mpalmer commented Nov 12, 2024

Meta -

Watir Version: 7.3.0
Selenium Version: 4.26.0
Browser Version: Firefox 128.3.1esr (64-bit)
Browser Driver Version: Whatever selenium-webdriver installed (how would I discover that?)
OS Version: Debian Bookworm(ish)

Expected Behavior -

I've got a page whose form inputs are structured like this:

<label>
  <span>
    <input type="text">
  </span>
  <span><!-- yes it puts an empty span in here... --></span>
  <span>
    The Text
  </span>
</label>

I'd like for browser.text_field(label: "The Text") to find the associated input.

Actual Behavior -

It... doesn't do that.

Steps to reproduce -

See above.

Commentary

As far as I can tell, this is allowed by the HTML5 spec, as unwise as that may be, but basically no example of using inputs nested in labels has extra elements in the way, so it's not unreasonable that it isn't currently supported in Watir. It looks like the matching of inputs inside labels was implemented in #200, but if I'm understanding the XPath correctly, it's only looking for the label as a direct parent, and probably that needs to be changed to use ancestor::label (if that's a thing? I dunno, XPath scares me).

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

1 participant
0