| Share
  1. Explore
    Introduction, screen-shots, features, limitations
  2. Getting started
    Prerequisites, download, install, browser configuration, record, playback, view logs
  3. Sahi Scripting Basics - I
    Statements, variables, functions, conditions and looping, _include
  4. Sahi Scripting Basics - II
  5. Sahi APIs (built-in functions)
    1. Browser Accessor APIs
    2. Browser Action APIs
    3. Miscellaneous APIs
  6. Sahi Scripting - Calling Java
  7. Exception handling using try-catch
  8. Recovering without try-catch using _setRecovery
  9. Data Driven Testing
    _getDB, CSV Files, Excel, Databases
  10. Multithreaded Playback (Parallel execution)
    suites, commandline, ant
  11. Advanced techniques, tips and examples
    1. HTTPS/SSL Sites
    2. Configuring an External proxy
    3. Adding jars to Sahi's classpath
  12. Other language drivers Driving Sahi from Java, Ruby etc.
    1. Java
    2. Ruby

Exception Handling in Sahi ·

Exceptions are handled via regular javascript try catch blocks since Sahi V2.

Syntax

try{ // sahi statements }catch(e){ // Corrective action // Can print exact source of error in log // Can throw the same or another exception }

Eg.

Corrective Action

try{ _click(_link("does not exist")); }catch(e){ _log("Exception occured"); // simple logging. no failure _click(_link("linkByHtml")); // Corrective action }

Corrective Action and Log the Exception Message

try{ _click(_link("does not exist")); }catch(e){ _click(_link("linkByHtml")); // Corrective action _logException(e); // Logs the exception, but does not fail }

Corrective Action, Log and then Fail

try{ _click(_link("does not exist")); }catch(e){ _click(_link("linkByHtml")); // Corrective action _logExceptionAsFailure(e); // Logs the exception, and fails, // and in the logs, points to the original line as source of failure. }




---