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.

To clear cache , cookies and history in mozilla firefox

rajendra_PASSrajendra_PASS Members
edited November -1 in Sahi - Open Source
Hi


Can anyone help me to clear cache , cookies and history in browser(mozilla firefox)through .bat file when the bat file is called using sahi script in a test.

Comments

  • Hi Rajendra,

    Please find the below batch code to clear history & cache from your firefox browser.

    ////// Batch file
    @echo off
    set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
    del /q /s /f "%DataDir%"
    rd /s /q "%DataDir%"
    for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
    //////

    You can call this batch file from SAHI.

    Let me know if that doesn't help you.

    -Ashish
  • rajendra_PASSrajendra_PASS Members
    edited October 2011
    Hi Ashish ,



    Thanks for your reply , we are already using the same script through a .bat file , The problem is when we are running this bat file the cookies, history and cache is getting cleaned however , we are unable to login to the application (web application) even after reloading the page. The requirement is we need to clear the cache while the browser is open so that the previous data would not interrupt while running a script.

    We are able to login to the application when we are clearing manually from tools-->options-->clear your recent history-->select cookies and cache --> click on ok button. eagerly waiting for your reply .


    regards
    Rajendra
  • Hi rajendra_PASS,

    You can try to open a private browser,so that it contains no history,cache and cookies.To do so,
    append -private to the options tag in browsertypes.xml file.A new private browser will be launced each time.To do the same with chrome append --incognito and with opera append -newwindow.

    This might help you.

    Regards,
    Theeran.
  • Theeran, this one really helps :) I had the same problem with cache & sahi. Also, really helpful tip: always check the encoding of each script, if it's not UTF8 - without BOM, then some problems may appear ;)
  • i want to write a program with .bat that it has to open a web browser with removing the firefox history cache and cookies is it possible
  • is this is correct way
    @echo off
    :MENU
    echo choose the following operations
    echo 1:notepad
    echo 2:ccleaner
    echo 3:firefox
    echo 4:notepad++
    echo 5:cmd
    Set option=
    set /p option=Your option:
    if %option%==1 start notepad.exe
    if %option%==2 start ccleaner.exe
    if %option%==3 start DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
    del /q /s /f "%DataDir%"
    rd /s /q "%DataDir%"
    for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
    if%option%==3 start firefox www.fb.com www.gmail.com
    if %option%==4 start notepad++.exe
    if %option%==5 start cmd.exe
  • plz send me the code to krakeshk2012@gmai.com
Sign In or Register to comment.