0% found this document useful (0 votes)
196 views

Error Handling - Runtime Errors

The document discusses exception handling in Selenium WebDriver and Eggplant Functional testing. It defines that an exception is an event that disrupts normal program flow, and exception handling allows anticipating, detecting, and resolving errors. Try/catch blocks are used to catch exceptions so scripts can handle errors. The ScriptResults() function returns run history details that can be used to check test status and results.

Uploaded by

vgpraveenkumar
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
196 views

Error Handling - Runtime Errors

The document discusses exception handling in Selenium WebDriver and Eggplant Functional testing. It defines that an exception is an event that disrupts normal program flow, and exception handling allows anticipating, detecting, and resolving errors. Try/catch blocks are used to catch exceptions so scripts can handle errors. The ScriptResults() function returns run history details that can be used to check test status and results.

Uploaded by

vgpraveenkumar
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 8

Basic understanding of Error, Exception, Exception Handling, Try, Catch, Throw and

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

How the reults are logged for failed test cases?


'on error resume next' - does this command exist?
If it is an eggplant exception - handle it, else consider as error and fail the test case.
Multiple catch blocks and keep a default block as the last catch block
Always print logs & screenshot about exception in catch block.
try catch block can be a reusable component from library
reset the SUT state to continue next tests ( it means, all the tests has to start
at known state)

When you will get image not found exception?

1. Image doesn't exist in SUT


2. SUT Image differs from captured image
3. Image delayed - sync problems
4.
Exception handling scenarios

1. Image not found


2. Sync failed
3. Image mismatch
4.

Test failed

5. More than one image found

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

Running Scripts using eggPlant Functional


Schedules
Scheduler
Can declare dependency tests
Run ignoring any type of error
Recover to initial state by try catch block, so that next test will run
Schedule Tab

Provide connection details for scripts,

set the run order,

and control other options for the schedule.

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

repeat with each item of the parameterlist


send logWarning locLabel(@the target) & it to sensetalk
end repeat
end logWarning

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

function locLabel theObj


put theObj's name into scriptName
put item -2 delimited by "/" of theObj's folder into suiteName
return suiteName & "/" & scriptName & ": "
end locLabel

Create own html file with modified reporting


information such as step number, step description, expected result, actual result
Use exampe suite to create html file
Scheduler
Initial condition in each test & reusable function
Run with new results
Try catch
run "CleanupScript"
Excel output
Create file in ResultsFolder
Command line execution
Actual results
Convert Outcomes runDate to date and
long time
put ScriptResults ("someScript") into
currentStatus
Log "Final Results"
eggPlant Settings ok
customized log file

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:

Date Run. The date and time of the run.

Status. The status of the run.

Time. The elapsed time (duration) of the run.

# of Errors. The number of errors that occurred during the run.

# of Warnings. The number of warnings that were logged during the run.

# of Exceptions. The number of exceptions that occurred 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.

You might also like