Using UFT’s Extensibility to Test Your Custom Controls

QTP/UFT Published on:
Using UFT’s Extensibility to Test Your Custom Controls

One of the most frequent questions I’m asked on my blog is, “How do I get my QTP or UFT to recognize my custom object?” There are many reasons why your automation tool is not able to recognize your application’s object, as I explained in my post, 6 things to try when QTP does not recognize an object.

One common but simple resolution that most folks forget to check is to actually ask the custom control’s vendor whether they have a solution.

For example, I recently had an issue with an Infragistics customer control, and it turned out that they have a vendor tool add-in called IG TestAutomation which currently supports their Windows Forms controls via HP’s Unified Functional Testing (UFT) and IBM’s Rational Functional Tester (RFT). IG TestAutomation also supports their WPF controls in HP’s UFT.

After finding out about IG Test Automation, I reached out to Michael Germann, Software Development Lead at Infragistics, and interviewed him on my TestTalks podcast to talk more about how to test custom controls.

Build Your Own Custom Control Code

Besides using a vendor’s automation SDK if available, Michael also mentioned that for many third party controls you can also develop your own code to handle most object recognition issues using HP’s UFT Add-in Extensibility, which is pretty much what IG Test Automation is built off of.
At a high level the extensibility kit gives you the control you're attempting to interact with and from there it injects itself into the control and you could hook up events and add methods, so you can then create your own record objects. Then you would record your parameters based off your methods and your properties. Then you can replay off the methods you add to it.

At a high level, the extensibility kit gives you the control you're attempting to interact with, and from there it injects itself into the control. You can hook up events and add methods, thus creating your own record objects. You would then record your parameters based off of your methods and properties and replay off the methods you add to it.

Do you need to be a Developer to use the Extensibility Kit?

To enable support for a third party control you generally do need to be a developer. Don’t be scared off, however, if you don’t consider yourself a developer; it's not too deep to actually implement it, but you will need some basic knowledge of coding to get to it.

Michael explained the process he uses working with the UFT extensibility add-in as basically listening to the controls events and then recording it. HP exposes a method where you essentially pass in a string that is likely going to be your method name along with all the parameters you’re recording from and replay. You then have an interface you have to implement. That’s extensibility in a nutshell.

Testability

Ultimately, if your application was not built with testability in mind, it will be very difficult to automate. And although we as test automation engineers pride ourselves on developing ways to get around all sorts of issues, the bottom line is that if your application is not testable from an end-user standpoint, from an application, then it's probably won’t be functional for that end-user. The whole concept of the testing is that you're supposed to emulate what an end user would do as best as you can.

If you can't test it that way, then the end user probably can't use it that way, either.

Michael Germann TestTalks

Custom Control Extensibility Automation Awesomeness


For more Custom Control Extensibility Automation Awesomeness read the full TestTalks interview with Michael Germann:

Joe: Hey Michael. Welcome to TestTalks.

 

Michael: Hi Joe. How are we doing?

 

Joe: Awesome. It's great to have you on the show, but before we get into it, can you just tell is a little more about yourself?

 

Michael: Right now, I am working at Infragistics. I am the software development team lead for the windows forms development team, but for about seven and a half years I was the lead developer for TestAdvantage, which eventually became just IG Test Automation, which is what we use to interact with HP and RFT. The HP UFT and RFT IBM. We basically build off their extensibility kits and create a product so that it can test our custom controls. Part of what Infragistics does, or actually the bulk of what it does, is create custom UI controls for every different platform, win forms, WPF, ASP Net, Android, iOS, et cetera.

 

That's pretty much what I've been doing. Before that I was just handling support, but the bulk of my time's been pretty much entirely on the development of TestAdvantage.

 

Joe: One of the biggest questions I actually get asked on the blog is “How do I get my QTP to recognize my custom object”. So for the people that are using your particular control, is this part of developer SDK or is it a separate product that they have to purchase?

 

Michael: It's a separate product you have to purchase. So for our controls, you would have to purchase it. You can actually develop your own if you'd like. HP does off extensibility kit, and that's pretty much what we built off of. You generally, it gives you the control you're attempting to interact with and from there it injects itself into it and you could hook up events, you could add methods from there, so you can then create your own record objects. Record your parameters from there, based off your methods, your properties, and all that. Then replay off the methods you add to it.

 

Joe: Great. So, like you said, I now UFT comes with that extensibility kit that you can do these types of things and I think a lot of people don't realize that and when they come across a custom control they just think they can't do it but they could either reach out to the vendor of the control and see if they have an extensibility kit, or if not, they could create their own extensibility kit. Basically, what it sounds like, is just something that can expose an object's, it controls methods or functions that may not have been available out of the box. Is that correct?

 

