How to iterate multiple times until get expected response text in jmeter - jmeter

I have used below code inside while controller but not working. Any one help me on that please
${__javaScript("${textcheck1}".indexOf("Message") == -1
&& !(("${textcheck2}".indexOf("Message1") == -1),))}
Thanks,
Yazhu

It's "not working" due to a syntax error which is because of unbalanced parentheses.
The valid syntax would be something like:
${__javaScript("${textcheck1}".indexOf("Message") == -1 && !(("${textcheck2}".indexOf("Message1") == -1)),)}
however I'm not sure that it will "work" as well because I don't know what you're trying to achieve.
Going forward I would recommend creating functions using The Functions Helper Dialog and looking at jmeter.log file if anything is "not working" first.
Also as per __javaScript() function documentation
javaScript is not the best scripting language for performances in JMeter. If your plan requires a high number of threads it is advised to use __jexl3 or __groovy functions.
Check out Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter.

Related

Jmeter BackendListener: How to use runtime variables

Trying to use BackendListener and observed runtime variables are not written to influxDB.
Predefined variables and properties, on the other hand, can be written to influx.
So I can separate test results by some ID by setting measurement=${__P(SOME_ID)}
What I'm looking for is a splitting results by thread group name, as I may have up to several dozens of them within the same test.
Tried to use following:
TAG_scenarioName=${__threadGroupName}
TAG_someJmeterVar=${SOME_JMETER_VAR}
TAG_someJmeterVarAsGroovy=${__groovy(vars.get("SOME_JMETER_VAR"),)}
eventTags=${__threadGroupName} testTitle=${__threadGroupName} (this
one makes less sense, but still..)
and none of those works
Those are works:
- TAG_injectorName=${__machineName()}
- TAG_predefinedVar=${USER_DEFINED_VAR} (I believe this is thanks to this)
So as I understand problem is with runtime variables only. Is it possible to make runtime variables accessible for the BackendListener? Or maybe there is some workaround for such case?
p.s. opened an enh for this
Based on your inputs. Please try with "sample variables"
These are defined in user.properties like:-
sample_variables=FileName,retHREF,PageID,Redirect,StatusCode
So, put all your variables in the sample_variables, restart jmeter and try. Please check if this helps.
This is not possible as of JMeter 5.1.1 (last version at time of this answer).
It's a feature request which is not implemented yet:
https://bz.apache.org/bugzilla/show_bug.cgi?id=57962

JMeter - Stop Thread from within a BeanShell PreProcessor

Is it possible to stop a Thread, or force a failure from within a BeanShell PreProcessor? I tried accessing the "stop()" function/method from the ThreadGroup Class and a few others, but I'm not sure I'm doing it right or if its possible.
I wanted to force my Test to stop inside my BeanShell PreProcessor if this one particular if statement inside my script resulted in TRUE... Is this possible? I did read a little of the "Failure" and "FailureMessage" functions, but wasn't sure the end result of using those was.
Any thoughts or suggestion would be greatly appreciated!
Thanks in Advance,
Matt
In a beanshell pre processor, you could try this:
org.apache.jmeter.engine.StandardJMeterEngine.stopThread(Thread.currentThread().getName());
In a beanshell post processor:
if (condition) prev.setStopThread(true);
If you can express your condition as an if-controller though, I would prefer to use a Test Action.

How to embed ruby variables in cucumber.feature tests

I have following cucumber test
Scenario Outline:
Given site <url> is available
Then I see all all content
Examples:
|url|
|"google.com|
In the test case is dynamic and is generated in ruby code.
Problem:
I want to replace google.com with a ruby variable e.g., <%URL%>. Is that possible to embed ruby code in cucumber tests and evaluate ?
I think you should not do that on the feature steps. If you need a ruby variable here it means that you are doing something wrong. Check some examples around
Link here
The features should be clear text so anyone can read, specially non-programmers. so that is why you should now start mixing code with features. The code goes behind, in your step definition.
You can eval this string it if you trust code in this feature file. But it may be a bad idea for the reasons outlined by #SnakeSanders.

Show number of assertions in RSpec output?

By default, RSpec's output ends with something like
14 examples, 0 failures
Is it possible to show the number of assertions made along with this stat, similar to what other libraries provide?
There's no support for that. If you're interested in it, please feel free to submit a feature request at https://github.com/rspec/rspec-core/issues.
It's a good habit to have only one assertion per example spec.

how to inspect objects while debugging groovy (eclipse plugin or other)

I have started to learn groovy by building a pet project. I fetch some html with XmlSlurper and parse it etc. I am using eclipse3.4 with groovy 1.6 plugin. I am having a very difficult time trying to iterate thorugh all the html elements etc. I expected to set some breakpoint, inspect the current variable where my contents are, see what it contains, what do I have to iterate over, evaluate some expressions etc etc.
But I almost cannot do anything like that:
- some variables don't appear in the variables view (maybe its the ones not having a type?)
- select any expression but you cannot evaluate
- and worst of all (for me) is that any variable is shown with all its groovy stuff (metaclass, value...). The things that most of the time will interest the developer are buried inside the hierarchy and very difficult to find.
I had thougth that the ObjectExplorer mentioned in the doco would be able to help but I was unable to get it running with my script.
What do people use for this sort of thing while developing in groovy?
Option 1:
Give following a try in your script
groovy.inspect.swingui.ObjectBrowser.inspect(object)
This gives all public fields, properties, methods, etc
Option 2:
You can also use obj.dump() and or object.inspect() method to see values of the object
e.g. println obj.inspect() or assert obj.inspect() == "some values"
Other options:
Eclipse 3.4 debug perspective works pretty well. Even the one without type information show up. Can you give specific problem that you are facing with debugging in 3.4
println variables
Writing Unit test with asserts regarding expected output of the xml

Resources