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

Comparing Field Values Using Extract and Coded Step

6 Answers 265 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
lora
Top achievements
Rank 1
lora asked on 02 Jul 2012, 07:41 PM
(Silverlight)

Anyone have experience using EXTRACT to pull a data vlaue into a variable and then writing code to compare that extacted value against data in another field?

Ex.
Field A
Field B

I need to compare Field B value to what was entered in Field A. If Field B > than Field A, I need to verify that an error message is thrown back on Field A. Silverlight uses a control that outlines the field in red and then presents the error on hover over the upper left corner of the input box.

Telerik Support suggested using Extract during recording and then writing code to compare the values as intergers in  a coded step. I'm still not able to verify that an error message is thrown if Field B > Field A.



6 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 02 Jul 2012, 10:14 PM
Hello Iora,

After adding the Extraction steps and customizing the DataBindVariableNames (below I used fieldA and fieldB), your coded step will resemble the following:

int a = Convert.ToInt32(GetExtractedValue("fieldA"));
int b = Convert.ToInt32(GetExtractedValue("fieldB"));
 
if (b > a)
{
    //custom code
}
else
{
    //do nothing
}

The custom code that goes under the IF branch will be unique to your application. My guess is you could combine the sample that grab's a Silverlight Tool-tip, and then verify the tool-tip's string is not empty.

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
lora
Top achievements
Rank 1
answered on 03 Jul 2012, 03:12 PM
I'm attempting to use the Extract feature, but am not getting the same options as shown on the Create An Extraction Step in Telerik's documentation. http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/verifications/data-bind-an-extraction-step.aspx

In your documentation, the example shows "Extract - text contains 'flow'"

But, when I use the feature, I am not able to extract the actual field value of '2'.
I am seeing only the following options:
Extract - Element visibility is Collapsed
Extract - left side position is 908
Extract top side position is 439

See attached for screenshot.

0
Anthony
Telerik team
answered on 03 Jul 2012, 04:35 PM
Hello Iora,

That article was written against an HTML site, so a Silverlight extraction will be slightly different. For a Generic Silverlight Control, don't click the first blue nub (see screen shot 1), which targets the base element. Instead click one of the next nubs that targets to the TextBox, TextBlock, or whatever element holds the text (see screen shot 2).

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
lora
Top achievements
Rank 1
answered on 03 Jul 2012, 05:15 PM
This worked great, and I was able to complete the extraction and coded comparison. The issue for the extraction was I had to hover across the input field, and the pointer had to be in a certain position, in order to invoke the second blue nub (radmaskedtextbox).

Thanks for your help!
0
Amit
Top achievements
Rank 1
answered on 17 Jan 2013, 10:48 PM
I need that code for Extract and comparison but in my case the standard values are in different page not in the same page Can someone help me ?

Thanks,
0
Plamen
Telerik team
answered on 22 Jan 2013, 03:03 PM
Hi Amit,

All you need to do is to create an Extract step against a value seen on the current page. Then navigate to next page and create a Verification step against a value seen there. After that Attach the DataBindVariable to the Verification step and Test Studio will compare these two values for you.

Let me know if we can assist you further with this.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
lora
Top achievements
Rank 1
Answers by
Anthony
Telerik team
lora
Top achievements
Rank 1
Amit
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or