How to get the result after each test case instead of logging the results into a file? - selenium

I'm using PHPUnit Selenium.
Is it possible to get the results of the test case in a json format or something and store it into a variable instead of logging it into a file? I don't want to read from a file.
For example, I run the test case testAsdf2. After the test case, i would like to get the results similar to the one below and store it into a variable and insert the results into a database
Is it possible to do that?
{"event":"test","suite":"JsonTest","test":"JsonTest::testAsdf2","status":"error","time":10.839267015457,"trace":[],"message":"\nInvalid response while accessing the Selenium Server at 'http:\/\/localhost:4444\/selenium-server\/driver\/': ERROR: Element id=asdfasfe not found","output":""}

Related

How to save result from OS Process Sampler to a variable?

JMeter OS Process Sampler is set up, works fine and saves result (a token as result of powershell srcipt execution) to a file.
Is it possible somehow to save result from powershell script directly into a JMeter variable instead?
What should I add for that?
Normally you should be using JMeter Post-Processors in order to extract data from Sampler's responses
If the token is the only thing that your powershell script returns you can extract it using i.e. Boundary Extractor, just provide desired variable name and leave everything else empty
Demo:
If there is some other text surrounding the token - adjust the boundaries accordingly or go for Regular Expression Extractor

How to run a TestCafe test with CLI that contains a metadata array

I have a test with the following metadata:
test.meta({ type: 'smoke', testcase: ['tc01', 'tc02'] });
The testcase metadata contains an array of id's that I would like to use them as filter for running the test using any of the values using the command line interface:
testcafe --test-meta testcase=tc01
testcafe --test-meta testcase=tc02
These two command lines should run the same test, however they don't work. Is there another way to approach to this solution?
Reading this discussion on TestCafe's github page, it seems that metadata has to be only single value strings: https://github.com/DevExpress/testcafe/issues/3267 The issue is then closed and the last explanation was that such a feature request is not very clear because:
In addition, the particular case you are addressing is a bit tricky, what will be the user expected behaviour?, To match only when the array has all the passed values? or when the array is equal to that values (ie: don't have any extra one)?.
Such an option is not mentioned in the official documentation either: https://devexpress.github.io/testcafe/documentation/guides/basic-guides/organize-tests.html#specify-test-metadata
That leads me to believe you can't really achive what you're asking for as of June 2020.

Jmeter: validating Code in Beanshell Sampler

Here is the simple code
vars.put("str" , "${__time(dd/mm/yyyy HH:MM:SS)}");
log.info("${str}");
I am expecting to see the value of str in logs but I am getting ${str}. I am validating it because I have to assign the current time to a variable and later want to use it in script. But I am not getting the value stored in str.
try as follows using vars.get:
vars.put("str" , "${__time(dd/mm/yyyy HH:MM:SS)}");
log.info("str " + vars.get("str"));
I wouldn't recommend inlining functions and/or variables into Beanshell script as you may face syntax error issues, i.e. type mismatch if the value has quotation marks.
So either use log.info(vars.get("str")); or use Debug Sampler and View Results Tree listener combination to see JMeter variables values.
More information: How to Debug your Apache JMeter Script

BeanShell PreProcessor updates User define variables

I'm very new at JMeter issues.
In a test script i have a BeanShell PreProcessor element that updates some variables previously defined at a "User Defined Variables" element.
Latter those variables are used in "Http Requests". However, the value that is used in the http request is the default one.
The scripts seems to be working due to some debug print();
My question is if it's necessary to delay the script to be sure that the BeanShell finishes?
Thanks a lot for your attention
There is no need to put any delay to Beanshell Pre-Processor as it's being executed before request. I'd recommend to check your jmeter.log file to see if there are any scripting issues as Beanshell Pre-Processor does not report errors anywhere including View Results Tree listener.
There are at least 2 ways to assure that everything is fine with your Beanshell script:
Put your debug print code after variables replace logic to see if it fires
Use JMeter __Beahshell function right in your HTTP request. If it's ok - View Results Tree will demonstrate beanshell-generated value. If not - the field will be blank and relevant error will be displayed in the log.
Example test case:
Given following Test Plan structure:
Thread Group with 1 user and 1 loop
HTTP GET Request to google.com with path of / and parameter q
If you provide as parameter "q" following beanshell function:
${__BeanShell(System.currentTimeMillis())}
and look into View Results Tree "Request" tab you should see something like:
GET http://www.google.com/?q=1385206045832
and if you change function to something incorrect like:
${__BeanShell(Something.incorrect())}
you'll see a blank request.
The correct way of changing existing variable (or creating new if variable doesn't exist) looks like
vars.put("variablename", "variablevalue");
*Important: * JMeter Variables are Java Strings, if you're trying to set something else (date, integer, whatever) to JMeter Variable you need to cast it to String somehow.
Example:
int i = 5;
vars.put("int_i", String.valueOf(i));
Hope this helps.
You can update the vale of a "user defined variable".
You have to create a bean shell sampler
vars.put("user_defined_variable", "newvalue");
#theINtoy got it right.
http://www.blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell
I'm new to jmeter too but as I know variables defined in "User defined variables" are constants, so you can't change them. I recommend to use "User Parameters" in preprocessors or CSV Data Set Config.

Selenium IDE Issue In Export Result

I have created one function in .JS file, using which I calculate the response time of login functionality, it's working fine, the log is also showing the response time correctly. But when I am exporting the Test result and open it in Firefox, its showing me all the steps as pass but not showing the calculated time. Its only showing the variable in which I store the calculated time not its value whereas the log is displaying them.
You should print the calculated result by using echo command.The variable which is printed by echo function must be like this format:
Command = echo,
Target = ${printedVal}