Each method in the chain can receive arguments to specify selectors on attributes of each element.
To select an <input> element with a name attribute whose value is email, pass name: 'email' to the input method:
Since class is an attribute just like name you can specify the exact class string to match elements as document.table(class: 'table users'):
However, this test is very fragile - any change to the class attribute will cause the test to break, even if the order of the classes changes.
Instead, you can match using CSS selectors by passing a string directly to each element method:
| Name | |
|---|---|
| user@example.org | Example User #1 |
| user@example.com | Example User #2 |
Any valid CSS selector is permitted:
| Name | |
|---|---|
| user@example.org | Example User #1 |
| user@example.com | Example User #2 |
| Name | |
|---|---|
| user@example.org | Example User #1 |
| user@example.com | Example User #2 |