Knowledge Base Article

> Knowledge Base > Rapise

Created By  alexey.grinevich Monday, April 16, 2018

Some applications show unexpected popup windows. This could be feature announcements, update reminders, license expiration reminders, alerts, internal messengers and so on. Here we are going to show a solution for this problem.

Problems with Popup Objects

The main problem is that appearance of popup messages is not predictable and may happen at any point in the application.

This causes a real problem for automatic test execution. Ideal solution may be to find an application configuration option and to disable such popups at all. Unfortunately this this not always possible. In some cases there is no such a config option. In others we simply cannot switch popups off completely because some of them are required for test scenarios.

For example, well known application box.com is throwing unexpected new feature prompts up in unanticipated places on occasion, failing scripts when the prompt requires a response the script is not expecting:

Solution

Proposed solution to this problem is to check presence of the popup object just before doing any action.

Go to Functions (<test>.user.js) file and add the following code:

function OnBeforeObjectAction(/**SeSObject*/ obj, /**string*/ actionName, /**array*/ arguments)
{
    // TODO: check if any popups before accessing object action, for example:
    if( Global.DoWaitFor('popup_object_close', 300) )
    {
        // It is important to use _DoClick, because it works directly
        // without calling 'OnBeforeAction' recursively
        SeS('popup_object_close')._DoClick();
    }
    
    // Return 'false' to let other OnBeforeAction handlers to be called.
    return false;
}

g_sesOnBeforeActionExecutedImpl.push( OnBeforeObjectAction );

 

This snippet introduces an array of functions: g_sesOnBeforeActionExecutedImpl, each will be called before any DoSomethigaction in the script.

OnBeforeAction arguments

Input parameters to this function are:

  • obj - Resolved SeSObject. If object is not found then OnBeforeObjectAction is not executed at all.
  • actionName - Action with Do prefix. I.e. actionName='Click' for the DoClick.
  • arguments - array of action arguments.

Here is an example scenario where OnBeforeAction is used to trace all actions into a file:

function OnBeforeActionTrace(/**SeSObject*/ obj, /**string*/ actionName, /**array*/ arguments)
{
	var objName = obj.object_name||obj.object_id||obj.name||"\"\"";
	// Callback on after action executed
	var actionString = "Before calling "+objName+".Do"+actionName+"("+JSON.stringify(arguments)+")";
	
	File.Append('Trace.txt', actionString+"\r\n");
	
	// Return 'false' to let other OnBeforeAction handlers to be called.
	return false;
}

File.Write('Trace.txt', 'Test starts\r\n');

g_sesOnBeforeActionExecutedImpl.push( OnBeforeActionTrace );

Rapise uses similar method internally to trace screenshots. Check built in function function _SeSMakeScreenshotBeforeAction defined in %ENGINE%/SeSCommon.js for more reference.

Attachments

Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Done!
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 4/16/2018
  • Article ID: KB338
  • Views: 68