Knowledge Base Article

Home Page > Knowledge Base > Rapise

Article Waiting Until Application Ready

by Jim R. on Friday, February 20, 2015

Sometimes you need to synchronize the test script so that it waits for a specific application event (change for status message or wait for some specific value). This guide explains how to ensure that Rapise waits for the appropriate condition.

Current Versions of Rapise

With version 1.4 (and higher) of Rapise you can wait for a specific object to be ready by using the built-in DoWaitForProperty function of the Global object:

 

            // Wait for timer to finish

            Global.DoWaitForProperty('OnlineTimerTime', 'InnerText', "00:00:00", 10000);

 

Rapise v1.3.x

To wait for a specific object to be ready, you need to add following function for this purpose into your <script>.user.js file:

 

            /**

             * Waits for specified value of object's property. Function returns object handle

             * if object was found and specified property equals to desired value or 'false'

             * in case of timeout.

             * @param obj ID of object to wait for or object itself.

             * @param getterName Property getter function name.

             * @param propValue Desired value.

             * @param [timeout = 10000] Maximum time to wait.

             * @param [params] Parameters for property getter function.

             * @returns Found object or 'false'.

             */

            function DoWaitForProperty(/**String|SeSObject*/obj, /**String*/getterName, /**String|Number|Boolean*/ propValue, /**Number*/timeout, /**Array|String|Number|Boolean*/params) /**SeSObject|false*/

            {

                        timeout = timeout||10000;

                        params = params||[];

 

                        if (typeof(params) != "object")

                                    params = [params];

 

                        var start_ = new Date;          

                        var waitInt = 0;

                        do

                        {

                                    var res = null;

                                    if (typeof(obj) == "object")

                                                res = obj;

                                    else

                                                res = SeSFindObj(obj);

 

                                    if(res)

                                    {

                                                var prop = res[getterName];

                                                if (prop && typeof(prop) == "function")

                                                {

                                                            var value = prop.apply(res, params);

                                                            if (value === propValue)

                                                            {

                                                                        return res;

                                                            }

                                                }

                                    }

                                    SeSSleep(100);

                        } while((new Date - start_)<timeout);

                        return false;

            }

 

This function may be used as follows:

 

            // Wait for timer to finish

            DoWaitForProperty('OnlineTimerTime', 'InnerText', "00:00:00", 10000);

 

 

 

Attachments
Article Info
Last Updated: 2/20/2015
Article ID: KB130
# Views: 889
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.