Recall & Review
beginner
What is XPath in Selenium?
XPath is a language used to locate elements on a web page by navigating the HTML structure, allowing selection based on element hierarchy, attributes, and text.
Click to reveal answer
beginner
What is CSS Selector in Selenium?
CSS Selector is a pattern used to select HTML elements based on their id, class, attributes, or position, using the same syntax as CSS styles.
Click to reveal answer
intermediate
When should you prefer CSS selectors over XPath?
Use CSS selectors when you need faster element location and simple attribute or class-based selection, especially when the structure is straightforward.
Click to reveal answer
intermediate
What is a key advantage of XPath over CSS selectors?
XPath can navigate both up and down the HTML tree and select elements based on text content, which CSS selectors cannot do.
Click to reveal answer
intermediate
Why might XPath be slower than CSS selectors?
XPath expressions are often slower because they require more complex parsing and can traverse the document tree in multiple directions, unlike CSS selectors which are optimized by browsers.
Click to reveal answer
Which locator strategy allows selecting elements based on their text content?
✗ Incorrect
XPath can select elements by their text content, while CSS selectors cannot.
Which locator is generally faster in Selenium?
✗ Incorrect
CSS selectors are usually faster because browsers optimize their parsing.
Which locator strategy can navigate up the DOM tree?
✗ Incorrect
XPath can navigate both up and down the DOM tree; CSS selectors cannot go up.
If you want to select an element by its class and attribute, which locator is best?
✗ Incorrect
CSS selectors are simple and efficient for selecting by class and attributes.
Which locator strategy is more readable and easier to maintain for simple selections?
✗ Incorrect
CSS selectors are usually more concise and easier to read for simple element selections.
Explain the main differences between XPath and CSS selectors in Selenium.
Think about navigation, speed, and syntax differences.
You got /5 concepts.
When would you choose XPath over CSS selectors for locating elements?
Consider capabilities CSS selectors lack.
You got /4 concepts.