Forum Discussion
Sadly yes ... There are a lot of "object identifiers" but none of these work to match an element longterm ... as these object ids are generated by the page during runtime - meaning if an elements loads faster / slower it gets the id first.
As it is a rather static page with no or close to no changes I would have chosen to do it with xpath as this doesnt change - But i dont want to script it, as we wouldnt use testcomplete if we had to use scripts anyway, because we have a fully working C# Selenium Testsuite for these purposes...
Hi,
> [...] it is a rather static page [...]
Well, as you are aware about the possible problems...:)
Back to your initial question: no, it is not possible in TestComplete use pure XPath to define elements within NameMapping tree. But you can easily effectively emulate it.
For example, let you like to namemap a text box with index 0 that is a child of div(0) with @class='aaa' that in its turn is a child of another div(0). I.e. XPath is like \div[0]\div[@class = 'aaa']\
You can do an initial NameMapping from Object Browser or Object Spy, switch then to the NameMapping editor and check/specify the following identification criteria for the elements:
-- For the first-level div: ObjectType = panel and ObjectIdentifier = 0;
-- For the second-level div: ObjectType = panel and ObjectIdentifier = 0 and ClassName = aaa;
-- For the text box: ObjectType = TextBox.
Note, that it is recommended to use (wrapping) properties provided by TestComplete wherever possible instead of the native ones provided by the browser. The reason is that properties provided by TestComplete ensure cross-browser support while native properties do not. For example, TestComplete-provided property contentText may correspond to either contentText or textContent native property depending on the browser.
You may make use of the Extended Find namemapping property if you like to emulate the XPath that searches down the tree (but remember that this increases search result uncertainty and search time depending on how deep you are searching).
https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/index.html help section should provide you with more details.
And the last but not the least: https://support.smartbear.com/screencasts/testcomplete/reliable-tests-for-dynamic-objects/ recording from the https://support.smartbear.com/screencasts/testcomplete/ page might appear to be useful.
Related Content
- 3 years agoLuukdb
- 3 years agoEgg
- 3 years agoenriquebravo
Recent Discussions
- 2 days agoGane195