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.

Two questions about Sahi features

KarenKaren Members
edited November -1 in Sahi - Open Source
Sahi announces features (1) no waits (2) Works on applications with random auto-generated ids. However, I have questions about them as below.

(1) When I playback scripts in FF4, it's found that when the page has many components and it takes somewhat long time (more than 1 second) to load the components or complete the action, unless I add explicit _wait(1000), my script won't playback well for the action after _wait.

(2) When I record scripts, some component is recorded as _textarea("ext-comp-1225"). I am not sure if it's the "random auto-generated id" mentioned above. However, it seems even if the source code doesn't change, sometimes when playback same script, the ID will change, but other times it won't. I am curious about when such "1225" will change when playback.

Thanks!

Comments

  • SumitraSumitra Members
    Hi Karen,

    1)It will be convenient if you can share the URL and mention where exactly you are facing problem so that we can test on our machine and let you know the solution.

    Also, kindly share the script and mention where exactly the script won't playback well.

    2)You can use Regular Expression when ever there is change in the ID's.

    Regards
    Sumitra
  • Akss004Akss004 Members
    Sahi announces features (1) no waits (2) Works on applications with random auto-generated ids. However, I have questions about them as below.
    (1) When I playback scripts in FF4, it's found that when the page has many components and it takes somewhat long time (more than 1 second) to load the components or complete the action, unless I add explicit _wait(1000), my script won't playback well for the action after _wait.
    (2) When I record scripts, some component is recorded as _textarea("ext-comp-1225"). I am not sure if it's the "random auto-generated id" mentioned above. However, it seems even if the source code doesn't change, sometimes when playback same script, the ID will change, but other times it won't. I am curious about when such "1225" will change when playback.
    Thanks!

    Hi Karen,

    If you don't want to add wait explicitly in script and you think your application is slow enough to fail execution of scripts due to wait issue you can change Sahi's configuration accordingly.

    It is present over there in Dir :- /Sahi/Config/Sahi.properties .

    In that file there is section for "Script execution params" as below where you can add some more millie seconds to wait before executing next steps or you can increase no of re-attempt in case of element not found.

    *************************Section of Sahi.Properties File for this configuration**********
    # Script execution params

    #Time (in milliseconds) delay between steps
    script.time_between_steps=100
    #Time (in milliseconds) delay between retries once an error occurs
    script.time_between_steps_on_error=2000
    #Number of retries once an error occurs
    script.max_reattempts_on_error=5
    #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=1200
    #No of times Sahi should wait for stability of AJAX and page loads before continuing. min value is 1
    script.stability_index=5

    ********************************************************

    Hopes this might be helpful,

    Sumitra please correct me if i had misunderstood this feature.
  • KarenKaren Members
    Dear Sumitra and Akss004,

    Thanks for your help and feedback.

    1) For the wait issue, I followed Akss004's advice to update script.time_between_steps=1000 and it works. But I have another concern. If I update the config to workaround, it means my test execution time will be longer. Actually I only have one step which needs to wait for 1000 ms, now all my steps wait for 1000 ms. To make it worse, when some success message will auto fade out after 1s, sometimes the message could not be cought for the assertion. This means I did not want to wait for 1s for certain steps. Is there any better way to wait only for specific steps instead of all?

    2)For the "random auto-generated id", actually I have two questions:
    a) What's the mechanism of the generation of ID? When will it change?
    b) Not quite understand "how to use Regular Expression" in this case. Can you show me an example?

    Your help is greatly appreciated!
  • narayannarayan Administrators
    Hi Karen,

    1) Sahi does not need waits in most cases like page loading ajax load etc. But there are situations where an action may be triggered using what is called a setTimeout. If that happens, Sahi would not know about the timeout and may proceed to execute further steps. If Sahi is unable to do the next step, it may wait, but if for some reason it is able to do that action (because the element is present on the page) then an error may occur after that. In your case the best solution may be to give a _wait(1000).

    2) _textarea("ext-comp-1225") definitely is a dynamic id. Check on the Controller, what the alternatives of that textarea are. (CTRL-Hover on the element. The accessor and alternatives should get populated on the Controller.) If you find an alternative which better describes your textbox, use that. For example you may see something like _textarea("details").

    If you wish to use the ext-comp id, you can do something like _textarea("/ext-comp/") to identify without the random number. (This is the regular expression that Sumitra mentioned)

    But the recommended solution would be to not use the ext-comp-xxx ids but look for some other useful parameter.

    About Dynamic Ids and Sahi:
    Sahi detects elements which have dynamic ids and automatically ignores them. The way it does this is by looking at patterns to ignore. The patterns are located in sahi/config/sahi.properties.
    You can open sahi/userdata/config/userdata.properties and add this line:
    recorder.ignorable_ids.pattern=^z_|^j_id|[:]j_id|^ext[-]gen|^[:]|^zk_comp_|^gwt[-]uid|^ext[-]comp
    

    Restart Sahi, clear browser cache, and Sahi will stop identifying elements using the ext-comp-xxx ids. (Sahi will stop using those ids as valid identifiers for your elements. Instead some other better attribute would be used. If you are left with nothing but indexes like _textarea(12), try and identify the element using _near or _in (http://sahi.co.in/w/browser-accessor-apis))

    Regards,
    Narayan
  • KarenKaren Members
    Hi Narayan,

    I followed your solution to resolve my problem. Now they work well. And most importantly, I understand the reason behind. Your help is greatly appreciated!

    Best Regards,
    Karen
This discussion has been closed.