Forum Discussion
Hi Guillaume,
Another possible approach is to use the .EvaluateByXPath()/.FindChildByXPath() method (if you succeed to append the ng-reference="first-piece to the final html markup). Might appear to be quite convenient if you can identify some parent element not far from the sought for object.
Hi again.
Thanks for your answers.
@lage: I would rather avoid using textContent. I assume I can not base my object recognition using innerHTML. There are two many elements (ancestors) that will contains the specify HTML code. Beside, I think it might take longer to parse DOM using regexp.
@dganov: Thanks. Indeed, that might help ! I actually never tried to add a non-existing property to identify a object in NameMapping. It is a bit tricky but it would do the job.
@alex: I would also avoid using EvaluateByXPath. I use Keyword Test and I avoid as much as possible script as it become difficult to understand and maintain test case. I assumed xpath/css selector would work, but I am trying to use namemapping.
Since @dganov answers actually works, I am still wondering how could I have TestComplete Object Browser to add specific property added to Extended Properties...
For instance, the following code actually works. I guess TestComplete NameMapping implementation actually uses a similar mechanism to retrieve element.
var PropArray = new Array("ng-repeat", "Visible"); var ValuesArray = new Array("*", true); var ngRepeats = Aliases.theBrowser.page.FindAllChildren(PropArray, ValuesArray, 50, true); ngRepeats = (new VBArray(ngRepeats)).toArray(); for(var idx = 0; idx < ngRepeats.length; idx++ ){ Log.Message(ngRepeats[idx].getAttribute("ng-repeat")) }
Are there any other solution (less tricky and time consumming) that would let me configure TestComplete in order to directly provide some property within Object Browser and NameMapping ?! If ng-repeat (or ng-reference, or anything else I would like to configure) attribute exists, then add it to Extended Property !
I tried Open Applications / Web Testing / Object Identification but that is not what I am looking for.
Thanks !
Guillaume
- dganov9 years agoStaff
I know about another trick, but I did not find any documentation on it, so use it at your own risk :smileywink:
There is "tcWebTestingRules.xml" configuration file in the "TestComplete 10\Bin\Extensions" folder.
To add "ng-reference" to the list of properties that can be used when mapping Panel (div) objects, you should find the following comment
<!-- FORM SPECIFIC -->
and right before it insert the following code:
<!-- PANEL SPECIFIC --> <MapOnAnyLevelRule> <Recognition> <True Name="canBeMappedOnAnyLevel" /> <Eq Name="ObjectType" Value="Panel" /> </Recognition> <Optional>ng-reference</Optional> </MapOnAnyLevelRule>
Then restart TestComplete, and after that auto mapping of Panels should use the "ng-reference" attribute as well.
Don't forget to backup the original file :smileyhappy:
- theraud-g9 years agoOccasional Contributor
Hey @dganov.
I really wonder how you found out this trick, anyway, it does work :). Thanks.
Even though it become easier to map object automatically, it uses a property (ng-reference) that is not accessible through Object Spy...
Still looking for a solution to add Extended Property to Object Browser !
Guillaume
- Lage9 years agoContributor
Hi all,
What dganov shares is awesome but I can not make it work. I'm also working with angular but the property that I would like to use to locate some web objets is the 'translate'. Please have a look at this label:
<label class="col-md-4 control-label ng-scope" for="password" translate="activate.account.password">Password:</label>
I would like to be able to locate the label for the property translate="activate.account.password"
If I Add My custom property manually, It works fine but editing the tcWebTestingRules.xml don't make any change.
how manually:
I have edited the TestComplete 10\Bin\Extensions\tcWebTestingRules.xml adding the line <Optional>translate</Optional> to the Label object rules to make this easier but I can not see anywhere the new optional property.
Can you help me?
<!-- LABEL SPECIFIC --> <MapOnAnyLevelRule> <Recognition> <True Name="canBeMappedOnAnyLevel" /> <Eq Name="ObjectType" Value="Label" /> </Recognition> <Optional>htmlFor</Optional> <Optional>form</Optional> <Optional>translate</Optional> </MapOnAnyLevelRule>
thoughts:
I don't find properly to use the inner or outerHTML
It would be nice if SmartBear will add support for adding custom properties, anywhere, easier.
- dganov9 years agoStaff
Lage, the change you made in this configuration file will be used only when you map new objects, so you need to re-map the needed object (and maybe delete the old one before that).
Also you can try to put your custom property at the top of the list (before htmlFor).