CSS Attribute Selectors
CSS attribute selectors let you match elements based on their attributes:
[attr='value']— exact match[attr^='value']— starts with[attr$='value']— ends with[attr*='value']— contains
On the Text Fields page:
<input type="text" id="lastNameWithPlaceholder"
name="lastName" placeholder="Enter your last name...">
Task:
- Navigate to
https://testkru.com/Elements/TextFields - Find an input whose name starts with
lastusing[name^='last'] - Print its placeholder using
getAttribute('placeholder') - Find an input whose placeholder contains
last nameusing[placeholder*='last name'] - Print its ID using
getAttribute('id')
Expected output:
Placeholder: Enter your last name... ID: lastNameWithPlaceholder
TestKru