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.
Java api and logging errors
Hi!
I use Sahi (20110719) from Java on Linux with Firefox. I have Sahi proxy started as external process (./sahi.sh) then I connect to it from my Java code.
The problem appears when exception is raised from Sahi, for example because element was not found on the browser. In this case I can only see:
net.sf.sahi.client.ExecutionException: null (NativeException)
at my console and this is not helpful at all... I've noticed that using:
(...)
try{
browser.div(itemname).click();
}
catch (ExecutionException ex){
System.err.println(ex.toString());
throw ex;
}
gives me much more readable exception, eg:
[INFO] error:_mouseOver(_link("blah"))
[INFO] Error: The parameter passed to _mouseOver was not found on the browser
I suppose that my test runner is using .getMessage() to read error message and getMessage returns 'null'. I think that ExecutionException class should be changed to support getMessage method, and (according to: download.oracle.com/javase/1.5.0/docs/api/java/lang/Throwable.html) toString should use getMessage.
Another thing I've noticed while dealing with above issue is that nothing is written into logs. I tried to change loglevels, but I still only have 'playback' directory in my userdata/logs. I expect some .log files to appear there but it doesn't happen. I'm not sure if it exceptions should be logged into this directory or 'logs' is only used with _log method?
I use Sahi (20110719) from Java on Linux with Firefox. I have Sahi proxy started as external process (./sahi.sh) then I connect to it from my Java code.
The problem appears when exception is raised from Sahi, for example because element was not found on the browser. In this case I can only see:
net.sf.sahi.client.ExecutionException: null (NativeException)
at my console and this is not helpful at all... I've noticed that using:
(...)
try{
browser.div(itemname).click();
}
catch (ExecutionException ex){
System.err.println(ex.toString());
throw ex;
}
gives me much more readable exception, eg:
[INFO] error:_mouseOver(_link("blah"))
[INFO] Error: The parameter passed to _mouseOver was not found on the browser
I suppose that my test runner is using .getMessage() to read error message and getMessage returns 'null'. I think that ExecutionException class should be changed to support getMessage method, and (according to: download.oracle.com/javase/1.5.0/docs/api/java/lang/Throwable.html) toString should use getMessage.
Another thing I've noticed while dealing with above issue is that nothing is written into logs. I tried to change loglevels, but I still only have 'playback' directory in my userdata/logs. I expect some .log files to appear there but it doesn't happen. I'm not sure if it exceptions should be logged into this directory or 'logs' is only used with _log method?
Comments
First u should check If it's available div tag in that particular page after that u can trigger that div.
I hope the following code has useful for u.
if( browser.div(itemname).exists() ){
browser.div(itemname).click();
}else{
//Print statement whatever u want
}
Regards,
Azhaguvel.A
I know I can check for existence of div element, but it is just an example here. It is hard to write/debug code if you can't see what was the exception