Move Gherkin's (i.e. Cucumber and Behave) Data Table to JSON - json

I was using Behave and Selenium to test on something that use a large amount of data. Data tables were becoming too big and making the Gherkin documentation unreadable.
I would like to move most of the data from data tables to external file such as JSON. But I couldn't find any examples on websites.

I cannot offer an example at the moment, but I would create the JSON file as needed and give reference to the JSON file in Given or Background , then capture the value in the respective decorated method.

Related

Extract JSON Data From ThingSpeak API

so i want to get the value from one oof my fields in my thingspeak, i'm able to extract data from my channels but i want to get only one specific field
i read the documentation and the api link that looks like this
https://api.thingspeak.com/channels/<channel_id>/feeds.json?results=1
and when i opened the link it showed this
{"channel":{"id":1688112,"name":"ESP8266 - Web Controlled LED","latitude":"0.0","longitude":"0.0","field1":"Command","field2":"Red LED","field3":"Green LED","field4":"Blue Led","created_at":"2022-03-29T00:36:06Z","updated_at":"2022-04-06T03:12:36Z","last_entry_id":443},"feeds":[{"created_at":"2022-04-10T07:06:01Z","entry_id":443,"field1":null,"field2":"0","field3":"0","field4":"0"}]}
so my question is how do i extract the data for example from my field2 data where "field2":"0"?
i want to use it for my project in my html where later it can do some functions in my content.
thanks!
It really depends on the program you use.
But usually you find a JSON library to be installed in your IDE.
With it you extract any field from the JSON file

Converting nested JSON response to a CSV table

I am testing APIs on a locally run service using Postman. I am getting a large nested response as JSON. But I am required to produce a CSV file with the data in tables. i.e., keys as column names and the values as separate rows into the tables
An offline solution for needed, for privacy and confidentiality reasons.
First I came across this solution: postman saveResponseToFile template
A template of postman that sends the requests to a node server running locally which in turn saves the JSON to a CSV.
But all this does is save each line into a separate cell horizontally across the CSV. Not of much use for readability.
Desired Output
The needed table is something like what this online tool does:
ConvertCSV
This takes the keys as column names and creates new rows for each nested data.
Is there a OSS script that can accomplish this. Sorry if this is a duplicate. I haven't found a proper one after trying more similar scripts similar to the first.

Visualize csv file data at Node-RED UI

I would like to visualize data from csv file at node-red ui.
What I would like to do is to show behind a flag of a country the countity from the csv file. So into the csv file I have 2 columns (country, quantity).
Because of I am new at node-red I would like to get some hints how to do that.
Thanks in advance.
my flow with CSV data
Welcome to Node-RED!
Firstly you need to decide what kind of UI you would like. Node-RED has options for a number ranging from the creation of data driven web pages using the http-in/out and template nodes through the more dynamic but slightly more complex Dashboard through to full-power dynamic web-apps using things like node-red-contrib-uibuilder.
The very simplest approach is to use an http-in and an http-out node to define a web page. Then to add your file reader after the http-in then the CSV node (which turns the CSV data into JSON). Then you could use node-red-contrib-tableify to turn your JSON into an HTML table. Finally use the template node to insert the table into the html that the http-out node sends back to the browser.
http-in -> file read -> csv -> tablify -> template -> http-out
Once you've mastered that, you could go on either to smarten up the template or swap to using Dashboard or even uibuilder depending on your needs.
I have to create a web page first, right?
You define the URL in the http-in node. When the -in is connected to the -out, you have a "page". Albeit with no content. To create content you can use the template node. In fact, pushing the csv data through the tablify node and into the template would give you enough of a page to see the data. The templatate itself need only be:
<pre>{{payload}}</pre>
Though, of course, you can also wrap that with other HTML elements as needed. But that alone should be enough to render something useful.
How can I trigger the http-in?
You simply reference the URL from your browser. So if you set the http-in node to use URL /fred and you used a browser on the same device that is running Node-RED, you would use the URL http://localhost:1880/fred in your browser.
How should I design the web page to be able to put the information from the csv file into it by the http-out node?
The tablify node does that for you.
String together what I've outlined and you should see something that will let you go further.
I suggest just using http-in, template and http-out nodes to start so that you can see how they work together. Then feed in your data without the csv or tablify nodes, then add the csv and finally the tablify. That way you can see how things work.

how to retrieve the data from xml and display it in table in html

I wanted to develop a small search website where I will be storing the data in XML files. When we search anything, it should display those data as table format in html. How does one retrieve the data from XML files?
Below is the basic thing to display data of only two columns, but I want to display data dynamically:
html file:http://www.w3schools.com/xml/xml_applications.asp
This is the sample code for retrieving the data from xml only for two columns.
Well the first problem I see is that you have two functions in there that are not being called. Nothing programmatic will happen in this scenario. When you have a method you need to call said method with myFunction(). I would recommend reading up a little more on javascript instead of copying and pasting it and expecting it to just "work"
To further elaborate, you removed the function call from the example you took when you took off the button. What is your xml endpoint? (it's not going to be the same as the example unless you build it to be that way). In this example it's just an xml file that is hosted on the server with the same root as the html.

Import.io to extract data from URL with json

This is an example of the URL, there are multiple I want to extract.
http://www.walgreens.com/svc/products/search/?requestType=loyalty
How can I train the extractor to put the json in rows and columns? I can only get it to highlight the entire data and import.io puts it all on one row.
I want to use the URL with json as the full web page is loaded with javascript and doesn't train properly.
You can use xpath to do this. Which ones are you actually looking to scrape? However, it seems that the data are on several different json objects. i.e. products, refinements, etc.
So if you're going to scrape everything, you'd need to create different extractors for the different json objects. But there might be a better way.