Error Handling - Runtime Errors
Error Handling - Runtime Errors
Throws statement.
http://www.toolsqa.com/selenium-webdriver/exception-handling-seleniumwebdriver/
What is an Exception?
An Exception is an event, which occurs during the execution of a program, that
disrupts the normal flow of the programs instructions or in simple words, any issue
which makes your test case stop in between the execution is an Exception.
What is Exception Handling?
Exception handling refers to the anticipation, detection, and resolution of
programming application, and communications errors. It is the block of code that
processes the exception object and helps us by giving us a chance to act on it.
Difference between Error and Exception:
An Error indicates serious problems that a reasonable application should not try to
catch.
An Exception indicates conditions that a reasonable application might want to
catch.
How to differentiate actual test fail and eggplant exception, bcoz both the cases,
you will find the image not found exception.
how eggplant execution engine handle failed test cases?
Run with new results -You can use this command to write sophisticated
master
control scripts, with actions based on the Status and ReturnValue
properties. For example, you can call one script if the previous script succeeds,
and call a
different script if it fails.
runWithNewResults "Master"
put the result into outcome
if the status of outcome is "Failure" then
subScript2
end if
ScriptResults() Function
If run in a suite, will move to next script on failure
Test failed
The try...catch...end try control structure allows you to catch these exceptions so
your script to handle the error condition in the manner you choose.
The throw command can be used to throw your own exceptions, or to re-throw an
exception that you caught.
params scriptName
try
run scriptName
catch
(* This will continue on but at the end script will report as having failed *)
LogError scriptName & "Failed"
(* This will also continue on but not cause the entire script to report as a failure *)
-- LogWarning scriptName & "Failed"
end catch
The scripts you add to a schedule can come from any suite, not just the active one.
"Running from a Master Script" in the Using eggPlant Functional manual.)
http://xserve1-55.redstonesoftware.com/phpBB2/viewtopic.php?
t=75&start=0&postdays=0&postorder=asc&highlight=&sid=7b20ee5f4ac02a2314
a54997d3f6c3eb
http://208.72.156.52/phpBB2/viewtopic.php?
printertopic=1&t=1803&postdays=0&postorder=asc&&start=0&sid=2640237f9685
4798dfed6ccaec773856
to log
// log can take multiple arguments, so add the prefix to each
repeat with each item of the parameterlist
send log locLabel(@the target) & it to sensetalk
end repeat
end log
to logWarning
// log can take multiple arguments, so add the prefix to each
to logError
// log can take multiple arguments, so add the prefix to each
repeat with each item of the parameterlist
send logError locLabel(@the target) & it to sensetalk
end repeat
end logError
ScriptResults() Function
Example: put ScriptResults ("someScript") into currentStatus
This function returns the RunHistory.csv file for any script. The script must be in an open suite,
or you must provide the full pathname.
Parameters: One script name. (If no script is named, the function defaults to the current script.)
LogFile: The name and absolute path of the Log file.
Errors: A count of errors logged for that run.
Warnings: A count of the warnings logged for that run.
Exceptions: A count of the eggPlant Functional caught and uncaught
exceptions raised.
Duration: The length of time the script ran (or has been running) given in
seconds.
RunDate: The date and time the run was started.
Status: The status of the run Success, Failure, or Running
ReturnValue: The returned value of any return statements
RunHistory.csv
A RunHistory.csv file is a comma-separated text file that summarizes all of the executions of a
script, with one line for each execution. The first line of this file identifies each of the fields:
# of Warnings. The number of warnings that were logged during the run.
Log File. The full path to the LogFile.txt file for the run.
Return Value. Any value returned by the script that was run.
Error Message. The final error message for the run, if it was a failure.