Michael: Correct. It injects straight into it. How HP generally does it is by injecting into it, you can also … you include the dlls itself for the actual test proxy dll that you create, generally we don't include the dlls. The way HP works is it sees what version of that dll you have in the application and pulls it from there, but again it's because its strongly named and our assemblies generally have or at least most of them have the assembly name built into it, or the assembly version built into it, you do have to keep version to version equal, so in our case we have, let's say, we just came out with 16.1, so you would need to have 16.1 to make it work with it, if you have our version's assemblies. While we have additional patches for, let's say in about two months we might come up with a service release for those controls, it's still the base name of the 16.1, so you could still use the same TestAdvantage across all different versions of the NetAdvantage controls.

 

Joe: Awesome, and so you are a developer, so for someone that's not a developer, there are test [inaudible 00:03:53] engineer, how hard do you think it would be for them to create an extensibility and to a custom object?

 

Michael: To create it you do generally need to be a developer to do it. It's not going to be nearly as extensive as trying to create the custom controls themselves. Like if you actually have the knowledge to create the custom control, it's clearly going to be a lot simpler than that, because you're only going like generally one or two layers deep. You're going to be listening to the events and then you record it. HP exposes a method on there where you just pass in essentially a string that will … that's the exact same string you're going to pass out, which will be … likely going to be your method name and all your parameters that you're actually recording from and replay. It's going to have a interface that you have to implement that has all your methods in there.

 

You basically use your specialized attribute replay interface that exposes that for you. That basically tells them to know that these are the methods you want to actually expose out to UFT, and from there it's just doing whatever you want from it, so let's say for selecting a cell in a grid. You might listen to the … after your select change event, from there you're going to get whatever identifier you want for that cell. You'll probably start off with the actual cell itself – the cell object. You want to turn it into something of a value-type member, so you might make a row/column string out of it and you just say okay, you're going to record it as record and say select cell and you'll have your row and cell string that you pass together. On replay, it's then going to say select cell, you're already going to have that method there. It's going to pass that row and column string that you passed in and then you have to then translate that back to the actual cell object to then select it.

 

So it's not to deep to actually implement it, but you do need some basic knowledge of coding to get to it.

 

Joe: Great. I think you mentioned it also supports IBM's rational functional tester, yes?

 

Michael: Yes.

 

Joe: Cool.

 

Michael: Yeah, we do have that as well. Generally speaking, between the two I've … it seems to be the customer always seems to be leaning a little bit more towards our HP and it's a little bit more user-friendly. I would say RFT is a little bit more developer-centric, or at least testing-wise, because you get a lot more ranularity in how you record things versus HP's how they generally record things and how we set up the method for recording things are we try and make limit to what the intent was. You try and put some intelligent recording to it, so against if you're going towards clicking in a cell and start entering it, we probably just instead of recording the select cell, activate row, activate cell, enter cell data, enter edit mode and start typing, we just set cell data on that.

 

All the others are just assumed because to set cell data, you have to actually activate the row, then activate the cell. You actually do a little bit more intelligent recording.

 

Joe: Like I said, this is an area that a lot of users struggle with, so this is great info. I do know that I noticed that you have a … I think it's an ultra data control and I'm just curious to know, is that part of your SDK for the IG Test Automation? Is that one of the controls they handle? Because a lot of times people say I can't … I want to be able to programtically get at the chopped data without having to hover over things and get tool tips.

 

Michael: Yeah, we do have the ultra data chart, and it's actually a newer chart over … like we have an ultra chart and an ultra data chart, we just started reissuing it … basically a redesign because the original design was done back I believe in 2005, so we tried to modernize and try and build it dotnet40 into the design aspects of it. Yeah, we do support the charting on it as well. For recording and replaying, most of it we actually only record basic interactions because how we generally see … like for a grid, you're dealing with a lot more data, and your user interactions are okay I'm going to change this cell of data and then I want to verify that all my … that that cell changed, all the calculations changed. For a chart you're generally seeing static information, unless you're maybe clicking on a specific data point, and but other than you just want to verify the data of the chart. In which case will give you a data table for the whole chart to say okay this all the data in the chart, so it's easier to validate the information of the chart.

 

Joe: And a lot of times I have people ask me “I can't recognize this control.” And I say, well work with your developers to figure it out, but how do you handle a customer request. Do you ever handle customers saying “I'm trying to interact, automate this particular control, and I need a particular method.” Is there a way or mechanism where they can submit requests to have that added with the newer version of the IG Automation Tool?

 

