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

Can I verify part of my TextContent without coding?

13 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mindy
Top achievements
Rank 1
Mindy asked on 16 Aug 2012, 01:50 PM
Hi,

I have Kendo grid for my Inbox message page.  The look is similar to gmail: Inbox (10) and "10 is the total number of message in my Inbox"

What I want to test is extract the number of message in my Inbox and verify with the number displaying in my label.

My first step:  KendoGridExtract 'Data' item count into DataBlindVariable $(GridMessagesDiv)  --> this line, I can see that the count is "10"

How do I use that count to verify part of my label?

When I record to verify the label; the TextContent displayed as "Inbox (10)"  

Can I do it without coding?

Thanks,
Mindy 

13 Answers, 1 is accepted

Sort by
0
Reddy
Top achievements
Rank 1
answered on 16 Aug 2012, 01:57 PM
You should be able to do that without coding. Open the step by clicking the "Show Inline Editor" and then in the Text Compare Type you can select contains instead of Exact.
0
Mindy
Top achievements
Rank 1
answered on 16 Aug 2012, 05:14 PM
So, I did the following:

KendoGridExtract 'Data' item count into DataBlindVariable $(GridMessagesDiv)  
Verify 'TextContent' 'Contains' 'Inbox (10' on 'Inbox10Link' - DataDriven: [$(GridMessagesDiv)]

I ran that and it failed.  I looked at the log and it said:

Content.TextContent of 'Inbox10Link' does not match!
Match Type: 'Contains'
Expected Result: 3
Value at time of failure: 'Inbox(10'

I'm confused why the expected result is "3" instead of "10"  
Did I set the DataBindVariableName wrong in the first line?  It is "GridMessagesDiv" 
0
Reddy
Top achievements
Rank 1
answered on 16 Aug 2012, 06:35 PM
you do not have to do an extract for that. You can use the verification option. I did a sample record on my gmail account. I did not do many steps, as you needed help only on the verification part. See the screenshot of the attachment. I did a simple open URL gmail.com and then added a verification for 'InnerText' contains '4' on 'Inbox4Link'. I then created an excel spreadsheet with a column having email count and enter 5 in the first row and 4 in the second row. Then added the data binding to the test and made the verification data driven. After running the test, the first iteration failed as there were only 4 unread emails and did not match the email count 5 in the spreadsheet while the second iteration passed as the count in the spreadsheet also was 4.
0
Mindy
Top achievements
Rank 1
answered on 17 Aug 2012, 12:01 PM
Hi Reddy,

Thanks for helping!

The reason I was doing the extract first was to get the total item in the Inbox before I can verify if my label is correct.  "10" was just an example when I recorded this test.  It could be any number when I run this test.   Does that make sense?

Thanks,
Mindy
0
Reddy
Top achievements
Rank 1
answered on 20 Aug 2012, 01:01 PM
Hello Mindy,
       Can you please send me a screenshot of your Test Studio Recording, Failure msg and DataBind excel you used?

Thank you,
Reddy
0
Mindy
Top achievements
Rank 1
answered on 20 Aug 2012, 01:15 PM
Hi Reddy,

I can only provide you the recording steps and the failure msg.  I'm missing the databind excel, maybe that's my problem.  I'm not sure why I need a databind excel.  I thought I can just record a step to extract the count so that I can use that count to verify it agains my label.  Could you please explain what I need to do to accomplish this test?

Thanks,
Mindy
0
Reddy
Top achievements
Rank 1
answered on 20 Aug 2012, 01:51 PM
I am not sure i understand you correctly. So you extract the value from the Inbox (3) label on gmail.com (Example) and then what do you compare it with? A couple of screenshots of the process i followed with a Databind for comparison.
0
Mindy
Top achievements
Rank 1
answered on 20 Aug 2012, 02:29 PM
Sorry, if I confused you.

In line 39, I extracted the count of the table.  Please see my screen shot.
In line 40, I took that count and compared it with the number in my label.  On this example, it's "10" next to the "Inbox (10)".

Thanks,
Mindy
0
Reddy
Top achievements
Rank 1
answered on 20 Aug 2012, 02:52 PM
Hello Mindy, I am sorry i am not able to replicate that on my side as i do not have access to a similar test site that i can use.
    Instead of doing a verify test content on the next step, can you try doing an extract on that value also and then do a coded step to compare both the Variables

For a sample, i have named the second extract as "GridTitanInboxDiv"

