Complete the code to locate the parent element of a given child element using XPath.
WebElement parent = driver.findElement(By.xpath("//div[@id='child'][1]"));
The parent::* axis selects the parent node of the current node, regardless of its tag name.
Complete the code to find the following sibling element of a specific element using XPath.
WebElement sibling = driver.findElement(By.xpath("//li[@class='item'][1]"));
The following-sibling::li[1] axis selects the immediate next sibling <li> element after the current node.
Fix the error in the XPath to select the preceding sibling div element.
WebElement prevSibling = driver.findElement(By.xpath("//span[@id='current'][1]"));
The preceding-sibling::div[1] axis selects the immediate previous sibling <div> element before the current node.
Fill both blanks to select the parent div and then its following sibling span element.
WebElement element = driver.findElement(By.xpath("//p[1][2]"));
First, parent::div selects the parent <div> of the <p> element, then following-sibling::span selects the next sibling <span> of that parent.
Fill all three blanks to select a div element that is the parent of a span, and then select its preceding sibling li element.
WebElement element = driver.findElement(By.xpath("//span[1][2][3]"));
First, parent::div selects the parent <div> of the <span>. Then preceding-sibling::li selects the previous sibling <li> of that div.