Michael: Yeah, they can contact our developer support and they'll generally get the information. Usually, I've been trying to build always some way to do it, even if it's not fully intrinsic like recorded and replay. Like we have a couple on scenarios come in where people are putting windows forms controls in a web application and certain of QTP's checks just weren't working at all because one of the main things it does is let's find out what form it's on. There is no form. So we had to do a lot of rewrites for that.

 

Another thing we generally try and do is, if their request is something that might possibly break other things, we might put let's say a proxy setting in there and in our stuff you'll see gets proxy settings, set proxy setting, which like temporally settings that we allow you to switch to say I'm going to start doing it this way instead, and we could just expose them for individual people and just add additional ones as we need. If it's something generic usefulness of the control, maybe we didn't add it initially or support for a particular function, in which case then yeah we'll gladly add some more support for it to make it a little more user-friendly.

 

I know it … based off of user's requests we've redid our toolbar support, because for about a series of five years we're doing a lot of different improvements and additions to toolbars including following with what Microsoft was doing when they added the ribbon, and a bunch of … the application menu, the application menu 2010, and we kept on adding to it. We were doing it by adding like additional actions for each style and then after awhile we just revamped it into a single action, make it a little cleaner and concise for everyone to use it.

 

Joe: Are all these control just for Microsoft-based applications or do you actually also have controls for web-based applications?

 

Michael: Oh, we do have controls for web-based applications and for iOS and Android. For support though HP currently we're only doing it for windows forms and WPF. We originally analyzed through ASPNet … actually I believe we analyzed around two or three times, and our extensibility kit, with working with our controls at the time, was not necessarily the best, so every couple years we reanalyze it to make sure they made the proper improvements and I generally also talk to HP to see if I can get any of the additional additions we need to try and and stuff to it.

 

For the WPF specifically, we've worked with them extensively to get that up to speed, but there was just certain basic aspects of the ASPNet that a little to hard to actually properly implement that support for.

 

Joe: Great, so if someone purchases IG Test Automation, how does it work? When they start up UFT, there's an add-in box. Would this be one of the options they'd select and once they select it from the add-ins, they then would be able to interact with all the different controls and be able to recognize them?

 

Michael: Well, it depends. There are … for WPF, they did add us to the additional add-ins to there. For windows forms, windows forms was around fairly early, to where they didn't really add the additional stuff to their add-in manager, so the way you end up doing that is through what they have is an SWF config file. It's just a text file that has all our information in it. When you install our product you have the option of checking to see okay what … how you actually want to install it. You want to install it based for the versioned assembly, so 16.1. The versionless assemblies, which we have a different set, where we just strip out the versions of them, and you wouldn't have to match those up or leave it as is. Let's say you're installing 16.1, but you're still testing 15.2, so you don't want to switch your configuration over.

 

After you have it installed, we have a version utility that will also just manually switch that for you. It'll check to see what versions of TestAdvantage you have installed, or IG Test Automation installed, and then from that you'll pick which one you want to actually have active.

 

Joe: Are there any areas of IG Test Automation you think most your users aren't aware of or is it just like you said, it's a standard extensibility add-in. Any tips or tricks you've found that some customers don't know that would help them use this particular tool?

 

Michael: Depends on which one. Like, some of the things we're implementing … actually some vigorous issues that we come across is just not picking the right version and generally what I am using is process explorer. It's a simple application you can get from Microsoft just be Googling it. I think it's only 2Mb, or something like that. It would essentially just replace your task manager and then you could see okay what version do I have actually running in my applications. You'd see all the loaded dlls, and from that okay I have clearly 16.1, or 15.2, or often we'll have people using much older versions like 7.3, but trying to install 15.2 and wondering why things are going wrong.

 

Most of the scenarios you can end up resolving is hop on process explorer, see what version you actually need, because testers may not actually be interacting with the developer. They'll just have this final application and go okay I know it has Infragistics in it, so I'm going just going to install this Infragistics Test Automation package on it should work. But if you have the wrong version, it's hard to actually determine that sometimes. That's one way to end up checking it. It's like use process explorer to see what's there and usually when you're recording you can also see when we inject our assemblies in it or on replay, and you can see oh are those assemblies matching. Well, if they don't then again you can see that issue as well, so that definitely handles 90% of the cases with people trying to get things set up and going will end up resolving most of their issues. After that, it's for WPF side, we have the concept of sub-items for it that we started interacting with because again with WPF, they can inject a lot of controls. It's much more fluid in design, so inside of a grid cell, you could throw like 15 controls in it and it'll work completely fine and for every cell you'll have 15 copies of those cell controls completely unnamed and HP really doesn't identify them well.

 

