Challenge - 5 Problems
CSS Selector Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
Identify the element selected by this CSS selector
Given the HTML snippet below, which element will be selected by the CSS selector
div.content > ul#list > li.item.active?Selenium Java
<div class="content"> <ul id="list"> <li class="item">Item 1</li> <li class="item active">Item 2</li> <li class="item">Item 3</li> </ul> <ul id="other-list"> <li class="item active">Item A</li> </ul> </div>
Attempts:
2 left
💡 Hint
Look for the direct child combinator (>) and the id selector (#list).
✗ Incorrect
The selector targets elements with classes 'item' and 'active' that are direct children of the
- with id 'list', which itself is a direct child of a
with class 'content'. Only 'Item 2' matches all these conditions.
❓ selector
intermediate1:30remaining
Which CSS selector matches all buttons except those with class 'disabled'?
Choose the CSS selector that selects all
Attempts:
2 left
💡 Hint
The :not() pseudo-class excludes elements matching the selector inside it.
✗ Incorrect
The selector 'button:not(.disabled)' selects all
❓ selector
advanced2:30remaining
What is the output of this CSS selector in Selenium?
In Selenium Java, what element will be found by the CSS selector
input[type='checkbox']:checked + label?Selenium Java
<input type="checkbox" id="check1" checked> <label for="check1">Option 1</label> <input type="checkbox" id="check2"> <label for="check2">Option 2</label>
Attempts:
2 left
💡 Hint
The + combinator selects the next sibling element.
✗ Incorrect
The selector finds elements of type checkbox that are checked, then selects the
❓ selector
advanced3:00remaining
Which CSS selector correctly selects all elements inside a
Choose the CSS selector that selects all elements inside a
Attempts:
2 left
💡 Hint
The :is() pseudo-class can be used to exclude specific nested selectors.
✗ Incorrect
Option C uses :is() inside :not() to exclude elements that are descendants of
❓ selector
expert2:30remaining
What error occurs when using this CSS selector in Selenium Java?
Consider the CSS selector
div > p:first-child + span::before used in Selenium Java's By.cssSelector(). What happens when Selenium tries to find elements with this selector?Attempts:
2 left
💡 Hint
Selenium does not support selecting pseudo-elements like ::before.
✗ Incorrect
Selenium's CSS selector engine does not support pseudo-elements such as ::before or ::after. Using them causes an InvalidSelectorException.