Add Capybara.touched_session_names method to retrieve used session names #2784
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This method returns the names of all currently active sessions that have been used with
using_session
. Its primary purpose is to callsave_screenshot
for multiple sessions when a test fails.Previously, it was difficult to retrieve session names during tests. With this addition, developers can now easily obtain all session names and save screenshots for each active session, enhancing debugging capabilities in multi-session test scenarios.
Additional Information
For example, in Rails, the
take_failed_screenshot
method captures a screenshot when a test fails. https://github.com/rails/rails/blob/e6429269fd5a8a7d728557f4e7d7f82c0ad1478c/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L53-L58Currently, this method only captures screenshots from the default session. However, when using multiple sessions with
using_session
, I would like to save screenshots for each active session. In Capybara’s current implementation, tracking the session names created withusing_session
is difficult, and the only workaround has been to override the method to achieve this functionality.