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 handle javascript errors in the page
Hi,
I am trying to validate if any javascript errors are there in the page loaded. Also know that sahi automatically reports the js errors in logs, but I want to handle as separate validation in my script. I tried using two methods as shown below both didnt work. Kindly let me know is there any way to verify is there any js errors on the page rendered.
note: I injected js exception in user_extension.js, so that i can get js errors in everypage getting loaded.
Also note that in both the cases automatically sahi reports the error as unhandled type error exception.
Method 1 : using try catch statement.
try{
_navigateTo("www.google.com");
} catch(e){
_log("Js Error found');
}
method 2: using window.onerror
<browser>
function verify_js(){
window.onerror = function(){
_log("js error found");
return false;
}
}
</browser>
_navigateTo("www.google.com");
_set($x,verify_js);
_alert($x);
I am trying to validate if any javascript errors are there in the page loaded. Also know that sahi automatically reports the js errors in logs, but I want to handle as separate validation in my script. I tried using two methods as shown below both didnt work. Kindly let me know is there any way to verify is there any js errors on the page rendered.
note: I injected js exception in user_extension.js, so that i can get js errors in everypage getting loaded.
Also note that in both the cases automatically sahi reports the error as unhandled type error exception.
Method 1 : using try catch statement.
try{
_navigateTo("www.google.com");
} catch(e){
_log("Js Error found');
}
method 2: using window.onerror
<browser>
function verify_js(){
window.onerror = function(){
_log("js error found");
return false;
}
}
</browser>
_navigateTo("www.google.com");
_set($x,verify_js);
_alert($x);