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
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
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
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
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?
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
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
Glad I could help.
Regards,
Cody
Telerik
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
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