cancel
Showing results for 
Search instead for 
Did you mean: 

Converting an old project to CSS/XPATH

SOLVED
hkim5
Staff

Re: Converting an old project to CSS/XPATH

@wmtan01 any luck trying out the conversion steps above?

We're eager to hear your experience.

 

 

Best,
Justin Kim
wmtan01
Contributor

Re: Converting an old project to CSS/XPATH

Hi,

 

Sorry about that, I was busy doing other stuff for work. We're currently working on cleaning up our namemapping that's why I came across the CSS/XPath changes. 

 

I'll try it out and let you know!

wmtan01
Contributor

Re: Converting an old project to CSS/XPATH

@hkim5 I was reading the steps and saw that the data collection phase basically needs to hit my namemapping object, meaning it needs to be used in a test? or at least identified in a page?

 

What happens if we have some objects mapped that are not currently used in a test, will they disappear when i hit convert?

wmtan01
Contributor

Re: Converting an old project to CSS/XPATH

Sorry for spamming the thread.

 

I did try it out and the following are the results:

wmtan01_0-1610637479062.png

This object was passed through by a small script I ran with the command line and converted

wmtan01_1-1610637536410.png

This object was not used in the small script so was not converted

 

I then tried to run a larger script that calls both objects and it worked! When I tried to edit the namemapping, for the object that was converted, it now showed me the edit screen for selectors while for the non converted it still showed me the previous editor.

 

It's my first time seeing the CSS/Xpath edit window and noticed it can only be modified by adding "Or" conditions to the selectors, is it not possible to do it similar to the old identifiers where you can say something like this?

wmtan01_2-1610637980753.png

 

hkim5
Staff

Re: Converting an old project to CSS/XPATH

im glad to see that it (partially) worked. As you would expect, TestComplete can only collect information about the objects if they are interacting with them during the test run using the special cmd line key to collect the xpath/css selector info

 

As far as your comment for the object identification properties go, you are correct. You cannot set it up to use the conditional mode as you used to within the classic name mapping projects. The css/xpath selectors are automatically mapped using a combination of boolean OR operators for the selectors. However, should you need more flexibility in search expressions, you can use XPath 1.0 functions like contains, substring, starts-with and others.

XPath 2.0 functions (like lower-case(), matches() and others), Microsoft extensions and other third-party extensions to XPath functions are not supported.

 

additionally, you can parameterize these search expressions with project level variables (kind of like you used to be able to with the classic name mapping), but you will need to encapsulate your project level variable name in '%' in order to reference them. 

Best,
Justin Kim
wmtan01
Contributor

Re: Converting an old project to CSS/XPATH

It looks like the TestComplete runner can actually use both styles of identifiers and accept a hybrid namemapping which is awesome! 

 

Does running with the Device Cloud Add-on require that my entire namemapping be CSS/XPath or will it still work with some objects using the old style? I honestly have not dived-in much to that Add-on

AlexKaras
Community Hero

Re: Converting an old project to CSS/XPATH

Hi,

 

Does running with the Device Cloud Add-on require that my entire namemapping be CSS/XPath

Yes it does.

Actually, what Device Cloud add-on does is it converts internal TestComplete commands that drive tested web page into Selenium analogues. This is required because it is Selenium that can drive web pages across different platforms and thus Selenium is used under the hood for Cross-platform testing in TestComplete. And as Selenium cannot deal with 'native' objects mapping used in TestComplete but only with XPath and/or CSS, this is the reason for the requirement that all objects that cross-platform test interacts with must be mapped via XPath/CSS.

Other objects that are not used in cross-platform tests can be left as they are.

 

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
================================
wmtan01
Contributor

Re: Converting an old project to CSS/XPATH

That means converting an existing project to be Cross Platform compatible is a huge effort even with the converter as the reliability is still unknown, I saw how much OR conditions the converter created and with the way we built our namemapping we are relying heavily on wildcards for most objects to make it cleaner and easier to understand which the converter will not pick up.

 

Thanks for the info!

AlexKaras
Community Hero

Re: Converting an old project to CSS/XPATH

I saw how much OR conditions the converter created

To my understanding these ORs correspond to all cross-platform identifiers that TestComplete can identify while analyzing this or that web element. (E.g. identification by id, XPath, CSS, etc., see https://support.smartbear.com/testcomplete/docs/app-testing/web/cross-platform/addressing.html#addre... and screenshot.)

So these ORs are just an attempt to increase identification stability so that if first locator fails, TestComplete tries the second one and so on. Every condition in cross-platform namemapping does not depend on others combined by OR clause. (This is documented.) If, for example, web elements on the tested web page have stable and unique IDs, all other locators can be safely disabled or deleted in cross-platform namemapping.

 

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
================================
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors