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.

Opens multiple browsers if browser is already open ..

vikkyjainvikkyjain Members
edited November -1 in Sahi - Open Source
Hi ,

I made a bacth file which have list of my all automated tests. When i execute this batch file it executes sahi scripts one by one. So the problem which i am facing is if suppose i want to execute my test using firefox and firefox session is already running, then each test will open a new firefox tab, and executes their and wont be closed. If no firefox session was running, then it will simply executes one by one test in firefox and close it after each execution.
Same problem occurs on chrome and IE.
So please suggest me if browser is already open , in that case also it should not open multiple tabs or multiple browsers, it should simply close the browser.


Thanks & Regards

Comments

  • Hi vikkyjain,

    What version of Sahi are you using and which OS?

    Also, check if there are spaces between the path to Sahi.

    Regards
    Sumitra
  • HI i am using sahi - V3.5
    OS - Windows XP Professional v-2002
    sahi path = c:\sahi\

    Let me know if you want some more information
  • narayannarayan Administrators
    Hi Vikky,

    This generally happens if your browserOptions parameter is incorrect. Can you paste the output that you see on the console where you ran testrunner.bat (or your batch file) ?

    Regards,
    Narayan
  • Sahi Output -

    SAHI_HOME: ..
    SAHI_USERDATA_DIR: ..\userdata
    SAHI_EXT_CLASS_PATH:
    Sahi properties file = C:\automation\sahi\config\sahi.properties
    Sahi user properties file = C:\automation\sahi\userdata\config\userdata.properti
    es
    Added shutdown hook.
    >>>> Sahi started. Listening on port: 9999
    >>>> Configure your browser to use this server and port as its proxy
    >>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Cont
    roller
    Reading browser types from: C:\automation\sahi\userdata\config\browser_types.xml

    Firefox 4 was not found at C:\Program Files\Mozilla Firefox 4.0 Beta 7\firefox.e
    xe
    Chrome was not found at $LOCALAPPDATA\Google\Chrome\Application\chrome.exe
    Opera was not found at C:\Program Files\Opera\opera.exe
    Sep 5, 2011 11:29:31 AM net.sf.sahi.ssl.SSLHelper getKeyManagerFactoryForRemoteF
    etch
    INFO: No SSL Client Cert specified
    >>>>>> Tests size = 1
    #### Running Script: C:\automation\scripts\version.sah
    Sep 5, 2011 11:30:02 AM net.sf.sahi.test.ProcessHelper execute
    INFO: "c:\Program Files\Mozilla Firefox\firefox.exe" "http://sahi.example.com/_
    s_/dyn/Player_auto?startUrl=http%3A%2F%2Flocalhost%3A8080%2FmyWeb
    __SahiAmpersandSahi__sahisid=sahi_0462e7390d5ac041e80af360a12cd149e6a8sahix16479
    65d099c404a4f0999c06554e5a31710x__SahiAmpersandSahi__isSingleSession=false"
    Sep 5, 2011 11:30:03 AM net.sf.sahi.test.ProcessHelper$PIDGatherer run
    INFO: PIDs: []; 969 ms


    Console Output -

    suiteName = C:\automation\scripts\test.sah
    base = http://localhost:8080/myWeb
    sahiHost = localhost
    port = 9999
    threads = 1
    browser = c:\Program Files\Mozilla Firefox\firefox.exe
    browserOption =
    browserProcessName = firefox.exe
    this.isSingleSession == false
    Added shutdown hook.
    http://localhost:9999/_s_/dyn/Suite_start?suite=C:\automation\scripts\te
    st.sah&base=http%3A%2F%2Flocalhost%3A8080%2FmyWeb&threads=1&sa
    hisid=sahi_9994301b06d23045940ab2a0b1f934460bee&browser=c%3A%5CProgram+Files%5CM
    ozilla+Firefox%5Cfirefox.exe&browserProcessName=firefox.exe&browserOption=&html=
  • narayannarayan Administrators
    Your browser option should not be blank. How are you running the batch file?
  • my batch file have following entries

    SET FIREFOX=%1
    SET URL=%2
    SET BROWSER=%3
    SET SAHIBATCH=C:\automation\sahi\lib\ant-sahi.jar net.sf.sahi.test.TestRunner

    java -cp %SAHIBATCH% "C:\automation\scripts\test.sah" %FIREFOX% %URL% default localhost 9999 1 %BROWSER%

    Can you please tell how to set BrowserOption value ????
  • narayannarayan Administrators
    Vikky,

    Please look at testrunner.bat to see how you can write your own batch file. In fact I would advise you to use testrunner.bat. It has the right configurations done.
    For more details have a look at: http://sahi.co.in/w/Running+multiple+tests+in+batch+mode

    In your case, you can try with:

    java -cp %SAHIBATCH% "C:\automation\scripts\test.sah" %FIREFOX% %URL% default localhost 9999 1 %BROWSER% "-profile "$userDir/browser/ff/profiles/sahi$threadNo" -no-remote"

    Regards,
    Narayan
  • Hi Narayan ,

    I tried using "-profile "$userDir/browser/ff/profiles/sahi$threadNo" -no-remote". This work good for Firefox and internet explorer, but for Chrome, it still opens a new tab and previous tabs shows a message

    "Eithe chrome ran out of memory or the process for webpage was terminated for some reason"
Sign In or Register to comment.