18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to Check For Errors while using Sahi...
Hi,
Doubts:
1) I'm using sahi to automate few web pages.
Now, I need to include error handling code for cases where sahi doesn't work or sahi returns diff. response as expected.
For example, I call this code:
browser.navigateTo(url);
If this code does not work due to invalid url then how should I handle these kinds of error.
2) Where can I find Java API code for sahi? kindly specify any reference.
Doubts:
1) I'm using sahi to automate few web pages.
Now, I need to include error handling code for cases where sahi doesn't work or sahi returns diff. response as expected.
For example, I call this code:
browser.navigateTo(url);
If this code does not work due to invalid url then how should I handle these kinds of error.
2) Where can I find Java API code for sahi? kindly specify any reference.
Comments
Sahi Error - www.rfbgvbgdargarha.de
Sahi could not connect to the desired URL
Now you could do an assert every time you are navigating somewhere: _assertNotExists(_bold("Sahi could not connect to the desired URL"));
Or set a recovery function ( Sahi API: _setRecovery() )
when you get an unresponsive URL, your script will mostly fail. Use a recovery function to evaluate what went wrong.
If this isn't helping, please give further informations on what you are trying to do.
Basically my intention is to add Error Handling Java Code while using Sahi.
Note: I only want Java code examples for sahi.
If I've written browser.navigate(url) and if my application is not able to connect to that url without throwing any exception then how should I do error handling (in java).
Also, I need to include these types of error handles everywhere I use Sahi Code.
So, How should I do this effectively OR does Sahi provide any java classes for doing this?
Thanks,
Nitesh
Sorry, I just got fundamental knowledge of Java. Maybe this is helpful:
http://download.oracle.com/javase/7/docs/api/java/lang/Throwable.html
http://download.oracle.com/javase/tutorial/essential/exceptions/throwing.html
if browser.navigate is throwing exeptions, then putting it in a try{ \ statements } catch ( exeption ) { / statments to handle exeption } should do the job.
Hope this is helping,
regards
Wormi
edit: this is my favorite site if I want to learn about java
http://chortle.ccsu.edu/java5/Notes/chap80/ch80_1.html
When you try to connect to a website using navigateTo, you always land up on a result page. The result page can either be your expected page, or it could be an error page. Both are valid pages according to Sahi. You have to add your own expectations to make sure that your test fails.
For example,
If the login page could not be navigated to, the textbox for the next step will not be available and automatically fail. You could check for existence of the textbox using an "if" condition to selectively log an error, if needed.
if (!browser.textbox("abcd").exists()) {
// handle your case
}
I am not sure if you meant this, but for assertions, you will have to use JUnit or TestNG.
All Sahi Java APIs are available here:
http://sahi.co.in/w/java
and
http://sahi.co.in/java/javadocs/
The latest javadocs are also in sahi/docs/java_client/ folder. Just double click in index.html there.
Regards,
Narayan
http://www.exampledepot.com/egs/java.net/GetHeaders.html
when you get an HTTP response, you can check the headers for the response codes ( i.e 200 for success or 404 for not responsive)
based on what you get, you can specify a behavior