-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
I encountered an issue with the auto-correction provided by Capybara/RedundantWithinFind. The automatic correction replaces within find_by_id with a within string selector, leading to unexpected behavior and causing the test to fail.
Before Auto-correction:
within find_by_id("array-form-session.dates") do
expect(page).to have_text(:visible, "YYYY/MM/DD")
end→ Match: <div id="array-form-session.dates">YYYY/MM/DD</div>
→ Not Match: : <div id="array-form-session" class="dates">YYYY/MM/DD</div>
This is the expected behavior.
After Auto-correction:
within "#array-form-session.dates" do
expect(page).to have_text(:visible, "YYYY/MM/DD")
end→ Not Match: <div id="array-form-session.dates">YYYY/MM/DD</div>
→ Match: : <div id="array-form-session" class="dates">YYYY/MM/DD</div>
Solution?
While it's rare for . to be used in HTML IDs, I believe a potential solution could be to avoid replacing find_by_id with within when the argument of find_by_id contains a . or to mark it as unsafe.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working