That's something I've always wanted to add, but never got the time...

My idea is an extension of this - it combines polling and assertions
in a single command, but it also has a maxWait duration, after which the
assertion would fail. The maxWait could be defined in user-extensions.js, 
since you cannot pass many params from the tests.

We would then have:
pause '2000', assertTextPresent 'Value:1' -> waitAndAssertTextPresent 'Value:1'
pause '2000', verifyVisible 'autoId' -> waitAndAssertVisible 'autoId'

Another idea is to replace pause '2000' with a new waitForAjaxResponse
that:
- Adds a boolean responseArrived=false;
- Intercepts tacos.responseComplete to add code that makes
responseArrived=true
- Calls Selenium's doWaitForCondition('responseArrived==true')

I like this last solution. I would just use a custom doWaitForCondition
that also has the maxWait logic.



>From Leonardo Quijano Vincenzi <[EMAIL PROTECTED]>:

> 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
> 


-- 




-------------------------------------------------------
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

Reply via email to