The way we end up generally handling that is we know the outer control is our grid, so we have means of getting to that individual cell and then we'll allow you to … they will click at different points in that cell because we generally swallow up all the controls inside of it, otherwise HP just ends up making it very unmanageable because it doesn't know how to identify them. They're just controls sitting out there. If you have let's say 1000 rows in there, it may only have like the first 15 or so that are visible, but if you scroll out of view, then there are 15 more all named the exact same and they wouldn't be able to identify them well. So we handle them as saying okay, here's a framework element of this cell. You can click at any point in there. You can dig deeper into it, we'll show you how to actually dig into that further, say okay click on this button, in the center of this button inside of that cell.

 

Windows forms, we usually … everything seems to be a little bit more contained, so you don't have those style of issues. But getting a property is usually fairly useful for any of those tricky scenarios where you need to get around to, or actually any of the any property ones. Like there's getting a property, setting a property, and getting a properties. Getting properties allows you actually just see all the properties on the object underneath and then you can pass in a full string of how deep you want to go. You can actually dig right down into your data source and get all the properties on it so you can get an idea of what it is. If need be, you can even … if it's publicly settable, set it. So, for those scenarios where for some reason your developer customized our control even further, but it was on our base, there's ways you can manually set things anyway to kind of reflect what you wanted to get done and bypass that. You'll still be able to generally test it. You can still get the let's say the XY coordinates if need be of any individual element and click inside there as well to simulate it that way if there's no other way from our normal recorded actions.

 

Joe: Awesome. Great advice. So, I'm just curious. As you being a developer, a lot of people I talk to, when they get to automation, I say if your developers haven't baked in testability to the application then you're probably not going to be very successful with automation. When you're developing, do you actually think about testability. Is that a good practice? Just trying to get a developer's point of view.

 

Michael: Well you don't necessarily do application development as much. Again, we're primarily control developers and that is actually sometimes actually an issue that I had over the years. Let's say the rush to get out the controls based on a certain time-frame, and in certain cases I might not actually be able to get to that particular control so I can start developing for it until later in their cycle to where they actually have already committed everything and there's, like I mentioned before, I listen to events to see how things interact, and there may not be an event for me to actually interact with that, so it is not uncommon for something like that to happen, even from a control-level support.

 

From a application development support, usually HP is pretty good with … between HP and our interactions with them, I haven't seen anything to where the testability of how a developer can end up setting it to would end up blocking that testability. There's always … I've seen a way to get around any sort of issue, but if it's not testable from a end-user standpoint, from an application, then it's also probably not functional for that end-user, because the whole concept of the testing is you're supposed to emulate what an end-user would do as best as you can. If you can't test it that way, then it's probably the end user can't actually use it that way either.

 

Joe: Awesome. Once again, great advice. Definitely agree with you there, cool. I noticed, you did mention you do have controls for web applications, so have you had any issues with Selenium being able to identify your objects or have any work-arounds for that particular situation or scenario?

 

Michael: I believe actually internally we do some testing with Selenium. I haven't been directly involved with that because I've been primarily on the development of the WPF and the windows forms.

 

Joe: Okay.

 

Michael: But I believe internally we still use Selenium. We did have to actually build our extensibility kit on that as well, or some layer for the Selenium to work, but again, I haven't really reviewed that often to get a strong sense of it.

 

Joe: How do folks know about TestAdvantage, because I've never heard of it before until I did a little research? Is this something that most people using your controls would know about, or …

 

Michael: If you end up needing to start testing our controls then you'll need something to test with and that's generally when they'll find out about it. Usually, when they purchase their controls, our sales team will end up mentioning that as well if they want to start testing it, the win forms is definitely the one that seems to be getting the most draw. WPF, I'm not sure if there is perhaps maybe other testing scenarios or maybe people just don't test it as much. I haven't seen that come up nearly as often.

 

Joe: Okay, Michael. Just before we go, what is the best way to find out more about you or learn more about IG Test Automation?

 

Michael: Well, I have a blog through Infragistics, MikeTechSpeak. You could end up finding stuff there. Usually I am putting general blogs about TestAdvantage in there as well as all the release blogs. That's primarily where you could find out … I do have a bunch of other like Facebook and other things, but they're … for testing related, that's probably the best spot where you'd end up going.

 

Joe: Awesome.

 

Using UFT’s Extensibility to Test Your Custom Controls