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

HTML Table data extraction

8 Answers 346 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mercedes
Top achievements
Rank 1
Mercedes asked on 14 Jan 2014, 02:17 PM
Hi,
      I have a HTML table that i need to extract data from. The table does not have a fixed set of rows and columns. Depending on the input entered by the user, the results in the table varies from a single row-single column to at least 2 rows and 3 columns. I will need to extract data from one of these columns. Please advise how to proceed.

Thank you,

8 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 2
answered on 14 Jan 2014, 02:47 PM
Which column, if it existed, would you be extracting from?
0
Mercedes
Top achievements
Rank 1
answered on 14 Jan 2014, 02:59 PM
In the screenshots i attached, the lower one says "No Surcharges found". I will need to extract that and If instead i see the first screenshot, i will need to extract the value in the 3rd column (which is the amount associated)
0
Mercedes
Top achievements
Rank 1
answered on 14 Jan 2014, 04:11 PM
I think we found a way for this, We used Verify Exists and then extracted the values conditionally. Thanks for the help.
0
Daniel
Top achievements
Rank 2
answered on 14 Jan 2014, 07:38 PM
Glad you found your answer.  Sorry I wasn't able to respond quick enough.  Have a good one.
0
Boyan Boev
Telerik team
answered on 15 Jan 2014, 04:09 PM
Hi Brian,

We are glad that you have found a solution.

If you need additional assistance, please do not hesitate to contact us.

Regards,
Boyan Boev
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Sam
Top achievements
Rank 1
answered on 28 May 2014, 07:37 PM
Question: How do I extract a value from the Session Data then save it into Local Data or some kind of excel file/csv/txt?

I was not quite clear on how to approach this prior...I am attempting to extract a value ("rx_id":23624 the numeric value) from the page source array. Then place it into either some kinda of local data or export and excel file.


I found this script for a coded extraction...

Get/Set Extracted Variables in Code
PROBLEM
I extracted a variable in a test step. I would like to do something with that data in a coded step.

SOLUTION
Use the GetExtractedValue() function:

//object myData = GetExtractedValue("varname");



So I changed it to the following (note I am not a programmer so if you need something else, let me know)...

var step_data = GetExtractedValue("rx_id");



Now...is that saving it correctly? (if so) how can I now export that
value to a excel or local data so I can run all my tests...it saves the
RX_ID (which is unique for each test) and place that into some file we
can refer back to for a report.


Any thoughts?
0
Sam
Top achievements
Rank 1
answered on 29 May 2014, 02:28 PM
Sorry re commenting so i can track this.
0
Boyan Boev
Telerik team
answered on 02 Jun 2014, 11:43 AM
Hello Sam,

Thank you for contacting us.

Please elaborate a bit more what exactly do you want to store in a variable?

Unfortunately script tag is a special html element which has no ID, no attributes which we use to locate the the elements. The only way to locate this element is via tagIndex (i.e. the first or second, etc  script element on the page). 

You can also store the entire text within this script tag, not only the second row.

First you should find this script like this:

Element script = ActiveBrowser.Find.ByExpression("tagName=script", "tagIndex=script:5");

It will find the 6th script tag on the page for example.

Then you should save its text into a variable:

string scriptText = script.InnerText;
SetExtractedValue("variableName", scriptText);

Here is how you can use it:

GetExtractedValue("variableName");

Hope to this helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Mercedes
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 2
Mercedes
Top achievements
Rank 1
Boyan Boev
Telerik team
Sam
Top achievements
Rank 1
Share this question
or