Assert an attribute value
Medium70 pts
- toHaveAttribute
- DOM Inspection
- Attributes
Practice app · Profile Settings
A settings page for clicking, typing, reading text/attributes/CSS and element state.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Verify HTML attributes such as alt text and custom data roles using attribute assertions.
Your Task
- 1Navigate to the profile settings page at TEST_URL.
- 2Locate the user avatar image (#avatar).
- 3Assert that the avatar image has an 'alt' attribute with the value 'Profile avatar'.
- 4Assert that the avatar image has a 'data-role' attribute with the value 'avatar'.
Validation Checks
- Profile settings page is loaded at TEST_URL
- Avatar image (#avatar) is located
- Attribute 'alt' verified as 'Profile avatar'
- Attribute 'data-role' verified as 'avatar'
- At least 2 assertions pass
Playwright · Playwright Practice Track · Assertions