Error Recovery with Omega13

Omega13 is a preloaded script in Eggplant Functional that can be used to attempt recovery following a randomly occurring event on your system under test, such as a notification dialog or advertisement pop-up window, that results in an "Image Not Found" exception. Omega13 differs from a Try...Catch block in that it automatically attempts to resume running your script at the same step where the exception first occurred. To use Omega13, write an attemptRecovery script (described below) and enable Omega13 from within your script.

Note: You can also view the full instructions for using Omega13 within Eggplant Functional itself. Run Omega13 from a script, and the instructions show in the Run Window.

For a quick explanation of how Omega13 works, see the video below:

When to Use Omega13

When writing a test, often you know at what point in the test a pop-up or other image-obscuring element might appear. In these scenarios, an if... then... else or try… catch... end try statement might be the appropriate choice. However, sometimes you do not know when a disruptive element might appear and hinder Eggplant Functional’s image search. This type of scenario is where Omega13 is helpful.

How It Works

Omega13 is a script built into Eggplant Functional and requires no additional installations. However, in order for Omega13 to do its job, you must write an attemptRecovery script or handler for it to run during error handling, that is accessible from the test in which you use Omega13.

Note: Image Update must be turned off to trigger Omega13. To do this, go to Run > Image Update and select Throw Exception (Update Off).

Using Omega13

In order to tell Eggplant Functional that you want to use Omega13, use the Start Using command to indicate where you’d like to start using Omega13 within your test, and Stop Using to indicate where you’d like to return to normal operation. These commands can bookend your entire script, or indicate a specific problem area.

Start using Omega13

openWebPage

RunWithNewResults "scrollThroughList"

RunWithNewResults "opentheLastItem"

closeWebPage

Stop using Omega13

When an image in your script is obscured by one of these random events at some point in your test, Omega13 catches the "Image Not Found" exception and calls a special script called attemptRecovery that you’ve designed to recover from the event.

One component of attemptRecovery is a Return "yes" or Return "no", which indicates to Omega13 whether or not attemptRecovery itself was successful. When Omega13 receives a "yes" , it looks again for the image that previously raised the exception. If the image is found on the second attempt, the original test script continues executing.

The attemptRecovery Script

Your attemptRecovery script must be located within the suite of the script where you are calling Omega13, and it must be called "attemptRecovery".

Your attemptRecovery script should contain error handling code to account for any obstructions to your script run that might occur on the system under test (SUT). Then, if Omega13 is called during your script run and an issue is encountered, the attemptRecovery script is called by Omega13 and your error handling code is executed.

All attemptRecovery scripts must include a Return command at the end of the script passing a "yes" or "no" value back to Omega13 indicating the success or failure of the attempt to recover. When Omega13 receives the return value "yes", it continues execution from the point of script failure.

Note: The Return command must be at the end of the script, as it terminates the execution of the current handler.

Example:

Script using Omega13 called "TestButtonFeature":

start using omega13

WaitFor 8.0, "Feature_with_buttons"

If ImageFound("Feature_with_buttons")

log "success"

end if

stop using omega13

Associated "attemptRecovery" script, located in the same suite as the "TestButtonFeature" script:

If ImageFound("DiscardChangesPrompt_1")

click "DiscardChangesPrompt_1"

return yes -- we were able to dismiss the popup

Else

return no -- it was a different problem we don't know how to deal with

End If

AttemptRecovery can also be included as a handler in the script calling Omega13. In that case, your script might look like this:

to attemptRecovery given theException, theCommand, theParams

 

If ImageFound("DiscardChangesPrompt_1")

click "DiscardChangesPrompt_1"

return yes -- we were able to dismiss the popup

Else

return no -- it was a different problem we don't know how to deal with

End If

 

end attemptRecovery

Parameters Passed to attemptRecovery

When Omega13 calls your attemptRecovery script, attemptRecovery receives three parameters:

  • The exception that occurred in trying the original command;

  • The name of the command or function; and

  • A list containing the parameters that were passed to that command or function

You can access these passed parameters by declaring variables within the attemptRecovery script. You can either declare variables using a params declaration, or declare them in-line with your handler declaration, as shown below:

to attemptRecovery given theException, theCommand, theParams

 

log theException -- logs the original exception encountered in the calling script

log theCommand -- logs the command on which the error occurred

log theParams -- logs the parameters passed to the command that failed

 

If ImageFound("DiscardChangesPrompt_1")

click "DiscardChangesPrompt_1"

return yes -- we were able to dismiss the popup

Else

return no -- it was a different problem we don't know how to deal with

End If

 

end attemptRecovery

 

This topic was last updated on August 19, 2021, at 03:30:51 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant