Move from a child to its parent with XPath
Automation taskMediumAsked in: Accenture, Infosys
Asked as: "The element you need has no stable attribute, but a child or sibling has one. How do you reach it?" The page is a tree: every element sits inside a parent, and elements with the same parent are siblings. XPath axes walk that tree from an element you can find: parent:: goes one level up, ancestor:: any number of levels up, and following-sibling:: to later elements with the same parent. In this task you find the strong element inside the paragraph with id boldText, print its text, then move up to its parent and print the parent id.