Ask a Question

xPath won't recognize


xPath won't recognize


I am trying to create a generic mapped object using xPath. But for some reason TestComplete cannot find the element.

2021-10-05 15_00_06-Window.png

I am trying to get the selected selector working. As it is now it doesn't seem to recognize the selector and it's using OR so it has to go through all the selectors, am I right?

When deselecting, TestComplete does recognize the selector. But I want to create a general selector. And for some reason start-with doesn't work, because multiple results are found.

2021-10-05 15_00_24-Window.png

I also checked the TestComplete documents to see if there is anything about this but I only get general xPath information.

Is there anyone who can help me with this? 


Kind regards,


SmartBear Alumni (Retired)

Have you attempted using a wildcard in the name mapping?  Or edit the order of selectors



Yes I tried to change the order and what happens is, the one selected is recognized, but others aren't. It seems that for some reason only the first or second selected selector are being used.


As for the wildcard, the * won't work using xPath, as far as I tried.

Hi @Luukdb - 


Have you tried taking a look at the object using the object spy recently to see how the selectors may have changed since they were originally mapped?


You can find more information about the Object Spy here:



SmartBear Alumni (Retired)

Thanks everyone!


@Luukdb does the advice help?

Sonya Mihaljova
Community and Education Specialist

Community Leader

When there are multiple xpaths(1,2,3,4,5) in the same object of the namemapping. Like your capture shown.

I think the check rule like below.

TestComplete will recognize the object with the order of the selected xpaths.

If 1 failed it will check 2. If 2 failed it will check 3....


If you want to recognize the object correctly.

1.Make sure the xpath is correct first.

2.Make sure the object display when you operate it by xpath.(You can add delay time in the previous step)


To the xpath:

You can try to replace start-with with contains.


I hope it can help.




@sonya_m unfortunately not.. I am experiencing this behavior with multiple random objects. I am also currently in contact with the support desk about this, but there is still no solution.


@ApplePen I tried using contains but this won't work because he will find multiple objects. I also checked the XPath and the ones we are using are correct. We are also using the Chrome extension SelectorsHub to validate and copy the XPaths we use.


I can give a bit more clearance why we have this many selectors for one object and give another example.


We have multiple instances of our ERP system, these are all in one TestComplete project, so we only have to maintain one namemapping. Our instances are named after colors for example; Green, Red, Blue, Orange. Currently the instances Green and Red are working and cooperating fine. But now I am implementing some tests for the Blue instance and this one gives trouble. There are random objects with the issue I explained above and we cannot seem to figure out why.


Now my other example:

We try to use the selected object below. This object can be selected in the instances Red and Green.


The XPaths we currently have to detect the object are these.


As you can see in the screenshot below we use the correct XPath for the object.


The XPath of the object we want to find is the fifth selector in my screenshot. But for some reason TestComplete cannot find this selector. When I move the selector above selector 4 he can find it, but then he cannot find selector 4. The other selectors aren't giving any trouble.


Also for this object I tried using contain and even starts-with but when I do this he finds multiple objects. I will copy my XPath below.

//div[contains(@id, 'controlButtonPickup')]

//div[starts-with(@id, 'controlButtonPickup')]

//div[contains(@id, 'controlButtonPickup')]//div[@class='actualButton ng-scope']


Community Leader

I know what you mean.


If the name mapping is correct.

BitInternational should be browser type.

BitInternationTest should be the website page that you want to operate.



Could the object in namemapping be hightlight?

Or this object is in an iframe. You need to switch to iframe first and then can use it.

Please check it.




@ApplePen BiTInternationalTest is the webpage, we currently use * to ensure that all the environments have the same namemapping. In 2022 we get an official one URL for all instances.


I do need to check the browser type.


I can only highlight the object when the fifth selector is on the fourth place, otherwise it says it cannot be found. The other way around is also true.


What do you mean by iframe?

Showing results for 
Search instead for 
Did you mean: