18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

wait until ajax response

simbo1905simbo1905 Members
edited November -1 in Sahi - Open Source
I have looked at the conditional wait but it seems a bit hard to know exactly what the ajax update will do to dom. Is their on way of saying "wait utill the next ajax response"?

Comments

  • narayannarayan Administrators
    Sahi automatically waits between steps. You should ideally never have to use that conditional wait. During your trial, did Sahi fail at any point because of not waiting?
  • Yes the script fails as it runs at very high speed faster than the server can respond without waits. The application is written using the ZK AJAX framework. If I step though the script it all works fine. Some of the steps take the server several seconds so the fact that sahi runs each step immediately means that the script always fails without the waits.

    Guessing a large enough wait makes the script very slow so I am going to put in conditional waits. That effectively means that I have to extensively manually edit the script to work out the conditions for each wait. This is why I would like Sahi it to "wait until after the next ajax response processing has finished".
  • If I look at sahi.co.in/w/browser-action-apis then I cannot see _byId documented which is used in the _wait example. Where is the documentation for this function and alternatives that I might use in the wait conditional?
  • narayannarayan Administrators
    Hi,

    Don't add conditional waits yet. Instead, open sahi.properties and tweak these values:

    #Number of retries once an error occurs
    script.max_reattempts_on_error=10

    #Number of cycles Sahi will wait for the page to load before it proceeds with execution
    #Time spent is (script.max_cycles_for_page_load x script.time_between_steps) milliseconds
    script.max_cycles_for_page_load=1500

    Let us know if this helps.

    Regards,
    Narayan
  • Those settings do slow the script down. They don't solve the issue though. The issue is that the script just runs on without the server being able to respond until some much later step when the script fails as the UI has not been updated by the sequence of ajax responses that have yet to come back from the server.

    If there was a way of saying 'wait until any ajax response comes back' then the script would wait until the server had acknowledged the last action.
  • narayannarayan Administrators
    Simbo,

    Sahi also waits for AJAX requests automatically, but it has a timeout. Let me check and let you know if that can be modified.

    Meanwhile, there is a new version of Sahi, released today, which helps load ZK pages much faster because it uses gzip compression while fetching pages. Please check if it helps you resolve this issue.

    Regards,
    Narayan
  • I used the new build 2009-02-08 and have the same issues.

    Is the expected behaviour the ajax timeout that you mention that the script moves onto the next step which is what I am seeing?

    If you private message me your email address I can send you some ZK code with a Thread.sleep(BIG_TIME) on the server that demonstrate the problem.
  • any advance on why things don't work automatically with the ajax framework I am using? I am happy send you running sample code to show you the exact issue.
  • narayannarayan Administrators
    Simbo,

    Does Sahi fail for every AJAX request for you? Is there a place which is extraordinarily slow which is failing? We have tested on the ZK demo pages and things work without any waits. Have you tried with any other site and faced similar results?

    Can you email your script and your sample code? My email is narayan@sahi.co.in (It is part of my signature). I suspect it is something specific to your script. Please also attach the information on the Info tab of the Controller.

    Regards,
    Narayan
  • narayannarayan Administrators
    Simbo,

    I am able to reproduce your problem. Sahi does go ahead as if it has clicked something, even though ZK has not reacted by then.

    The fix will be available in the next build. I am emailing you a link to a temporary build till then.

    Regards,
    Narayan
  • Narayan,

    I did not get an email with the temporary build so I just built sahi from head. Sahi does appear to pause now for the ajax responses. However it now only really works well with ZK5 (which has only been released 1 month) and it now no longer works so well with ZK3.6 as it does not recognise buttons on ZK3.6 as well as it recognises them on ZK5.

    I have written more about this on the comments at the bottom of the ZK+Sahi page:

    http://docs.zkoss.org/wiki/Making_ZK_Functional_Tests_With_Sahi

    thx

    Simon
  • narayannarayan Administrators
    Simon,

    The identification by id should not be a big problem to solve. Sahi basically ignores ids matching some regular expressions. My guess is that the id patterns are different for 3.6 and 5.6. If you can give me a sample of a few ids, (so that I can figure out their pattern) I should be able to guide you to get Sahi working for you.

    Btw, did you mean that the public release of Sahi was identifying elements well on 3.6, but the latest version of Sahi you built from source has broken this?

    Is there a sample page I can test this out on?

    Regards,
    Narayan
Sign In or Register to comment.