This is a migrated thread and some comments may be shown as answers.

Common steps in different class

4 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
md amir
Top achievements
Rank 1
md amir asked on 12 May 2010, 07:10 AM
I'm facing a weird problem here. I need to separate the common steps in the testcases and create a method in a new class. But it doesnt work.
For example, I have recorded 6 screens and the way to reach all the six screens are common. Only the core part of the screen differs. In this case there is so much of  duplicate code and I'm trying to remove that. I copied the common steps to a function in a new class and called that function from the testcase. It doesnt work at all. The common class inherits the same classes as done by the test cases. There is no compilation error or warning. But it just doesnt call them. It makes the function look insignificant.

Kindly help me get through with this issue. I'm not able to figure out if this is a problem with the tool or c# itself. Thanks in advance for the reply.

4 Answers, 1 is accepted

Sort by
0
Missing User
answered on 12 May 2010, 04:50 PM
Hi md amir,

Thanks for the post and question. For WebUI Test Studio, we strongly recommend you create short, individual tests for discrete user sequences of a web application and especially for different web applications all together.

If you decide to create a generic test suite over 6 similar, but still different pages, you can work on the same Manager object that a WebUI test uses.

You can pass that the Manager object into your helper class in the WebAii code behind file, then instantiate you helper class in a customized test step like the following (any inherited class of BaseWebAiiTest will not have it's Manager instantiated):

[CodedStep("MyCustom Step Description")] 
public void MyCustomStep() 
// Custom code goes here 
}


You can use the Manager object and it's reference to the ActiveBrowser object to Find controls on the page, but the Find Logic on the controls for each page will probably be different.

You would need to make the Find's as generic as possible (like using find by text content) or enumerate the Finds for each page and use logic to choose which Find to use for each test run. Here is a link to the Find logic for reference.

But I would like to mention again, it would likely be easier to create smaller, individual tests for each page you want to test over from a test creation and maintenance perspective.

Kind regards,
Nelson Sin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
md amir
Top achievements
Rank 1
answered on 13 May 2010, 10:25 AM
Nelson,

Thanks a lot for your response. We tried to work on this yesterday. The problem that we are facing is with the ActiveBrowser object. It fails if we have the ActiveBrowser in the second class (the common class). If we put it in the first class (i.e., the test case *aii.cs file), it works fine. All the steps other than ActiveBrowser are working fine if we move them to the Common class. Is there any solution for this?

Thanks,
Amir
0
Missing User
answered on 13 May 2010, 04:20 PM
Hello again md amir,

I rechecked this scenario with a static helper class and a new instance of a helper class. Both worked as long as the Manager object from the main WebAii Test's code behind file is being passed in using customized coded step I mentioned in my previous post.

I similarly tested the same implementation with passing in the ActiveBrowser instance from the main WebAii test and this also worked for me.

Please remember that inheriting from the BaseWebAiiTest class does not automatically instantiate the ActiveBrowser property. You must pass the Main Test's instance of the ActiveBrowser into your common class, then set the common class's ActiveBrowser property with that instance.

Sincerely,
Nelson
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Missing User
answered on 20 May 2010, 03:34 PM
Hello again md amir,

Just wanted to check back with you on this and point out this thread that covers a similar issue.

Kind regards,
Nelson
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
md amir
Top achievements
Rank 1
Answers by
Missing User
md amir
Top achievements
Rank 1
Share this question
or