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.
- theraud-g10 years agoOccasional Contributor
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
- dganov10 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-g10 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
Related Content
Recent Discussions
- 13 hours agoMW_Didata
- 24 hours agod_gfleetwood92