Module 1

Advanced XPath and CSS Locator Strategies

Module objective: Learn how to choose stable locators in real-world UI. Each task asks you to find one exact element and click it.

Main flow: Read each strategy, build locator using only that strategy, click target element, and confirm chip changes from Pending to Passed.

Basic Locator Strategies

What to do: Use one direct locator type per row (id, name, class, tagName, linkText, partialLinkText) and click only the target element.

Expected result: Each row chip changes to Passed after the correct target click.

  1. By idPending
  2. By namePending
  3. By classPending
  4. By tagNamePending
    Ignore this

Relative XPath Functions

What to do: Use the exact XPath function requested for each row (text(), contains(), starts-with(), grouped index, combo predicates, and multi-attribute predicates).

Expected result: Correct target click sets the corresponding chip to Passed.

  1. Use text()Pending
  2. Use contains()Pending
  3. Use starts-with()Pending
  4. Grouping/Capture style with parentheses (pick 2nd match)Pending
  5. Combination of functions: contains(text()) + starts-with(@id)Pending
  6. Multiple attributes in XPath predicatePending

XPath Axes

What to do: Start from nearby anchor elements and traverse using requested axes (child, parent, ancestor, sibling, forward, and backward traversal).

Expected result: Each axis task marks Passed only when the right target is clicked.

  1. Axis: child::Pending
  2. Axis: parent::Pending
    Anchor
  3. Axis: ancestor::Pending

    Leaf

  4. Axis: following-sibling::Pending
  5. Forward traversing: following::Pending
    Gap
  6. Backward traversing: preceding::Pending
    Anchor Node
  7. Sibling traversal both sidesPending

Relative CSS Selectors

What to do: Use CSS selector syntax for #id, .class, multiple classes, tag selector, and multi-attribute selectors.

Expected result: Each CSS row chip changes to Passed after successful target click.

  1. By CSS #idPending
  2. By CSS .classPending
  3. By CSS multiple classesPending
  4. By CSS tagName (scoped)Pending
  5. By CSS multiple attributesPending

CSS Attribute "Functions"

What to do: Use CSS attribute operators *= (contains) and $= (ends-with) to match partial attribute values.

Expected result: Correct target click updates each function row to Passed.

  1. Contains equivalent [attr*='value']Pending
  2. Ends-with equivalent [attr$='value']Pending

CSS Parent/Child and Sibling Concepts

What to do: Use relationship selectors for direct child (>), descendant (space), and sibling combinators (+/~).

Expected result: All three relationship tasks show Passed when correct targets are clicked.

  1. Direct child selector parent > childPending
  2. Indirect descendant selector parent childPending
  3. Following sibling selector + / general sibling ~Pending
    Sibling Start

Completion

In Progress: completed 0 / 29 tasks.

When all 29 are done, this module is complete.