Read a value next to its label
intermediate XPath axes Challenge 3 of 13
The order details table lists labels in th cells and values in the td next to them. Write a locator for the value of the Status row (the cell that currently shows “Shipped”).
Requirements
- Use
driver.findElement(By.xpath("..."))with thefollowing-siblingaxis. - Find the row by its label text, so “Payment status”, “Status history” and the help legend do not match.
- Do not depend on the row’s position (no
tr[3],position()or:nth-child).
Expected output
Resolves to the value cell in the "Status" row (the cell containing "Shipped").
Checks (4)
- ○Resolves to exactly the intended element(s)
- ○Uses By.xpath
- ○Uses the following-sibling axis
- ○Does not depend on the row position
Solution.javaLocator engine · not a real Playwright run
Ctrl/⌘ + Enter to check locator · your code is saved in this browser
Results
Check your locator to see which elements it resolves to.
Page under test
matches are outlined in greenView page HTML
<section class="order-details">
<h2>Order 2041</h2>
<table class="details">
<tbody>
<tr><th>Order date</th><td>3 Nov 2026</td></tr>
<tr><th>Payment status</th><td>Authorised</td></tr>
<tr><th>Status</th><td><span class="badge">Shipped</span></td></tr>
<tr><th>Status history</th><td>Placed, Packed, Shipped</td></tr>
<tr><th>Total</th><td>$142.80</td></tr>
</tbody>
</table>
</section>
<aside class="help">
<h3>Status</h3>
<p>Track your delivery in the app.</p>
<table class="legend">
<tr><th>Status</th><td>What it means</td></tr>
</table>
</aside>