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

Pass loop count through variable

5 Answers 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Surendranath Potu
Top achievements
Rank 1
Surendranath Potu asked on 16 Jan 2012, 01:42 PM
Hi ,

Could you please let me know if there is any way that we can pass the loop count through a variable .


Thanks in advance


Thanks
Surendranath

5 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 17 Jan 2012, 05:14 PM
Hello Surendranath,

There are a few approaches here depending on your desired implementation.

1. Perform loop and its actions entirely in a Coded Step:

int count = 3;
for (int i = 1; i <= count; i++)
{
    //Some action/verification
    Log.WriteLine("Loop count = " + i.ToString());
}

2. Use a standard Loop step that includes actions and verifications as standard steps. Insert a coded step in the Loop. You'll need to press View Class to see the Code-Behind File and add an additional line of code outside of the coded step:

public int count;
         
[CodedStep(@"New Coded Step")]
public void LoopCountVariable_CodedStep1()
{
    count++;
    Log.WriteLine(count.ToString());
}

3. If you truly wish to create a variable you can later use to Attach to an Input Value or Attach to a Verification, use the following approach which Gets and Sets an Extracted Value in code

Use a standard Loop step that includes actions and verifications as standard steps. Insert an additional coded step in the Loop with the following:

object count;
try
{
    count = (int)GetExtractedValue("iter") + 1;
}
catch
{
    count = 1;
}
                    
SetExtractedValue("iter", count);
Log.WriteLine(count.ToString());

Now you can data bind a later step using $(iter) via data binding.

All the best,
Anthony
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
Surendranath Potu
Top achievements
Rank 1
answered on 17 Jan 2012, 06:47 PM
Hi Anthony ,

Thank you very much for your reply. 

I have another query ...

It is regarding radsplitter . 

RadSplitter is used in one of the pages in my application . Based on the part of the page that is visible ( currently I'm viewing )  , I have to do some operations on my webpage .  But when I tried to identify which part of the web page I'm viewing by using "Verify if a perticular  element is visible "  , even though I'm not seeing that element  ( i.e I'm seeing other part of the page which is behind ) , It is showing that that element is visible . 

Can you please guide me how can I identify if a Radsplitter is expanded or not using our test studio . 

So that I can understand which part of the page I'm in ..

Donno If I could able to explain the problem clearly . 

By Hoping you got my point , waiting for your reply .

Regards ,
Surendranath 

0
Anthony
Telerik team
answered on 17 Jan 2012, 11:14 PM
Hello Surendranath,

I am not able to reproduce the described behavior against this Telerik demo site. Please see the following screen recording where a "Is Visible" Verification properly fails after a RadSplitBar is collapsed:

http://screencast.com/t/JkNx2VXPtXWV

If you continue to have difficulty, please provide a public site, or even a sample test (within a .zip file), that demonstrates the issue.

All the best,
Anthony
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
Vijula
Top achievements
Rank 1
answered on 03 Sep 2013, 01:25 PM
Hi,

I am using latest version if Telerik 2013 R1. But with the above solutions provided for binding the loop did not work for me.

I need to run the loop for a specific time with some verification inside loop. I cannot keep the verification as a coded step since the element under verification is data binded. Can you please provide exact steps to data bind the looping counter.

Thanks,
Vijula
0
Velin Koychev
Telerik team
answered on 06 Sep 2013, 12:36 PM
Hi Vijula,

I am sorry to hear that  you are experiencing this issue.


I can see that my colleague, Anthony, has provided the different ways for doing this, depending on your testing scenario. 

In order to help you, I will need to know more about your testing scenario:
1) Please provide us with a copy of your test and if it is possible grant us access to your application so we can reproduce the issue on our end and give you a solution. 

2) A Jing video demonstrating the issue may also help us to better understand what is happening.

Looking forward to hearing from you.
 

Regards,
Velin Koychev
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Surendranath Potu
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Surendranath Potu
Top achievements
Rank 1
Vijula
Top achievements
Rank 1
Velin Koychev
Telerik team
Share this question
or