Skip to content

[πŸ› Bug]: Text is considered as invisible when using native dialog inside a web componentΒ #14524

@jkimmeyer

Description

@jkimmeyer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions