1
votes

I am new to UFT. I have a long "complex" xpath that finds precisely one element in chrome browser developer tools. When I use the same xpath in uft, the tool complains that the xpath is not in the object repository. Why does this happen and how do I fix it ?

This is what the xpath looks like:

//div[@class='a b c']//div[@class='p-q r-s']//div[@class='m n']//button[contains(text(), 'yes')]

I have to use such complex xpath because there are no ID attributes in this part of the page or any other 1-2 attributes which can uniquely identify the element.

Please help.

EDIT: My Vbscript code looks similar to this code:

Dim aButtonLoc
aButtonLoc = "//div[@class='a-b c-d-e g']" & _
"//div[@class='p-q r-s-t']//div[@class='uv w-x']" & _ 
"//button[contains(text(), 'Yes')]"

Error message: The {full xpath here} object was not found in the Object Repository. Check the Object Repository to confirm that the object exists or to find the correct name for the object.

1
Not familiar with UFT, but maybe you should check, if the DOM tree of the website is the same when you query it Chrome and when you use UFT. The DOM tree is often modified by JavaScript code or something like that, so depending on which front-end code is executed in UFT and which in Chrome, the DOM may look different, and therefore the XPath expression may find some element here but not there. - Kai Weber
Sounds like your UFT code is dealing with an object it expects you to have in the OR. Please show the actual UFT code that you're using and we can help you make use of your xpath properly to identify it. - Dave
@Dave - I added the code snippet that I am using. Looks like the object repo is a set of fixed locators. So, if you use anything outside it, then will you get an error, even if the locator is correct ? - JohnSink
@KaiWeber - You are right. It looks like the dom changes more frequently than I thought. The non-absolute xpath that worked in chrome well, does not work everytime. - JohnSink

1 Answers

0
votes

There is an error in my aButtonLoc locator. It should have xpath mentioned, like this: aButtonLoc = "xpath:=//d...etc."