Question

Element with xpath is not unique in Rescan but unique in Browser Inspector

  • 27 November 2023
  • 4 replies
  • 36 views

Userlevel 2
Badge +1

While locating an element by using xpath instead of properties in the Rescan window in Tosca Commander, the tool says the element is not unique, but on browser in inspector the same xpath returns only 1 found element on the page.

The value which is set in the xpath field of the Rescan window is following: 

"//tr/td[text()='User']/following-sibling::td[text()][@align='right']"

What can be the reason of not finding the element as unique in Rescan? As I can’t see what other elements the Rescan finds by that xpath.

Maybe Rescan is leveraging xpaths not as we used to experience in browsers.


4 replies

Badge

Hello.. Did you find the solution on the use of xpath in tosca.?

Userlevel 1

I recently faced this issued as described in original question, when working with Salesforce application. Upon further investigation we found out that the Salesforce screen we were working on, had some invisible parents (you can open a module and press F12 to see invisible parents). 

We then had a Salesforce Upgrade and a Tosca upgrade, and we dont know which one broke this association of module attribute to the parent. But yes, the association didnt exist anymore, which was the reason that Tosca was not able to identify the control using xscan event though browser did. To be honesh, in this case xscan didnt really matter, it could be any property used to identify an attribute.

To see if a parent is associated to an attribute, right click on that attribute and click on search icon to open TQL query window, and write “->UIParent” 

I suggest you do a new scan once and select the attribute and use any property to make it unique. Then use the TQL query I mentioned above to see if there are any parents associated to the attribute. And then use this query on your existing/old module attribute, and compare.

 

Hope it helps!

Userlevel 2
Badge +1

@PriyankaSharma thank you for sharing your experience. Did you also try to locate elements using xpath?

Hello,
I am not quite sure, but I think the issue could be with “/following-sibling”.
I remember some instance where Tosca interpreted “/following-sibling” as “//” (double slash) and the double slash always as the root element no matter where in the xpath it was. Sadly I can’t remember anymore how I worked around this.
But I believe it was with Tosca 15.0. I think in Tosca 2023.2 I did not encounter this issue. But I’m really not too sure.

Regards,

Reply