cancel
Showing results for 
Search instead for 
Did you mean: 

CSS selector into namemapping

SOLVED
RegasQA
New Contributor

CSS selector into namemapping

Hello,

I have not been busy with Testcomplete for a long time and I mainly use Keyword tests because I am not a developer. I cannot write code. Now the developers have made an adjustment so that all my tests suddenly fail. This is because I did not set up my namemapping sufficiently uniquely. My colleagues mainly use the CSS selector to give elements a unique ID. They also want me to use it. To what extent is it possible to include the CSS selector in my name mapping? And if that is not possible, what should the developers do so that I can make elements unique enough?

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: CSS selector into namemapping

Hi,

 

I am not sure that CSS selector can be used for Namemepping. (Though you can use the value of the 'class' property as one of the identification criterion for Namemapping.)

The best thing that your developers can do to improve testability of their application is to introduce stable and unique IDs for every UI element that automated test needs to interact with.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

5 REPLIES 5
AlexKaras
Community Hero

Re: CSS selector into namemapping

Hi,

 

I am not sure that CSS selector can be used for Namemepping. (Though you can use the value of the 'class' property as one of the identification criterion for Namemapping.)

The best thing that your developers can do to improve testability of their application is to introduce stable and unique IDs for every UI element that automated test needs to interact with.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

sonya_m
Community Manager

Re: CSS selector into namemapping

Thanks Alex! 

 

@RegasQA does this approach work for you? Please let us know Smiley Happy


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Tris
Contributor

Re: CSS selector into namemapping

Marked solution is incorrect.

 

This is a recent feature added in TestComplete v14.50 as I was investigating the use of this. There is a full guide on this which can be found on the support site below.

 

https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/xpat... 

 

Note - I have tried to implement mapping with CSS selectors alongside my existing name mapping which uses attributes and have had inconsistent mapping results.

 

For example I map a new object, which on the UI is within an existing mapped object and TestComplete maps it correctly as I would expect within the existing object at alias level, but not anywhere close to where I would expect at the mapped object level. 

 

I contacted SmartBear about this, their suggestion? Delete all my existing mapping and start again if I want to work with CSS locators, hardly a solution, so just be aware of this if you do decide to go down the CSS locator route.

 

I would suggest if the above is something you would like to do, then up vote the feature request below which would allow us to transition our existing mappings over, rather than deleting and mapping all over again.

 

https://community.smartbear.com/t5/TestComplete-Feature-Requests/Request-adding-CSS-Selector-to-exte... 

AlexKaras
Community Hero

Re: CSS selector into namemapping

Hi,

 

Marked solution is incorrect.

Reply was correct as of date of writing.

 

Delete all my existing mapping and start again if I want to work with CSS locators

This is just because the new cross-platform web mode that you are talking about uses Selenium under the hood. Selenium has no idea about TestComplete's native recognition functionality and thus 'native' and 'cross-platform' NameMappings are incompatible and cannot be mixed.

 

P.S. Search by CSS is supported in TestComplete via the .FindElement() and .QuerySelectorAll() methods and has the same problems as the search by XPath.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Tris
Contributor

Re: CSS selector into namemapping

@AlexKaras - apologies, I'm from the UK, saw the date as 2nd September 2020, rather than what it is (US date) 9th February 2020.

 

Still would be nice to see a future update which made the CSS/Xpath locators visible in the old way of mapping so that they could be gracefully switched over. In the software I'm automating it would potentially be worth switching due to the lack of attributes associated to objects, though in recent update of our technologies it seems that they are starting to get better.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors