I'm using some test extensions for Selenium in user-extensions.js to
wait for an ajax request return, like these:
Selenium.prototype.setTimeout = function(timeout, waitFunction) {
if (isNaN(timeout)) {
throw new SeleniumError("Timeout is not a number: " + timeout);
}
testLoop.waitForCondition = waitFunction;
testLoop.waitForConditionStart = new Date().getTime();
testLoop.waitForConditionTimeout = timeout;
testLoop.pollUntilConditionIsTrue = function() {
try {
if (this.waitForCondition()) {
this.waitForCondition = null;
this.waitForConditionStart = null;
this.waitForConditionTimeout = null;
this.continueCommandExecutionWithDelay();
}
else {
if (this.waitForConditionTimeout != null) {
var now = new Date();
if ((now - this.waitForConditionStart) >
this.waitForConditionTimeout) {
throw new SeleniumError("Timed out after " +
this.waitForConditionTimeout + "ms");
}
}
window.setTimeout("testLoop.pollUntilConditionIsTrue()", 10);
}
}
catch (e) {
var lastResult = new CommandResult();
lastResult.failed = true;
lastResult.failureMessage = e.message;
this.commandComplete(lastResult);
this.testComplete();
}
};
};
Selenium.prototype.doWaitUntilVisible = function(locator, timeout) {
var p = this.page();
var f = function () {
try {
var element = p.findElement(locator);
return true;
}
catch (e) {
return false;
}
};
Selenium.prototype.setTimeout(timeout, f);
};
Selenium.prototype.doWaitForCondition = function(script, timeout) {
var f = function () {
return eval(script);
};
Selenium.prototype.setTimeout(timeout, f);
};
Right now, the "waitUntilVisible" Selenium action works great. It can be
used after an AjaxSubmit click to wait for a new component to appear on
the page.
The problem is, that only works for components that *appear* as new in
the page. Is there any dojo "flag" I could use as a return condition
instead of:
try {
var element = p.findElement(locator);
return true;
}
catch (e) {
return false;
}
??
Or maybe a tacos flag ? I'm looking for something that is true during
the ajax request, but is false immediately after.
--
Ing. Leonardo Quijano Vincenzi
DTQ Software
Web Application Design and Programming
http://www.dtqsoftware.com
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Tacos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tacos-devel