Reply
Highlighted
Frequent Contributor
Posts: 97
Registered: ‎10-03-2016

Framework - generic functions - passing Name mapping as parameters

For Web Application 

Is any one creating the framework where generic functions are created for different web objects like check box, Text box, button? 

 

for e.g. 

 

for select and click on the button 

 

function SelectButton(ButtonObj)
 {
       if(ButtonObj.WaitForProperty("Enabled", true, 3000))
{
        ButtonObj.ClickButton();
         Log.Message(ButtonObj.contentText + " is clicked");
}
else{
            Log.Error("No Button is Found");
}

}

 

 

Then from the main script .. 

 

call this function by passing Alias Name Mapping as parameters 

Have attached the scrrenshots.

 

Let me know if any more information is needed.

 

Thanks

Nishchal

 

 

 

 

Posts: 4,233
Topics: 37
Kudos: 1,495
Solutions: 307
Registered: ‎11-30-2009

Re: Framework - generic functions - passing Name mapping as parameters

I haven't gone quite to that level but I know others who have. It's not an unusual way of doing things.  An automation framework can be as granular or as general as you would like.  In a POS application I did testing on, I had generic functions for applying payments that I used all over the place.  That's a bit more generalized as it's not a single button press but I know of some other framework structures that go a bit more granular.  


Are you haven particular problems with this?  Is there something not working for you?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Extensions available
Community Leaders Program
Frequent Contributor
Posts: 97
Registered: ‎10-03-2016

Re: Framework - generic functions - passing Name mapping as parameters

Thank you very much for the updates.

 

No this kind of framework requires less coding in terms of creating the functions for every applications. Yes We have to be dependent on Name mapping as we are passing Name Mapping as parameters.

 

The biggest challenge is code completion do not appear . For e.g. if you look at the the screenshot functionscript1.png .

 

Also if we have new type of web Object then there is a challenge of writing the functions ie. writing the logic for e.g. how can we write the generic function of radio buttons.

 

Do you think is this a good framework ?

 

Thanks

NG

 

 

Posts: 4,233
Topics: 37
Kudos: 1,495
Solutions: 307
Registered: ‎11-30-2009

Re: Framework - generic functions - passing Name mapping as parameters

If it meets your business needs, does what you need it to do, and is easily maintainable and expandable... then yes, it's a good framework.

 

As mentioned, I don't go quite this granular.  I prefer to write my framework on a functional level (applying a payment, entering contact details, saving a file, etc) rather than on granular controls.

 

As for code completion, this is to be expected.  The function you displayed doesn't know what "ButtonObj" is... there's no context for it to know how to complete that code.  

 

As for radio buttons, what I would do is map the parent object for the radio buttons (panel, etc) and each of the buttons underneath it.  Your parameters for that function would be the parent object and the button name.  But this is just one way, I'm sure there are others.  Again... if it works for you, then it works.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Extensions available
Community Leaders Program
Community Hero
Posts: 2,934
Registered: ‎07-19-2013

Re: Framework - generic functions - passing Name mapping as parameters

[ Edited ]

Hi Nishchal,

 

Fully in line with Robert - if this framework works for you then it is a good one.

The only potential problem is non-existing objects.

I.e.: your code for drop-down contains a line like

<parameterObject>.WaitProperty("Exists", true, ...)

While running, TestComplete will try to evaluate the <parameterObject> and if it does not exist, TestComplete will wait for the object to appear within default timeout. If it is expected that the <parameterObject> may not exist then you will get not necessary execution performance loss.

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Leader
Posts: 661
Registered: ‎10-21-2016

Re: Framework - generic functions - passing Name mapping as parameters

Based on your code what i understand, you want to have some generic functions which can perform actions like ClickButton, Select Dropdown, etc.

 

Yes, this kind of functions would be useful when you want to have a framework for Object actions.

 

In some scenarios, It won't be helpful if you trying to do different operations with Textbox.

 

As @tristaanogre@AlexKaras said, If it is useful for your AUT structure and business needs then it is good have.

 

I have similar kind of function that i wrote for Setting up of Text,

 

function EnterText(objMainObject,strValue,strFridenlyName)
{ 
      
    //objMainObject should be Text box object
	if(objMainObject != null)
	{
		  if((objMainObject.Exists) && (objMainObject.Visible)) 
		  {
				
			if(aqConvert.VarToStr(strValue) == "null")
			{
				  objMainObject.Keys("^a");
				  objMainObject.Keys("[BS]");          
			}
			else if(aqConvert.VarToStr(strValue) != "")
			{
				  
				if(aqString.Compare(aqConvert.VarToStr(objMainObject.getText()),strValue,true) != 0)
				{
					  objMainObject.Keys(strValue);
					  
					if(aqString.Compare(aqConvert.VarToStr(objMainObject.getText()),strValue,true) == 0)
					{
					  Log.Event(strFridenlyName + " object is entered as " + strValue);
					} 
					else
					{
						Log.Error(strFridenlyName + " object is not entered as " + strValue);
					}
				}
				else
				{
					  Log.Event(strFridenlyName + " object is already as " + strValue);
					  break;
				}
				  
			}
			else
			{
				  Log.Message("No value found for input");
			}
		}
	}
}

 


Thanks
Shankar R

“You must expect great things from you, before you can do them”

Frequent Contributor
Posts: 97
Registered: ‎10-03-2016

Re: Framework - generic functions - passing Name mapping as parameters

Thank everyone for the updates .

 

The reason why I am trying to go create generic functions because we have 300-400 web applications that will be automated in the future. If I create generic functions and passing Name Mapping as parameters then we have to create less functions whenever we work for automation for new application.

 

I am trying to create generic function for radio button. We are using java script .

 

Let me know if additional details . Attached the screenshot.

Community Leader
Posts: 661
Registered: ‎10-21-2016

Re: Framework - generic functions - passing Name mapping as parameters

Hi,

 

You can create generic function to click the Radio button and it will have only the Click operation.

 

But in-order to know which Radio needs to be clicked, you need to have function to identify that.

 

ForEx:

In your attached screenshot, if you want to click the second radio button how will find it. If you know how to find it then you create common functions to do that.

 


Thanks
Shankar R

“You must expect great things from you, before you can do them”

Frequent Contributor
Posts: 97
Registered: ‎10-03-2016

Re: Framework - generic functions - passing Name mapping as parameters

In my case I have tried to implement generic function to determine which radio button need to be clicked but it is not working . Besides I don't see any testcomplete methods for radio buttons just like we have for drop down values . We want to select the radio button based on the R# value.

 

Please advise

 

 

Thanks

Nishchal

Posts: 4,233
Topics: 37
Kudos: 1,495
Solutions: 307
Registered: ‎11-30-2009

Re: Framework - generic functions - passing Name mapping as parameters

Couple of things:

1) Can you post the code that you are using for your radio button generic?

2) Can you post screenshots from your object browser showing

    a) The parent object containing the radio buttons and its properties

    b) At least one radio button object and its properties.

 

 

This will help us help you in correcting your generic.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Extensions available
Community Leaders Program
Try QAComplete Now