Forum Discussion

pkudrys's avatar
pkudrys
Contributor
12 months ago

xpath finds an incorrect object in TC, but the same xpath works fine in Chrome

Hi guys,

 

I'm experiencing an issue where given xpath finds an incorrect object in TC, but the same xpath works fine in Chrome. The xpath looks like this:

//mat-sidenav[contains(@style,'visibility: visible')]//input[@id=(//label[contains(.,'Key')]/@for)]

This is how the xpath works in Chrome (finds correct element in given sidenav panel):

xpath fins correct input, based of its label

 

The same xpath finds input in the main page, instead of sidenav panel...

 

Do you have an idea about the reason of this problem? Thanks.

10 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    So it highlights the object in "Legal Profile Filter"? Then TC should be able to identify the child item Key_IPT, which is beneath the parent item Filter_FRM_IPT. Have you tried to add another conditional expression, to see if that helps?

     

    Are you using the 'Tree' model?

     

    I wonder if this is an issue with an unsupported browser version, Supported Web Browsers and Technologies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    From what's mentioned here Finding Web Objects Using XPath Expressions, in Tips on Using XPath Expressions, "To search the entire web page for elements, put a double slash (//) at the beginning of the XPath expression".

     

    Since you are searching for,

    //input[@id=(//label[contains(.,'Key')]/@for)]

    it will match the first item it finds.

    • pkudrys's avatar
      pkudrys
      Contributor
      Hi,

      Thank you for the reply. Well, I was under the impression, that if a mapped element is a child of another mapped element, the xpath of searched element is a combination of parent and child element? So in this particular case, the child element should be searched in the sidenav panel, which is a parent element?
  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If you were to highlight the parent object Filter_FRM_IPT, does it highlight the correct item?

  • Thanks for the additional suggestions.

     

    Yes, I tried to add some more parameters and completely different xpath. But your suggestion about unsupported browser version gave me an idea to try the same in Chromium-based Edge. Surprisingly, it worked here! So I checked the Chrome version and it seems there was an older version 111 installed. After installing latest version 112, expected mapped input element was found also in Chrome. Thanks for your help and suggestions!

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You've installed Chrome 112.0.5615.49 and it works, even though TC doesn't support it 🤔

     

    At least it's working now 👍

  • Hi again,

     

    It seems I was too quick about the solution (installation of latest Chrome). Unfortunately, I'm experiencing the same issue today, both in Chrome and Edge. I guess I will have to contact support, because it looks like a TC problem? The xpath works perfectly fine in browsers dev. mode. And it also works if the xpath is used in single mapped object, instead of parent>>child mapped object.