Ask a Question

XPath - Cannot find the object (KeywordTest)

klabbe
Occasional Contributor

XPath - Cannot find the object (KeywordTest)

Hi,

 

For several days, TestComplete often does not find several objects. I record a test and I run it and some objects are not found even if I put auto-wait or delay.

 

In some cases, I've test my XPath in Chrome's console and my XPath works but when put in a selector of a mapping in TestComplete it doesn't work.

 

Example :

I'm trying to acces a button that have no id that I can use because it's auto-generated and it changes all the time. 

 

Here is a the part of the html that contains the button. You can se that the button has a class named "icon-show-datebooks" and it's included in a table that has an Id = "btnShowDatebooks"

 

klabbe_0-1642101397869.png

 

If I use the commande $x in chrome with the following XPath, chrome has no problem finding it. But TestComplete don't

 

klabbe_1-1642101699264.png

 

I have also tried in TestComplete the following Xpath to find the button include in the table that has an Id, but it doesn't work also (bit it works in the console of chrome) :

 

         //table[@id='btnShowDatebooks']//button

 

klabbe_2-1642102147106.png

 

 

I have tried also the full XPath created by Chrome and it doesn't work also :

 

        /html/body/div[1]/div/div[1]/div/table/tbody/tr/td[1]/table/tbody/tr/td[7]/table/tbody/tr[2]/td[2]/em/button

 

The selectors in TestComplete :

 

klabbe_0-1642102855286.png

 

 

I don't know anymore want to do. If I cannot wrote XPath manually in the selectors of TestComplete, I'm in trouble.

 

Help please!

 

Thanks!

 

 

4 REPLIES 4
ebarbera
Staff

Hi @klabbe - 

 

In the bottom image you provided are these the selectors TestComplete automatically mapped?

 

Also what is the error message you are receiving in the TestComplete logs?

 

Thanks, 

 

Emma

 

klabbe
Occasional Contributor

Hi @ebarbera 

 

In the last image, the ones with the index [7] are the ones created by TestComplete but they don't work. The index always changes so I cannot use them. It's the reason I need to add manually selectors that will always be the same.

 

The error is changing depending of the selector.

 

The one with the selectors generated by TestComplete is this one :

 

klabbe_1-1642107654321.png

 

Some of them with the selectors that I added manually (work in the console of Chrome with the "$x" command). You can see that the button as a border in red in the image on the right.

 

klabbe_0-1642107525015.png

 

klabbe_2-1642107809115.png

 

Thanks

 

klabbe
Occasional Contributor

Hi,

 

Is there anyone who can help me? I really need to know why valid XPath in Chrome doesn't work in TestComplete.

 

Thanks!

 

Katherine

sonya_m
SmartBear Alumni (Retired)

Hi @klabbe ! If the suggestions from the Community didn't work I would suggest that you open a support case. This question might need a deeper investigation. 


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: