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

Can a Script Step be used for If ... Else verify

3 Answers 138 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 20 Oct 2011, 12:43 AM
I have a data driven test that currently needs the data binding altered to filter different rows for different environments. Is there a way to use a scripted step to check the environment and then run subsequent steps or skip them?

thanks

3 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 2
answered on 20 Oct 2011, 02:55 AM
Yes,
please note that you will have to loop through the cycles.  Each row is a cycle ad include the following code here:

If  Data("Environment")  =  "Win7"  Then
'Enter what you need ran here.

End   If

I hope this help, if you need more help,
John
0
Matthew
Top achievements
Rank 1
answered on 20 Oct 2011, 05:32 PM
While I could hard code every step into an if else block in code, what I would like to do is simply up the iteration index and set the executioncontect.currentdatarow to the next datarow, or if I am at the end of usable datarows, to end the test without throwing a failure.

in psuedocode...

while ( Data["environment"] != CurrentEnvironment )
{
    if ( Executioncontext.currentdatarow == LastDataRow )
    {
        end test without error
    }
    executioncontext.setcurrentdatarow(NextDataRow)
}
0
Stoich
Telerik team
answered on 25 Oct 2011, 10:22 AM
Hello Matthew,
     I understand what you're trying to do.

Currently it's not doable but I've logged this as a Feature Request:
http://www.telerik.com/support/pits.aspx#/public/test-studio/8286

    You'll need to implement a workaround in order to skip an iteration:
You'll need to create two tests. Let's call them MainTest and Subtest.
Put all the automation actions in Subtest. Make MainTest data-driven. Now we're going to add Subtests as a TestAsStep in MainTest. However, we're going to do it in a coded step. Here's what the code will look like:

Copy Code
this.ExecuteTest("Subtest");
This implementation will now allow us to skip an iteration in MainTest if we so desire:
Copy Code
if (  ! ActiveBrowser.Url.Equals("http://someurl.com") ) {
      this.ExecuteTest();
}
In this way if the condition you're looking for isn't met we won't go into Subtest. In effect we'll be skipping the iteration even though it won't seem so from MainTest's point of view. I hope I've managed to explain this clearly, let me know if you require additional assistance with this.

Let me know if you have additional questions on this.

Best wishes,
Stoich
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
Matthew
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 2
Matthew
Top achievements
Rank 1
Stoich
Telerik team
Share this question
or