Currently I will want to add one or any
actins which will enable me to simulate the loop [for(i=0;i<7;i++)] as in
java, c++, python........ If somebody has an idea on that which there does
not exist. Or if that were already done I will even like how it is
done ?
You can place the code below into your
user-extensions.js file. If you don't have that file, just create it in
the selenium directory (selenium will load it at startup, if it exists). A
couple of points to note:
1 - This is not supported by anyone - not even
me.
2 - It uses internals which could change in a
newer version of selenium (e.g. currentCommandRow)
|
usrWhile| | ${Counter} < 5| |
|
<do your stuff here>
| |
store| | _javascript_{parseInt(storedVars['Counter'])+1}| | Counter |
usrEndWhile | |
|
Code
Selenium.prototype.doUsrWhile=function(sExpression)
{
var oWhile = inputTable.rows[currentCommandRow].oWhile;
if(!oWhile)
{
var oWhile =
usrParseWhileBlock(sExpression);
if(!oWhile.parsedOK)
{
Assert.fail("While: invalid while
construct.");
return;
}
}
var nextRowIndex =
currentCommandRow;
var res = usrEval(sExpression);
if(!res)
{
nextRowIndex =
oWhile.endRow.rowIndex;
}
currentCommandRow = nextRowIndex;
};
function
usrParseWhileBlock(sExpression)
{
var rows =
inputTable.rows;
var nFromRow = currentCommandRow;
var c =
rows.length;
var oThing = new Object();
oThing.expressionResult = usrEval(sExpression);
oThing.parsedOK = false;
oThing.bFoundEndRow = false;
oThing.endRow = rows[c-1]; // if not overridden,
last row of inputTable
oThing.whileRow =
rows[currentCommandRow];
for(var i = nFromRow+1; i < c;
i++)
{
var cells =
rows[i].cells;
switch(cells[0].firstChild.nodeValue)
{
case "usrEndWhile"
:
oThing.bFoundEndRow =
true;
oThing.endRow =
rows[i];
// drop
through...
case "usrExitWhile"
:
rows[i].oWhile =
oThing;
break;
}
if(oThing.bFoundEndRow)
break;
}
oThing.parsedOK = oThing.bFoundEndRow;
return
oThing;
}
function usrEval(s)
{
var res = null;
if(s == "")
return res;
try { res = eval(s);
}
catch(e) { res = s; }
return
res;
}
_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users