Assert.IsNotNull(Data("GridTitanMessagesDiv"))
Log.WriteLine("Mails in Grid: " + Data("GridTitanMessagesDiv"))

Assert.IsNotNull(Data("GridTitanInboxDiv"))
Log.WriteLine("Mails in Grid: " + Data("GridTitanInboxDiv"))

Assert.IsTrue(Data("GridTitanMessagesDiv") =  Data("GridTitanInboxDiv"))
0
Mindy
Top achievements
Rank 1
answered on 20 Aug 2012, 03:10 PM
Hi Reddy,

Thank you so much for helping!

I did the extract "TextContent" instead of verify on line 40.  Then line 41, I added the code you provided.  I got compile error:  The name 'Data' does not exist in the current context in all 5 lines of code.
0
Reddy
Top achievements
Rank 1
answered on 20 Aug 2012, 03:40 PM
That's weird. I was expecting a different error. I was expecting two log messages (like the ones bolded below) to be written to the output log and then a failure msg because both the values do not match.

'8/20/2012 11:38:16 AM' - Using 'InternetExplorer' version '9.0' as default browser.
'8/20/2012 11:38:18 AM' - 'Pass' : 1. Navigate to : 'http://demos.kendoui.com/web/grid/editing-custom.html'
'8/20/2012 11:38:18 AM' - 'Pass' : 2. KendoGridExtract 'Data' item count into DataBindVariable $(Div)
'8/20/2012 11:38:18 AM' - 'Pass' : 3. Extract 'TextContent' on 'BasicUsageLink' into DataBindVariable $(BasicUsageLink)
'8/20/2012 11:38:18 AM' - LOG: Grid Count: 6
'8/20/2012 11:38:18 AM' - LOG: Email Link: Basic usage

'8/20/2012 11:38:18 AM' - 'Fail' : 4. [WebTest1_CodedStep] : New Coded Step
------------------------------------------------------------
Failure Information:
~~~~~~~~~~~~~~~
Exception thrown executing coded step: '[WebTest1_CodedStep] : New Coded Step'.
InnerException:
ArtOfTest.Common.Exceptions.AssertException: Assert.IsTrue - [Expected:True],[Actual:False]
   at ArtOfTest.Common.UnitTesting.Assert.IsTrue(Boolean condition, String message)
   at ArtOfTest.Common.UnitTesting.Assert.IsTrue(Boolean condition)
   at WebTest_1_.WebTest1_CodedStep() in C:\Users\nrahul.BLCORP\Downloads\WebTest(1).tstest.vb:line 78
------------------------------------------------------------
'8/20/2012 11:38:18 AM' - Detected a failure. Step is marked 'ContinueOnFailure=False' aborting test execution.
------------------------------------------------------------
'8/20/2012 11:38:18 AM' - Overall Result: Fail


0
Byron
Telerik team
answered on 20 Aug 2012, 10:06 PM
Hi Mindy,

I have created a sample test performing a similar task against our KendoUI grid demo. Please find a screenshot attached. The item count for the data grid does update to reflect changes in the grid. Using similar steps should work in your scenario. I have also included coded steps to output the contents of the extracted variable to the log. These should help you debug your test. Nithin's coded steps are correct, but they are written in VB; your errors are consistent with a test that is using C#. You can change the code to the C# version, as per our article on using extracted variables in code:

Assert.IsNotNull(GetExtractedValue("Div"));
Log.WriteLine("Items in Grid: " + GetExtractedValue("Div"));

You should replace the variable name as appropriate to your test. If this approach does not explain the changes in value, or indicates that the item count for the data grid is inaccurate, please provide us with a copy of your test and access to your application. Also, please provide your failure log and a copy of the DOM at the time of failure. You can export these to file from the failure tab for your test and add them to a .zip archive. If it is not possible to grant us access to your application, please take a Fiddler trace and attach it to a support ticket in a zip file. If you are unfamiliar with how to do that please refer to this short video. You can download the Fiddler application from here. A Jing video demonstrating the issue may also help us to better understand what is happening. Thank you for providing the information we require to advise you best.
 

Regards,
Byron
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Mindy
Top achievements
Rank 1
answered on 21 Aug 2012, 01:58 PM
Thank you all for your help!

I was able to get the extracted value in the gird and then get the InnerText of the label; then compared it using contains using coded step.

Thanks,
Mindy

Tags
General Discussions
Asked by
Mindy
Top achievements
Rank 1
Answers by
Reddy
Top achievements
Rank 1
Mindy
Top achievements
Rank 1
Byron
Telerik team
Share this question
or