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

Reusing test steps in multiple tests

12 Answers 267 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Misty
Top achievements
Rank 1
Misty asked on 25 Aug 2015, 07:15 PM

I have two steps that I want to run at the beginning of each test I've created in multiple projects. Is there a way that I can do that? I wanted to create the steps in one test and save them somewhere so when I'm building the next test, I can just pull the steps in. The only thing that will be different on each test is the URL that I'm navigating too. 

Thanks,

Misty

12 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 28 Aug 2015, 09:53 AM
Hello Misty,

You can add the common steps in a separate test and use that test as test as step in your project when building other tests.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Misty
Top achievements
Rank 1
answered on 28 Aug 2015, 03:39 PM

Thank you, Ivaylo. I had an "ephiphany" yesterday and I realized the feature, "Run Test as Step" means create a small test with the steps I'll be using and put that into other tests.

 My other concern is that I'm using this for 100 other tests and I'm navigating to different sites. If I create the test and use it in other tests, can I change the URL that I'm navigating to? I'm afraid the storyboard pictures won't match up.

Misty

0
Cody
Telerik team
answered on 28 Aug 2015, 04:53 PM
Hi Misty,

Allow me to step in and answer your questions.

There are a couple of ways you can pass in a parameter to a subtest for navigating.

1) Use a test list and the BaseUrl feature. Using this approach you manually change the test list setting for the correct server or URL to navigate to. The subtest will pickup this setting and use it when you run that test list.
2) Set the subtest to InheritParentDataSource and data drive the parent test. Once properly setup the URL from your data source will flow from the parent test, to the child test and into the NavigateTo test step.

The storyboard images might not match up perfectly but that won't affect test execution. The storyboard images are only used in two ways:

1) You can manually view them and print them when you export the storyboard to HTML.
2) The storyboard image is displayed as the "expected image" when viewing failure details.

The test execution engine does not actually use these images in any way when executing the test script.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Misty
Top achievements
Rank 1
answered on 28 Aug 2015, 07:06 PM
Thank you, Cody. I'm not understanding what I'm supposed to use for a BaseURL?
0
Misty
Top achievements
Rank 1
answered on 28 Aug 2015, 07:35 PM

Maybe I should give a better example. When our sites are taken down for maintenance and then brought back up, they take awhile to spin up. With that being said, my tests fail because the webpage doesn't appear fast enough. I've tried changing the "Wait On Elements" but that doesn't seem to work or I'm using it incorrectly. A co-worker and myself came up with this but I think there's got to be an easier way to do it. I want the test to keep trying to access the URL until it comes up; when the page appears, we are looking for "Password:" to make sure that it's the actual log in page. I need to do this for every single test that I write. That's where the "Test As Step" feature comes in. I've attached a screenshot of what we came up with. Is there a different way to do this without coding?

 

 

0
Accepted
Cody
Telerik team
answered on 28 Aug 2015, 08:36 PM
Hello Misty,

Let me start with a high level explanation how BaseUrl works.

Let's say you have 4 testing environments:
  •  Development
  •  QA
  •  Stage
  •  Production

It's the same application but on 4 different servers with 4 different server address. Thus the login page for each one looks like this:
  • http://dev.server.com/app/login.aspx
  • http://qa.server.com/app/login.aspx
  • http://stage.server.com/app/login.aspx
  • http://prod.server.com/app/login.aspx

BaseURL would be the 4 server URL's:

- http://dev.server.com
- http://qa.server.com
- http://stage.server.com
- http://prod.server.com

Now in your NavigateTo test step you enter separate values as shown in the attached screen shot. To change testing to a different environment simply enter one of the above 4 Base URL values into the test list settings and like magic all of your tests now run against that environment w/o changing any of the tests. What Test Studio is literally doing is discarding the BaseUrl value of the NavigateTo step and replacing it with the BaseUrl value contained in the test list setting. Then it appends the NavigateTo value to that BaseUrl value creating one full and complete URL to actually navigate to.

