This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UFT Developer modifies xpath of objects

Hi,

I am dependent on XPath for identifying the objects. And I write my own XPath instead of going through the OIC.

Here is an XPath to identify an object - //*[@id="uniqueNumber"]/parent::div/parent::div/parent::div/div[2]/div/mat-error/span

And I get the inner text of that object via the command.

browser.describe(WebElement.class, new XPathDescription(<xPath>)).getInnerText();

When I execute I get the error message 

com.hp.lft.sdk.GeneralLeanFtException: Failed to execute 'evaluate' on 'Document': The string '//*[@id="uniqueNumber"]/uft:parent::div/uft:parent::div/uft:parent::div/uft:div[2]/uft:div/uft:mat-error/uft:span' is not a valid XPath expression.

If you see, UFT Developer is adding an additional 'uft:' to each level. I dont understand why it is doing it and how to avoid it.

  • 0

    You can write your own custom XPath if you are well versed in writing XPath or you can take the help of the Object Identification Centre (OIC) to create the descriptive object using XPath Description. During object identification using OIC, you can uncheck all other properties except XPath to create the object using the XPath description.

    You can copy the XPath value to your clipboard and use it in your scripts. To learn more about how to use the Object Identification Center, please refer to the following posts.