Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion development/generate_api/example_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ def example_622cccefcda0bf4d35e338d1bf0c045f64815fc8b81a4792506a912e3e1abf3c(pag
def example_eff0600f575bf375d7372280ca8e6dfc51d927ced49fbcb75408c894b9e0564e(page:)
page.content = <<~HTML
<div id="my_status" class="status">Pending</div>
<button onClick="setTimeout(() => { document.getElementById('my_status').innerText='Something Submitted!!' }, 2000)">Click me</button>
<button onClick="setTimeout(() => { document.getElementById('my_status').innerText='Submitted' }, 2000)">Click me</button>
HTML

page.get_by_role("button").click
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/api/locator_assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Since the matcher comes with auto-waiting feature, we don't have to describe tri
```ruby
page.content = <<~HTML
<div id="my_status" class="status">Pending</div>
<button onClick="setTimeout(() => { document.getElementById('my_status').innerText='Something Submitted!!' }, 2000)">Click me</button>
<button onClick="setTimeout(() => { document.getElementById('my_status').innerText='Submitted' }, 2000)">Click me</button>
HTML

page.get_by_role("button").click
Expand Down
2 changes: 0 additions & 2 deletions lib/playwright/locator_assertions_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
if expected.respond_to?(:each)
expected_text = to_expected_text_values(
expected,
match_substring: true,
normalize_white_space: true,
ignore_case: ignoreCase,
)
Expand All @@ -441,7 +440,6 @@ def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
else
expected_text = to_expected_text_values(
[expected],
match_substring: true,
normalize_white_space: true,
ignore_case: ignoreCase,
)
Expand Down
17 changes: 17 additions & 0 deletions spec/integration/assertions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,23 @@ def setup_page(page, aria_invalid_value)
end
end

it "should not match a substring" do
with_page do |page|
page.goto(server_empty_page)
page.set_content("<div>Text content</div>")
expect(page.locator("div")).to not_have_text("Text")
expect {
expect(page.locator("div")).to have_text("Text", timeout: 300)
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)

page.set_content("<ul><li>Text 1</li><li>Text 2</li><li>Text 3</li></ul>")
expect(page.locator("li")).to contain_text(["Text 1", "Text 2", "Text"])
expect {
expect(page.locator("li")).to have_text(["Text 1", "Text 2", "Text"], timeout: 300)
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end
end

it "should ignore case" do
with_page do |page|
page.goto(server_empty_page)
Expand Down