SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.23k stars 8.11k forks source link

[🐛 Bug]: Text is considered as invisible when using native dialog inside a web component #14524

Open jkimmeyer opened 2 hours ago

jkimmeyer commented 2 hours ago

What happened?

When using Google Material Web Components, specifically the dialog component, all text within the dialog content slot is invisible to Selenium. The get_element_text method returns an empty string instead of the actual text content. However, filling the input or finding the label element (without text) works without any problems.

I am uncertain whether this issue originates from Chromedriver or Selenium, as there appears to be some visibility logic within the Selenium repository. Could you please advise if I should file this issue under Chromedriver instead?

Reproduction Steps:

When running the dialog spec, tests are failing. The labels are visible but cannot be found using the have_content matchers.

How can we reproduce the issue?

Code: https://github.com/jkimmeyer/selenium-example

Markup:

<md-dialog open>
  <div slot="content">
    <label for="field">
      Field
    </label>

    <input id="field" type="text" />
  </div>
</md-dialog>

Test:

require "rails_helper"

RSpec.describe "Dialog" do
  it "fills a field", js: true do
    visit "/"
    fill_in "Field", with: "Hello"
    expect(page).to have_content("Field")
    expect(page).to have_content("Hello")
  end
end

Relevant log output

Failures:

  1) Dialog fills a field
     Failure/Error: expect(page).to have_content("Hello")
       expected to find text "Hello" in "Field"

     [Screenshot Image]: /Users/johannes.kimmeyer/Coding/work/pfreundt/selenium-example/tmp/capybara/failures_r_spec_example_groups_dialog_fills_a_field_307.png

     # ./spec/system/dialog_spec.rb:8:in `block (2 levels) in <top (required)>'

Finished in 3.93 seconds (files took 0.70339 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/system/dialog_spec.rb:4 # Dialog fills a field

Operating System

macOS Sequoia 15.0

Selenium version

Ruby 3.3.5

What are the browser(s) and version(s) where you see this issue?

Chrome 129

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 129

Are you using Selenium Grid?

No

github-actions[bot] commented 2 hours ago

@jkimmeyer, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!