Ask a Question

Copy tests if they are similar

mcp111
Contributor

Copy tests if they are similar

Can I copy one test to another if theyare similar and manually make few changes?

eg. In login test, I may have valid login/pwd as one test

In another, it may just be valid login and invalid password.

Instead of recording a whole new test, can I copy the first test and just make changes?

 

Regards

Partha Mandayam
Software Consultant
10 REPLIES 10
shankar_r
Community Hero

I would prefer creating a common function for login and call them in individual test.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

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

Extension Available

You didn't understand

There are two tests, one is a successful login and another is unsuccessful.

Since the only difference is the password, I want to copy the first and create the second test.

Is there a way to do that?

 


@shankar_r wrote:

I would prefer creating a common function for login and call them in individual test.


 

Regards

Partha Mandayam
Software Consultant

@shankar_r is right.  You could have a common login function and then call it once with successful data and once with unsuccessful data.

 

But can you copy one test to another?  Sure.  Select all the code in the one you have and copy it.  Add a new blank test and paste.  Done.

 

You can also make a copy of the test file in the TC directory with a new name, then in the Project you can use the Add Existing feature to add that renamed test into the list. 


Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

How would I create a commonlogin function and call it from multiple tests?

 


@Marsha_R wrote:

@shankar_r is right.  You could have a common login function and then call it once with successful data and once with unsuccessful data.

 

But can you copy one test to another?  Sure.  Select all the code in the one you have and copy it.  Add a new blank test and paste.  Done.

 

You can also make a copy of the test file in the TC directory with a new name, then in the Project you can use the Add Existing feature to add that renamed test into the list. 


 

Regards

Partha Mandayam
Software Consultant

A simple function will look like below, 

 

 

function loginMyPage(strUserName,strPassword){
      var loginWindow = Aliases.App.LoginWindow;
      
      loginWindow.txtUserName.Keys(strUserName);
      loginWindow.txtPassword.Keys(strPassword);
      loginWindow.btnSubmit.Click();
}

Using this option you can call this function in Tests. 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

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

Extension Available

Thanks

What is 

Aliases.App.LoginWindow

 


@shankar_r wrote:

A simple function will look like below, 

 

 

function loginMyPage(strUserName,strPassword){
      var loginWindow = Aliases.App.LoginWindow;
      
      loginWindow.txtUserName.Keys(strUserName);
      loginWindow.txtPassword.Keys(strPassword);
      loginWindow.btnSubmit.Click();
}

Using this option you can call this function in Tests. 

 



 

Regards

Partha Mandayam
Software Consultant


@mcp111 wrote:

Thanks

What is 

Aliases.App.LoginWindow

 


This is the NameMapping of my login window.

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

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

Extension Available

Thanks.

So how do I find name mapping of my login window?

 


@shankar_r wrote:

@mcp111 wrote:

Thanks

What is 

Aliases.App.LoginWindow

 


This is the NameMapping of my login window.

 


 

Regards

Partha Mandayam
Software Consultant

These are all basic items of TestComplete, I suggest you attend or watch the TestComplete 101 training.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

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

Extension Available

cancel
Showing results for 
Search instead for 
Did you mean: