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 close a window or a tab in Firefox from Sahi script?
hi,
Is there a way to close a window or a tab from Sahi script? _closeWindow() only works for popup window.
Is there a way to close a window or a tab from Sahi script? _closeWindow() only works for popup window.
Comments
You are right that _closeWindow() only works for popups.
If you are using a suite, Sahi will automatically close windows after a test.
Regards,
Narayan
when i execute my suite, everytime it opens a new tab in the window so the tabs accumulate and finally broke the tests.
I was testing against a https site. I tried both "-profile c:\sahi\userdata\browser\ff\profiles\sahi$threadNo -no-remote" and '-profile c:\sahi\userdata\browser\ff\profiles\sahi$threadNo"
If I launch directly from console, both launch a window, failed to execute after 150seconds, then close the firefox.
So in order to make the command work what I did was I open a ff browser, execute the script manually from sahi controller first(which succeeds), then from console, launch the batch command again. and in this case, the behaviour is different:
1. with "no-remote":
it launches a new browser window, fails after 150s, then close THAT browser.
2. without "no-remote"
it launches a new tab in existing window, succeeds but the tab accumulates.
Note: I cannot paste my script here because of the restrictions of the forum:
"New Members can not post links, images or email addresses until they become more active"
So in addtion to my original question, couple of questions here:
1. why is it not working for HTTPS site(for sure I've followed exactly the steps in the instructions)?
2. Is there a complete reference for the commandline options?
What do you see on the opened browser? Does it navigate to your page? Does it show a security warning?
It looks to me like the browser opens the correct profile of firefox when -no-remote is used, but is unable to find the certificates you had accepted, and so keeps waiting on the security warning page.
When you don't use -no-remote, it is using your existing open profile and hence certificates are available to you.
To fix this you can either:
* Accept the certificates when the warning comes up during playback.
Or
* Copy the cert_override.txt file from your default firefox profile to the profiles in sahi/userdata/browsers/ff/profiles directory. There will be ten of them. An easy way to do it, is to
1) copy cert_override.txt from your Firefox profile to sahi/config/ff_profile_template.
On my windows 7 machine, my default profile is located at C:\Users\me\AppData\Roaming\Mozilla\Firefox\Profiles\l0ipiru7.default
2) Delete all profiles in sahi/userdata/browsers/ff/profiles directory
3) restart Sahi. It will copy the ff_profile_template into the profiles directory.
Now all profiles will have the same certificate exceptions.
We are trying to make this process easier in the coming builds.
Regards,
Narayan
the problem isn't with certification. I've added the cert exception and it's not give warning. I tried your suggestion with cert_override, not helpful. The script stops once the first HTTPS page loaded, while it's supposed to do next action
_click(_image("Next Screen"));
Is there anyway I can send you my script so you can probably make a test when you get a min?
_navigateTo("https://onlinebusiness.icbc.com/deas/WebDeasServlet/DriverWelcomeAction",true);
_click(_image("Next Screen"));
And my suite file is even simpler...only one line:
icbc5.sah
This script works well when i play it from controller.
We will check here and update you.
Regards,
Narayan
It works now. I think you're right it's still cert problem. I think it's the sahi.example.com that matters. Looks like Firefox won't display a warning even doesn't have a cert exception, it just silently rejects it. But i tried many times and I'm pretty sure i did check the cert for sahi before.
Anyway, thanks for the help. I'll post if i find out the exact cause later.