Updated withText and withAttribute methods to use xPath