Does that clarify how this is supposed to work? Another combination that would work is if you left the NavigateTo property empty and put the full URL into the test list settings BaseUrl value, Test Studio would go through the same motions of appending a now empty string to your BaseUrl value and navigate to it. Thus you can completely control what URL would be navigated to this way.

I've tried changing the "Wait On Elements" but that doesn't seem to work or I'm using it incorrectly.

Ah, thanks for that explanation. It's the ClientReadyTimeout value that you need to increase. Test Studio is timing out waiting for the browser to return to a "Ready" state, when it's done downloading the main HTML page plus all supporting files (css, js, png, etc.).

If you prefer to stick with your code, we can certainly do that. We'll just have to modify the code to read the BaseUrl value from the test list settings like this:

ActiveBrowser.NavigateTo(Settings.Current.Web.BaseUrl + "/default.aspx?local=1", true);

Using the above code you want to set your BaseUrl to "https://allegiant-test.comply365.net".

Or

ActiveBrowser.NavigateTo(Settings.Current.Web.BaseUrl , true);

Using the above code you would want to set your BaseUrl to "https://allegiant-test.comply365.net/default.aspx?local=1".


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Misty
Top achievements
Rank 1
answered on 02 Sep 2015, 02:00 PM
Ok, this is starting to make more sense to me now. I do have one question. I create the tests on my local machine and then I run them on a server that only I use. Each test is for a different site. Do I use both the BaseURL and the NavigateTo option or one or the other? I think I have an understanding of what a BaseURL is but I'm not certain I understand which one I use and when. I'm assuming, I use the BaseURL so the test will run on the server and I would use the NavigateTo with the appropriate url? Maybe?
0
Accepted
Cody
Telerik team
answered on 02 Sep 2015, 06:42 PM
Hi Misty,

BaseUrl is a setting for the entire test list (found in the test list settings). The value you set it to feeds directly into the NavigateTo step, by replacing the NavigateTo steps BaseUrl value. Thus they work together to accomplish the goal of controlling which environment your tests in that test list will run against. All the tests in your test list will run against that one environment (i.e. that servers URL), as controlled by the BaseUrl value. To go to a different server URL you must either change the BaseUrl setting before running the test list, or duplicate the test list and each test list has a different BaseUrl setting.


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Misty
Top achievements
Rank 1
answered on 03 Sep 2015, 04:18 PM
Ok! I'm following you now and I understand what you are saying. Thank you for all of the information above. I've tested out the options you provided and I'm finding which one I like best. Thanks again!
0
Cody
Telerik team
answered on 03 Sep 2015, 05:41 PM
Hi,

Glad I could help.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Can
Top achievements
Rank 1
answered on 05 Apr 2016, 05:03 PM

Hey Cody 

I have a problem similar to Misty's 

I need to use different urls sometimes with different parameters as in navigation step

So i would like to create an abstract structure where i can bind it to a different data everytime i use that step in a different test

But test studio doers not allow me to bind it when i use it as Execute as step so i cant 

If you have any suggestions or work around it would be appreciated 

Thanks in advance 

0
Elena
Telerik team
answered on 08 Apr 2016, 01:09 PM
Hello Can,

Thank you for your interest in Telerik Test Studio. 

The information you share wouldn't be enough to figure out the best solution for your scenario. Please elaborate more on the desired outcome for a bound test/step. Do you want to run the same test against different web pages? Please let me know of the details of your scenario so that I could advise you the best way. 

Please bear in mind it is recommended to submit new support/forum tickets for each new issue you face as it would be easier for us to keep track of any detected unusual behavior. 

Looking forward to hearing from you. 

Regards,
Elena Tsvetkova
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Misty
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Misty
Top achievements
Rank 1
Cody
Telerik team
Can
Top achievements
Rank 1
Elena
Telerik team
Share this question
or