Forum Discussion

klabbe's avatar
klabbe
Occasional Contributor
3 years ago

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"

 

 

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

 

 

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

 

 

 

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 :

 

 

 

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

  • 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's avatar
      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 :

       

       

      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.

       

       

       

      Thanks

       

      • klabbe's avatar
        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