I want to check if title = google if yes then hit yahoo.com else do nothing
could anyone please help with this. I am new to Jmeter.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityI want to check if title = google if yes then hit yahoo.com else do nothing
could anyone please help with this. I am new to Jmeter.
First use the xpath extractor and extract the string from title the xpath would be //title Give the reference name say "t" and default as "Not Found"
Next use in the if controller give condition as "${t}" == "Google" add a sampler in it which hits yahoo.com.(Make sure you use https in protocol inside sampler)
Add a View Results Tree in the Thread Group
Run the plan
You should get 2 HTTP Requests made now make the condition in IF as "${t}" == "Facebook" Run the plan You will get only 1 HTTP Requests made Because the If condition failed.
Add a Regular Expression Extractor as a child of the request which hits Google and configure it as follows:
title
<title>(.+?)</title>
$1$
Add If Controller at the same level as request hitting Google lives and use the following expression
"${title}"=="Google"
Using XPath Extractor is not very recommended as it builds entire DOM tree in memory for locating a single word, it is not very efficient and may cause performance overhead or even out of memory errors in case of immense loads.
So use Regular Expression Extractor where possible and consider XPath or CSS extractors only if you have to deal with complex multiline DOM which may change.
For other recommendations on JMeter usage and fine tuning see JMeter Performance and Tuning Tips guide.
The jMeter Web Driver Sampler plugin describes a situation like this:
Example code:
WDS.browser.get('http://google.com')
if(WDS.browser.getTitle() == 'Google') {
WDS.browser.get('http://yahoo.com')
}