Writing a Browser-Driven System Test Case
Explore how to write browser-driven system tests for a Rails widget rating feature using Capybara. Learn techniques to detect dynamic DOM changes, handle JavaScript execution, and use diagnostic tools like with_clues to debug tests.
We'll cover the following...
We'll cover the following...
We’ll write a test case of the widget rating feature, which will look very much like the one we wrote before. To test the widget rating feature, we need to:
- Navigate to a widget page.
- Click a rating button.
- Check that the DOM reflects our rating.
We’ll create this test in test/system/rate_widget_test.rb, and it will look for an element matching [data-rating-present] that has the text content, including the rating the test will choose. Even though this content is not initially visible and some of it (the rating itself) isn’t even in the DOM, Capybara will wait a small amount of time for the ...