18 January 2026:


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?

zxiazxia Members
edited June 2010 in Sahi - Open Source
hi,
Is there a way to close a window or a tab from Sahi script? _closeWindow() only works for popup window.

Comments

  • narayannarayan Administrators
    Hi zxia,

    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
  • zxiazxia Members
    for firefox, if the suite fails, sometimes it closes the window and sometimes not, but if it succeeds, it doesn't close the window.

    when i execute my suite, everytime it opens a new tab in the window so the tabs accumulate and finally broke the tests.
  • narayannarayan Administrators
    Looks like the browserOptions that you have specified in your target/batch file is incorrect. Can you post it here? With the correct browserOptions, firefox opens each test in a new window and closes it at the end of the test.
  • zxiazxia Members
    hi Narayan,
    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?
  • narayannarayan Administrators
    Hi,

    1. with "no-remote":
    it launches a new browser window, fails after 150s, then close THAT browser.

    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
  • narayannarayan Administrators
    The command line options are not Sahi related. They are specific to various browsers. You can search for "firefox command line options" or "chrome command line options" to get a list of them. We are using the ones that are related to Sahi. The options we use are listed on this page: http://sahi.co.in/w/Running+multiple+tests+in+batch+mode
  • zxiazxia Members
    Hi 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"));
  • zxiazxia Members
    luckily i was able to post my script. you see it's very simple -- navigate to a HTTPS page and click on "next" button.

    And my suite file is even simpler...only one line:
    icbc5.sah

    This script works well when i play it from controller.
  • narayannarayan Administrators
    Hi Zxia,

    We will check here and update you.

    Regards,
    Narayan
  • zxiazxia Members
    hi 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.
Sign In or Register to comment.