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

Unable to Get Extracted value.

9 Answers 263 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 22 Jun 2018, 05:41 PM

Hi, Please see the code below...

            HtmlTable T2 = ActiveBrowser.Find.ByXPath<HtmlTable>("//*[@id='SystemClientsGrid']/div[2]/table");
            HtmlTableCell C2 = T2.Find.ByContent<HtmlTableCell>("l:ZZ");
            Log.WriteLine(C2.TextContent);
            string str1 = this.GetExtractedValue(C2.TextContent).ToString();

My Code is working fine till second last line as i can verify it in log. Last line not working.

It is throwing below mentioned error:

"The extracted variable 'ZZ' does not exist in the store. Make sure there is an extract step that has executed before executing this step."

 

 

 

9 Answers, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 1
answered on 25 Jun 2018, 09:44 AM
I basically trying to achieve a scenario where i am extracting an element. Then verifying the Same content exist on another page grid.
0
Elena
Telerik team
answered on 26 Jun 2018, 11:42 AM
Hi Rahul,

Thank you for reaching us out. 

Please find some additional details on how to get and set extracted variables. Based on the scenario you are trying to build you first need to use SetExtractedValue() and then get that value to verify if it is exist on the next page. 

string extrVar = "";
SetExtractedValue(C2.TextContent.ToString(), extrVar);

That way the string variable extrVar will get the content of C2. 

I hope this is helpful. Please let me know in case of further questions. 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Rahul
Top achievements
Rank 1
answered on 27 Jun 2018, 11:46 AM

Let's breakdown what i am trying to achieve. So, i have put in SetExtractedValue step. But it still showing nothing in logs."ZZ" should be printed in logs,Right??

 HtmlTable T2 = ActiveBrowser.Find.ByXPath<HtmlTable>("//*[@id='SystemClientsGrid']/div[2]/table");
 HtmlTableCell C2 = T2.Find.ByContent<HtmlTableCell>("l:ZZ");
            string str1 = "";
            SetExtractedValue(C2.TextContent.ToString(),str1);
            Log.WriteLine(str1);

Logs are:

'6/27/2018 5:11:24 PM' - Using 'Chrome' version '67.0.3396.99' as default browser. 
'6/27/2018 5:11:31 PM' - 'Pass' : 1. New Coded Step
'6/27/2018 5:11:31 PM' - 'Pass' : 2. New Coded Step
'6/27/2018 5:11:33 PM' - LOG: 
'6/27/2018 5:11:33 PM' - 'Pass' : 3. Click 'NavbarButtonButtonTag'
------------------------------------------------------------
'6/27/2018 5:11:33 PM' - Overall Result: Pass
'6/27/2018 5:11:33 PM' - Duration: [0 min: 9 sec: 444 msec]
------------------------------------------------------------
'6/27/2018 5:11:33 PM' - Test completed!

 

0
Elena
Telerik team
answered on 29 Jun 2018, 08:30 AM
Hi Rahul,

Thank you for the additional details. 

Since i do not have access to your application there are few things I would like you to try. Please insert Assert statements if the table exists and if the table cell exists after the Find statements to locate these: 

Assert.IsNotNull(T2);
 
Assert.IsNotNull(C2);

If these are not null we could proceed with getting the content of the cell. You could try to get the InnerText instead of Text.Content to outpu the cell text. 

Please let me know if this is helpful or if you need further assistance! Thanks! 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Rahul
Top achievements
Rank 1
answered on 29 Jun 2018, 09:29 AM

Hi Elena,

I tried assert.IsNotNull() also. and along with that i print C2.TextContent in logs. It's showing "ZZ".

But still after using setExtracted value, If i print variable "str" it's not showing "ZZ" in logs. SO i think problem lies within that Set Extracted value line of code..(within 2 lines)

string str1 = " ";
            SetExtractedValue(C2.TextContent.ToString(),str1);

Full Code>>>>

            HtmlTable T2 = ActiveBrowser.Find.ByXPath<HtmlTable>("//*[@id='SystemClientsGrid']/div[2]/table");
            Assert.IsNotNull(T2);
            HtmlTableCell C2 = T2.Find.ByContent<HtmlTableCell>("l:ZZ");
            Assert.IsNotNull(C2);
            Log.WriteLine(C2.TextContent);
            string str1 = " ";
            SetExtractedValue(C2.TextContent.ToString(),str1);
            Log.WriteLine(str1);

 

 

Logs>>>>>>

------------------------------------------------------------
------------------------------------------------------------
'6/29/2018 2:46:33 PM' - Using 'Chrome' version '67.0.3396.99' as default browser. 
'6/29/2018 2:46:40 PM' - 'Pass' : 1. New Coded Step
'6/29/2018 2:46:40 PM' - 'Pass' : 2. New Coded Step
'6/29/2018 2:46:43 PM' - LOG: ZZ
'6/29/2018 2:46:43 PM' - LOG:  
'6/29/2018 2:46:43 PM' - 'Pass' : 3. Click 'NavbarButtonButtonTag'
------------------------------------------------------------
'6/29/2018 2:46:43 PM' - Overall Result: Pass
'6/29/2018 2:46:43 PM' - Duration: [0 min: 9 sec: 657 msec]
------------------------------------------------------------
'6/29/2018 2:46:43 PM' - Test completed!

 

 

0
Rahul
Top achievements
Rank 1
answered on 29 Jun 2018, 10:20 AM

Hi Helena,

Can i use line 1 instead of line 2 for saving C2.TextContent in a local variable?? Because i am able to print str1 = ZZ in logs.

line A : string str1 = C2.TextContent.ToString();
line B :  SetExtractedValue(C2.InnerText.ToString(),str1);

If Yes, Then to proceed further. I want to see if str1 value i.e. ZZ exist in a dropdown list on another page. Please guide me how to achieve it via coding.

 

0
Elena
Telerik team
answered on 29 Jun 2018, 02:33 PM
Hello Rahul,

Thank you for getting back. 

I may have mislead you and would like to apologize for that. 

The correct approach is as follows - use SetExtractedValue() to set a value to a variable which will be used later. In the discussed example this will be: 

SetExtractedValue("variableName", C2.TextContent.ToString());
Log.WriteLine(variableName);

This should output ZZ in the log file. 

Then using GetExtractedValue() you could use that variable value to use it in the scenario further. 

GetExtratcedValue("variableName");

Please let me know if this works this time. And excuse me for the misunderstanding once again! 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Rahul
Top achievements
Rank 1
answered on 29 Jun 2018, 03:09 PM

Hi Elena,

Thanks for clearing out this time. Now that i have "ZZ" showing in logs. I want to use that extracted value which i set i.e. "ZZ" & verify if that value exist in a dropdown list containing multiple values.

Could you please provide solution for the same.

0
Elena
Telerik team
answered on 29 Jun 2018, 03:59 PM
Hello Rahul,

I am glad to know we sorted that out. 

To verify if any of the items in a drop down has the same value as the extracted variable you could use a for cycle to iterate through the dropdown items. I am not familiar with the exact control implemented in the application under test and how the items are listed in the html but this should be working for you. 

Though please let me know if you need further assistance. If so it will be nice if you could share a sample app I could use to test against - that way I could provide more exact advice. Thanks! 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Rahul
Top achievements
Rank 1
Answers by
Rahul
Top achievements
Rank 1
Elena
Telerik team
Share this question
or