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.

browser.close() doesn't work

JirkaJirka Members
edited November -1 in Sahi - Open Source
Hi there!

I'm running tests through JUnit in Eclipse and I'm facing one problem. I have extended the sample_java_project and everything works fine except one thing - sahi never close the opened browser window. I have tried both IE7 and FF3.5 with the same result. The browser.close() is called, but it never close a window. If I run two tests, when the script finishes, I have two opened windows.
I want to use sahi for remote testing, so this behaviour will lead into tons of opened windows.

I'm using Sahi Build 2010-11-03 on WinXP with Eclipse 20100917-0705.

Thanks for any advance

Comments

  • narayannarayan Administrators
    Could you check if taskkill command is available on your system?
  • Yes, taskkill command is possible to call from prompt line or from Run dialog.
  • I have tried it now with Ant, and it also don't close the window.
    And one more thing: When I'm trying this with Firefox, and Sahi try to open another window, it fails with message "Firefox is already running but...". Before run the test i have checked the proccess list and there was no "forgotten" firefox.exe process :) This happens with the -no-remote directive and also without it. IE opens two instances correctly.
  • narayannarayan Administrators
    Hi Jirka

    And is tasklist available? Somehow Sahi is not able to keep track of the process PIDs. Not sure why. Let us know if you have more information, or else we can do a desktop sharing session to see what is going wrong.

    Regards,
    Narayan
  • Hi Narayan

    Yes, tasklist is available on my system and I can see there the firefox process with his PID and I can terminate it with taskkill.
    I have noticed that in Sahi server window during test run are messages like:

    INFO: PIDs: []; 765 ms
    Killing C:\app\sahi\userdata\scripts\sample1.sah
    2.12.2010 16:13:44 net.sf.sahi.test.ProcessHelper kill
    INFO: Kill: []

    Shouldn't be the process name/PID in the brackets? Just guessing.

    Maybe the solution for Ant task will be the external call for taskkill, but this will terminate all browser windows, because i know only the process name, not the PID.
  • narayannarayan Administrators
    Hi Jirka,

    There seems to be some problem there. The PIDs should have been populated. Don't do it via ant. Sahi already has logic to do it, but something seems to be amiss. Let me know if we can do a desktop session sometime.

    Regards,
    Narayan
  • Thanks for the answer, I think we are moving in right direction :)

    OK, I think desktop session would be problem, because of strict IT policy on our company. I will ask the IT department, but I think it wouldn't be possible. But I can also try to reproduce this problem on my personal computer and then we can arrange a session.
    What kind of access do you need?
  • Problem solved.
    First, big thanks to Narayan for the help.

    Problem was in localized parameters used in the "tasklist.exe" process on my non-English version of Windows. Solutions are two
    1) Change the tasklist parameters in "sahi/config/os.properties" to fit the proper (localized) value, or
    2) get somewhere (I downloaded it from internet) the english version of tasklist.exe and use it instead of the localized one.
This discussion has been closed.