Wednesday, February 1, 2012

Creation of Firefox profile for Selenium


 We use Selenium with firefox profile to test our JS functions in selenium console of firefox profile.

 Before we can create profile, take a backup of  firefox  so that the bookmarks and default settings of firefox won't vanish.

 Steps to take backup:
  1. For Windows 7 users, go to C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ and copy the default folder and paste it some local directory.
  2.  Windows XP users,C:\Users\username\Application Data\Mozilla\Firefox\Profiles\ and copy the default folder and paste it some local directory.

Steps to create profile.
  1.     Make sure all your firefox instance are closed
  2.     Click Start>Run(windows xp) or click start ,type in search (windows 7)
  3.     Type “firefox.exe -ProfileManager -no-remote”    or C:\Program Files (x86)\Mozilla Firefox\firefox.exe -ProfileManager -no-remote
  4.     Select “Create Profile” 
  5.    Click “Next”
  6.     Enter new profile name (i.e. selenium)   Optional:  Select a directory folder to store your new profile
  7.     Click “Finish”
  8.   Don't Select “Don’t ask at startup”
  9.    Click “Start Firefox” and configure settings ,  From “View\Toolbars” tab, uncheck “Bookmarks Toolbar”
        Right click from toolbar and click “Customize”
        Remove “Google search” by dragging it to the “Customize Toolbar” window
        From the “Customize Toolbar” window, click “Use Small Icons” check box then hit “Done”
        Click “Tools\Options” then set the following:
        a. “Main” tab
        - set Home Page to “about:blank”
        - uncheck “Show the Downloads..” option
        b. “Tabs” tab
        - Select “a new window” for new pages
        - Uncheck all warning options
        c. “Content” tab
        - uncheck “Block pop-up” windows option
        d. “Privacy” tab
        - uncheck all “History” options
        e. “Security” tab
        - uncheck all “Security” options
        - click “Settings” and uncheck all warning options
        f. “Advanced” tab
        - Uncheck “autoscrolling” option from “General” tab
        - uncheck “warn me …” and “Ssearch Engines”option from “Update” tab
        From “Tools\Add-ons” install the following:
        - Firebug: allows you to edit, debug, and monitor CSS, HTML, and JavaScript on your application under test
        - Selenium IDE: allows you to record, edit, and debug Selenium tests
        - From the address bar type “about:config” and add the following by right-click anywhere on the page and selecting “new”
        - extensions.update.notifyUser (type=boolean; value=false)
        - extensions.newAddons (type=boolean; value=false) 
  10.  Now , your profile is set. To restart the default firefox , close the firefox profile, and Click Start>Run(windows xp) or click start ,type in search (windows 7) . Type “firefox.exe -ProfileManager -no-remote”    or C:\Program Files (x86)\Mozilla Firefox\firefox.exe -ProfileManager -no-remote . Select default and then click on “Don’t ask at startup”
  11. Now you can see your default  firefox with all your bookmarks.
If, by any chance, the bookmarks are gone,then follow,

Steps to restore the default profile

  1.  Copy the default folder from the local directory  
  2. Paste it in C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\default.which will replace the default profile . 
Steps to launch Selenium Server with the created profile
  1.   Go to the folder containingselenium server jar 
  2. Now start selenium server with firefox profile by giving the right location of profile     
    java -jar selenium-server.jar -firefoxProfileTemplate “<Selenium Profile Directory>”

     ex :  java -jar selenium-server-standalone.jar  -firefoxProfileTemplate "C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\jvme65u6.selenium"
  3.  To launch selenium test using profile through ant,
 <target name="startServer">
        <echo>Start Selenium Server...</echo>
        <java jar="${lib.dir}/selenium-server.jar" fork="true" spawn="true">
            <arg line="-port ${selenium.port} -trustAllSSLcertificates"/>
            <arg line="-log log.txt"/>   
            <arg value="-userExtensions"/>
                <arg value="${lib.dir}/user-extensions.js"/>
        </java>
    </target>

Any problems??? feel free to comment...

3 comments:

  1. Hi Farheen Khan,

    Thanks giving this one buti need to know why we need to creating profile and how to create IE,Chrome and Saffari profile craeting........please gve me reply.

    Thanks

    ReplyDelete
  2. Nice Post! I searched the internet for this, but found nothing as clear as this one..

    ReplyDelete