Greasemonkeyは、load testing web pages/servers/appsに最適なツールではありません。
しかし、ここでは繰り返しページをロードし、要素をチェックするスクリプトです:
// ==UserScript==
// @include http://xyz.co.in/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==
$(document).ready (Greasemonkey_main);
function Greasemonkey_main()
{
do
{
var TargetNode = $("#TargetNode"); //-- Look for node with id, "TargetNode".
if (TargetNode && TargetNode.length)
{
//--- Maybe also check contents:
if (/Node contents to search for/i.test (TargetNode.text()))
{
alert ("We found what we're looking for");
break;
}
}
//--- Failsafe check on number of reloads
var NumReloads = parseInt (document.location.search.replace (/.*num_gm_reloads=(\d+).*/, "$1"))
if (NumReloads > 2)
{
alert ("After 2 reloads, we still didn't find what we were looking for.");
break;
}
//--- We neither found the stop code nor exhausted our retries, so reload the page.
if (NumReloads)
NumReloads++;
else
NumReloads = 1;
var TargetURL = window.location.href;
//--- Strip old URL param, if any. Note that it will always be at the end.
TargetURL = TargetURL.replace (/(.*?)(?:\?|&)?num_gm_reloads=\d+(.*)/, "$1$2");
var ParamSep = /\?/.test (TargetURL) ? "&" : "?";
TargetURL = TargetURL + ParamSep + 'num_gm_reloads=' + NumReloads;
window.location.href = TargetURL; //-- Reload the page.
} while (0)
}
助けてくれてありがとう!それはセレニウム(FFアドオン)がそのようなテストを行うための最良のツールであることが判明しました。 – Ravikiran