Our shop is currently evaluating TestComplete. Ive used UFT for several years. Can someone give me an example what TestComplete's approach to what is defined as 'descriptive programming' in UFT looks like? For example, how would the following line look in TestComplete scriptive - we will be using VBScript.
Browser("title:=TitleName.*").Page("title:=.*").Link("html tag:=A","text:=Log Off","html id:=ctl00_logOffButton").CLick
These references may be of some help
If you get used to work with XPath expressions, you may find the
Personally, I steer clear of XPath... and here's why... finding something via XPath will return something... but that something might not be a UI object that can be operated on with the standard wrapper actions/methods from TestComplete. Our pal @AlexKaras can give a better explanation.
The primary method (preferred and recommended) for object identification in TestComplete is via the NameMapping engine which builds an object hierarchy structure where objects are identified by a) what they are a child object of and b) a set of object properties used as identifciation criteria. So, your example would look, in the TestComplete programming, like
See https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/abou... and all related articles.
@tristaanogre In UFT, the Object Spy would return the XPath to most objects. So for example, in your example, that .click on the LogOffButton would work well by just supplying the XPath property. I just tried Test Complete ObjSpy and it doesnt look like the XPath is something it can locate. I can see where it would not be a favorable method to use. Correct me if Im wrong in my findings regarding not being able to actually spy the XPath as Im relatively new to Test Complete.
Yes, you are correct, neither Object Spy, nor Object Browser provide XPath expression as locator for some web element.
I think that the main reason for this is because TestComplete does not use XPath as a primary means to locate web elements and because XPath is specific for web elements, but TestComplete has a different unified approach that works for desktop, web and mobiles.
(In addition: why XPath? Why not css, for example? )
And in addition to everything been said by all previous repliers:
TestComplete identifies and searches for tested objects within the tested application using arbitrary set of properties and their values (which may be wildcarded). By default, TestComplete tries to uniquely identify objects by using a subset of predefined properties (like id, etc.).
With this in mind: There are three main ways to search for the tested objects in TestComplete:
-- Direct objects referencing as provided in the Object Browser. You may see this type of referencing in the line above the list of properties available for the selected object within the objects tree. This is most simple, most straightforward and least stable way of addressing.
For your example, the reference might look like this:
-- Objects may be searched for using .FindXXX() methods (e.g. FindChild(), FindAlChildren(), FindAliasChild(), ...). The use of these methods is more preferable than XPath because of their much greater flexibility, performance and some other pecularities related to web page markup.
In theory, FindXXX methods can be chained like in your example, but this is inconvenient and is rarely used in real code.
-- The most advanced and recommended approach is to use Namemapping with Aliases. With this approach, you need first to build a tree of mapped objects and then adjust Aliases tree to your most convenience. After that your code may look like in Robert's example (i.e. Aliases.browser.page.logOffButton.Click) and remain pretty stable for certain page design changes.
I also would like to recommend you:
a) Read documentation, which is pretty detailed and descriptive for TestComplete; and
b) Watch https://support.smartbear.com/screencasts/testcomplete/reliable-tests-for-dynamic-objects/ and other relevant recordings from the https://support.smartbear.com/screencasts/testcomplete/ page.
I appreciate all of the replies. As mentioned, ive had my skillset in UFT way back when it was Astra QuickTest. So migrating my skills to TC will be a process. Im not married to XPath. In fact, just started using it within the last couple of years. from my experience with it, it's one obj prop vs, at least two to sometimes 4 obj props to identify a single web element, e.g., an edit field. That said, my evaluation of this tool has been rewarding. Ive spent a couple of months getting it to integrate to VS and TFS -- and getting it to run tests via a build def. So havnt had the time to explore the scripting engine capabilities as much as I would have preferred to do. Sorry for the bold font,
> Im not married to XPath
...neither I am saying that XPath cannot be used in TestComplete test code. Sometimes this is the last resort due to the HTML markup of the tested web page.
But at least you should be aware about these pecularities of the search by XPath in TestComplete:
we will be using VBScript.
Some technical summary for your convenience: https://community.smartbear.com/t5/TestComplete-General-Discussions/Which-script-language-do-you-pre...
(Yes, I understand that other reasons like your current knowledge or other considerations might matter.)