samples/pantheon.js
function doProductPage(product) {
	let res = http.get(product.url);
	check(res, {
		"title is correct": (res) => res.html("title").text() == product.title,
	});
	if (Math.random() <= product.chance) {
		let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
		let formID = res.body.match('name="form_id" value="(.*)"')[1];
		let formToken = res.body.match('name="form_token" value="(.*)"')[1];
		let productID = res.body.match('name="product_id" value="(.*)"')[1];
		group("add to cart", function() { 
			addProductToCart(product.url, productID, formID, formBuildID, formToken)
		});
	}
}
function doProductPage(product) {
	let res = http.get(product.url);
	check(res, {
		"title is correct": (res) => res.html("title").text() == product.title,
	});
	if (Math.random() <= product.chance) {
		let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
		let formID = res.body.match('name="form_id" value="(.*)"')[1];
		let formToken = res.body.match('name="form_token" value="(.*)"')[1];
		let productID = res.body.match('name="product_id" value="(.*)"')[1];
		group("add to cart", function() { 
			addProductToCart(product.url, productID, formID, formBuildID, formToken)
		});
	}
}
function doProductPage ( product ) { let res = http . get ( product . url ) ; check ( res , { "title is correct" : ( res ) => res . html ( "title" ) . text ( ) == product . title , } ) ; if ( Math . random ( ) <= product . chance ) { let formBuildID = res . body . match ( 'name="form_build_id" value="(.*)"' ) [ 1 ] ; let formID = res . body . match ( 'name="form_id" value="(.*)"' ) [ 1 ] ; let formToken = res . body . match ( 'name="form_token" value="(.*)"' ) [ 1 ] ; let productID = res . body . match ( 'name="product_id" value="(.*)"' ) [ 1 ] ; group ( "add to cart" , function ( ) { addProductToCart ( product . url , productID , formID , formBuildID , formToken ) } ) ; } }
Load product page and potentially add product to cart
Load product page and potentially add product to cart