Postman test doesn't work after console log - postman

As a newbie in Postman, I'm a bit confused trying to log the test step.
When console.log is commented - the test works fine:
But when I use console.log, it goes through all iterations, prints the value but falls on the next step
Any thoughts appreciated!

try to loop through the JsonData array and access to the key value "symbol" by using forEach. It will probably solve your issue.
Ex:
JsonData.forEach(element){
console.log(element.symbol)
};
then you can push the element to the array called "a".

Related

Postman - how to target the final iteration?

I would like to run a Postman test on just the final iteration of a test run - I am building a variable (array) of response time values across all of the iterations and then want to test this variable for extreme values once we've reached the last / final iteration.
I hoped pm.info.iteration would have my answer but didn't see anything relevant.
I'm using a data file - the test runner highlights how many iterations are applicable (rows in the csv) as soon as the file is chosen so I'm guessing that Postman does know 'final' iteration? I just haven't worked out how to get at it.
My workaround is to hard code the number of iterations per test run based on how many rows my csvs currently have (e.g. if(pm.iteration.info === 70) but not ideal as the data file is likely to grow.
As #DannyDainton mentioned you can use iterationCOunt
iteration index starts from 0 ,so use
(pm.info.iteration === (pm.info.iterationCount-1) )

Is there any way to get value from specified position From List variable Automation Anywhere?

I want to get a value from particular location from list variable. Right now what i see is it only uses loop to iterate over in Automation anywhere.
SO is there any way to get value from a specified location?
For now, this is your only option to get a value from a specific location/index on a list.
I hope that Automation Anywhere includes a command/option to do that in the next release(s).
Unfortunately you'll have to loop over the list, and have a counter variable to get the item on the position you want.
After that you exit the loop. Not very efficient, but I just had to do it today :(
You can directly access the list elements, you can modify and delete them directly much easier and quicker in G1ANT software, even without executing the loop.
Here is the sample code:
♥list = Adam❚Eva❚John❚Mary
♥list⟦1⟧ = Peter
dialog ♥list
♥list⟦⟧ = 200
♥list⟦5⟧ = ♥list⟦5⟧+10
dialog ♥list
Enjoy!

Is there a way to access the iteration number in Postman REST Client?

I'm using postman for API testing. I'm running a large number of tests and I want to print the iteration number to the console on some of them. Is there a way to get the iteration number as an environment-like variable?
According to Postman API Reference, pm.info.iteration - is the value of the current iteration being run.
Example:
console.log(pm.info.iteration);
It is possible now! You can access the iteration variable, in the same way you access other variables like responseBody.
I don't know if there is an internal way to get the iteration number but I believe you should be able to track this number through code yourself. Here's a quick code snippet:
var value = environment.count;
value++;
postman.setEnvironmentVariable("count", value);
If you put this in the pre-request editor or the test editor of a collection that you are sure will run once per iteration it will effectively track the iteration count.
You can get the iteration number with
pm.info.iteration:Number
Is the value of the current iteration being run.
Postman Sandbox API reference
I got there like this:
const count = pm.info.iteration+1
console.log("======== LITERATION "+count+" ========");

PigUnit test failed due to brackets and comma's

I am trying to create a PIG script which changes the order of the columns. This is what I have come up with so far :
inputdata = LOAD 'path/to/file/on/hdfs' USING PigStorage() AS (param1:chararray, param2:chararray, param3:chararray);
outputdata = FOREACH inputdata GENERATE param1, param3, param2;
DUMP outputdata;
I've not tried this yet on HDFS but I figured I'd go ahead and write the unit test first. Unfortunately it doesn't work.
Unit Test code :
PigTest test = new PigTest("path_to_script.pig");
FixHadoopOnWindows.runFix();
String[] input = {
"valueparam1\tvalueparam2\tvalueparam3"
};
String[] output = {
"valueparam1\tvalueparam3\tvalueparam2"
};
test.assertOutput("inputdata", input, "outputdata", output);
The FixHadoopOnWindows bit is a fix so I can run my unit tests on a windows machine easily. I found it in some blog and it helped resolve the permission issues I was having.
So now my tests run, but the problem is that the assertOutput fails. When I check the difference, I get this:
Expected:
valueparam1 valueparam3 valueparam2
Actual:
(valueparam1,valueparam3,valueparam2)
So I'm getting these brackets and comma's I never asked for. Now I'm not sure whether this is a bug in my unit testing code or in my actual script so any advice to get me started would be great. Thanks.
Your code looks ok. The brackets mean that your relation outputdata consists of a tuple with three values.
If you later want to store your data separated by tabs just do STORE outputdata INTO 'dest' USING PigStorage('\t');
http://pig.apache.org/docs/r0.11.0/basic.html#Data+Types+and+More
Figured it out. The PigUnit reads out the outputdata value, which is a Tuple in PIG. It's not until I store it to file, that the tuples are converted to a tab separated record.

Xlrd list index out of range

I'm just starting to explore Xlrd, and to be honest am pretty new to programming altogether, and have been working through some of their simple examples, and can't get this simple code to work:
import xlrd
book=open_workbook('C:\\Users\\M\\Documents\\trial.xlsx')
sheet=book.sheet_by_index(1)
cell=sheet.cell(0,0)
print cell
I get an error: list index out of range (referring to the 2nd to last bit of code)
I cut and pasted most of the code from the pdf...any help?
You say:
I get an error: list index out of range (referring to the 2nd to last
bit of code)
I doubt it. How many sheets are there in the file? I suspect that there is only one sheet. Indexing in Python starts from 0, not 1. Please edit your question to show the full traceback and the full error message. I suspect that it will show that the IndexError occurs in the 3rd-last line:
sheet=book.sheet_by_index(1)
I would play around with it in the console.
Execute each statement one at a time and then view the result of each. The sheet indexes count from 0, so if you only have one worksheet then you're asking for the second one, and that will give you a list index out of range error.
Another thing that you might be missing is that not all cells exist if they don't have data in them. Some do, but some don't. Basically, the cells that exist from xlrd's standpoint are the ones in the matrix nrows x ncols.
Another thing is that if you actually want the values out of the cells, use the cell_value method. That will return you either a string or a float.
Side note, you could write your path like so: 'C:/Users/M/Documents/trial.xlsx'. Python will handle the / vs \ on the backend perfectly and you won't have to screw around with escape characters.