{"id":7686,"date":"2020-12-22T17:21:54","date_gmt":"2020-12-22T11:51:54","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=7686"},"modified":"2025-04-03T07:11:33","modified_gmt":"2025-04-03T11:11:33","slug":"creation-of-firefox-profile-in-selenium-webdriver","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/creation-of-firefox-profile-in-selenium-webdriver\/","title":{"rendered":"Creation of Firefox Profile in Selenium WebDriver"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>What is Firefox Profile?<\/strong><\/h2>\n\n\n\n<p>A Firefox profile is a user-personalized setting that consists of the user\u2019s bookmarks, plugins, extensions, and saved passwords that can be done on the Firefox Browser. When Firefox is installed, it creates a profile folder by default in your local drive that saves information like passwords, bookmarks, etc. You can have many Firefox profiles, each profile containing a separate set of user information. <\/p>\n\n\n\n<p>Let\u2019s, for example, say you and your friend are using the same computer, and both of you want to see your own Firefox settings when logging in. Both users can create and access their own Firefox profile whenever they open the Firefox browser. Understanding how to manage profiles is a useful skill covered in a <a href=\"https:\/\/www.h2kinfosys.com\/courses\/selenium-automation-testing-certification-course\/\" data-type=\"link\" data-id=\"https:\/\/www.h2kinfosys.com\/courses\/selenium-automation-testing-certification-course\/\">Selenium testing<\/a> course, where you learn how to configure and use different profiles for personalized browser automation.<\/p>\n\n\n\n<p>Whenever the Firefox browser<a class=\"rank-math-link\" href=\"https:\/\/www.mozilla.org\/en-US\/firefox\/products\/\" rel=\"nofollow noopener\" target=\"_blank\"> <\/a>is launched with Selenium WebDriver, it opens a blank Firefox browser without bookmarks, extensions, plug-ins, etc. Sometimes we required these plug-ins bookmarks, extensions, etc. while executing the selenium test case.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is the purpose of creating a custom Firefox profile?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the Firefox profile to make the test execution more reliable we need some special settings in the Firefox profile. A common example is handling <a href=\"https:\/\/www.h2kinfosys.com\/blog\/handling-of-ssl-certificates-in-selenium-webdriver\/\" data-type=\"link\" data-id=\"https:\/\/www.h2kinfosys.com\/blog\/handling-of-ssl-certificates-in-selenium-webdriver\/\">SSL certificate<\/a> settings. During test execution to handle these requirements, we need to create a custom profile and to make test execution more reliable.<\/li>\n\n\n\n<li>Whenever we use different profiles every time, the SSL certificates you accepted or the installed plug-ins would be different and would make the tests behave differently on the machines.<\/li>\n\n\n\n<li>Always make sure that the profile which you have created is lightweight that includes only plug-ins, bookmarks, extensions, settings that are required for test execution. Every time for Firefox instance a new session is created whenever selenium starts it will copy the entire profile in some temporary directory and if the profile is big, it makes it slow and unreliable.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Finding Your Profile Folder<\/strong><\/h2>\n\n\n\n<p>Based on the operating system you use your profile folder\u2019s location depends. The location of the profile is as follows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Operating System<\/strong><\/td><td><strong>Profile Folder Path<\/strong><\/td><\/tr><tr><td>Windows XP \/ 2000 \/ Vista \/ 7 \/ 10<\/td><td>%AppData%MozillaFirefoxProfiles_name.default<\/td><\/tr><tr><td>Linux<\/td><td>~\/.mozilla\/firefox\/profilename.default\/<\/td><\/tr><tr><td>Mac OS X<\/td><td>~\/Library\/Application Support\/Firefox\/Profiles\/profilename.default\/<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Creating a New Firefox Profile<\/strong><\/h2>\n\n\n\n<p>There are three steps to create New Firefox profiles and use the same in the test script. First&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First we need to start the Profile Manager,&nbsp;<\/li>\n\n\n\n<li>Creating a New Custom Profile and&nbsp;<\/li>\n\n\n\n<li>Using the same profile in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Test_script\" data-type=\"link\" data-id=\"https:\/\/en.wikipedia.org\/wiki\/Test_script\" rel=\"nofollow noopener\" target=\"_blank\">Test scripts<\/a>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Starting the Profile Manager<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First close Firefox if it is open. Click on the <strong>File<\/strong> menu at the top of the Firefox window, and click <strong>Exit<\/strong>.<\/li>\n\n\n\n<li>Press \u2018Windows Key <strong>+ R\u2019,<\/strong>&nbsp;and type firefox \u2013 p, and click the OK button.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/MbTUO7WvQzOh_j5ncoFd8uMtrjevCg7UeyqtlAGak1ZEm0ZRuGGF2k5q5FNdK4AD3dyu_VUbOl5dd2DTcdtVe7pEdIFcZJiyINDvpvmYRXDtuc6oOtadokUUySuIClbsY_DfTGQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;After clicking on the \u2018OK\u2019 button and if the Profile Manager window does not seem, it may be opened in the background that needs to be closed properly, you can use the Ctrl+Alt+Del program to kill it. If it still does not open then you can try using the full path, enclosed in quotes.&nbsp;<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&#8220;C: Program FilesMozilla Firefox.exe&#8221; \u2013p: On 32 bit- Windows<\/li>\n\n\n\n<li>Windows: &#8220;C: Program Files(x86)Mozilla Firefox.exe&#8221; \u2013p: On 64 bit<\/li>\n<\/ul>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>A dialogue box choose user profile window will look like<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/CEugkQNqFmnS9_986q9tX3bqxCbZiG0tmW9x_Qt-82gDSj1lWtFOsX-_cWVTE52BPoVC9W1hvkXjeGLVnIRC_rxPu-sls6ER9mTidWywge8JW-mb_bHCxSzQnv9jrZ96x-PiA50\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 2:&nbsp;Creating a Profile<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click on the \u2018Create Profile\u2019 button and Choose User Profile\u2019 window.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/S1Cn8X-0toc9epU0XY4ehwqHjUHLyt2wHwIwBEA_vWETP8HeTd2EwA4ZZF6FAKQw61jh1_CnjrK2UykHh3BURpUM3cjYkG-V-PqHf1vHaPPUcQIERITO4bPZ1fdi8arzDaOBprs\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Click on the <strong>\u2018Next\u2019<\/strong> button in the \u2018Create Profile Wizard\u2019 window.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/3vcUbnsRRmhIlBP9mivhHrm2M8vQOZJBaG_euCQYhHkrUpm-U9273ODRWmt7yBaNrhSfuQEHTY9nkRZKpSb1zDfy__xFr8ThjFckNMy2Gkb5zoaOHl_ei_TRBF4ixoHGG0-41S0\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Type a new name \u2018profileTestQA\u2019 in the \u2018Enter new profile name\u2019 box and click on the \u2018Finish\u2019 button.&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/3aorms2X1vvZ1VBUyrtWy2D1OVGmPljH-f84wOS_PFrklVunObdFUQHTQEjryh3ULHP2GN24vPdz4FxtK9FYN69FmTlJiyVG4MIiv1tzc7APpFRRBwt7jLFz6DKYRkOgTJSY3t0\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>A newly created profile is displayed in the \u2018Choose User Profile\u2019 window.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/rbi-xJ3yObw8FuszjuMNyz473day2KJ4EKe6eDOYCpxzSebZTqo54GmDTDOHfLdtFzc2ISvAKI8hndVWrCeHMXclkl8gLnHoZuwNmCAewa_4FCM3kEeCLRINL5HP8iO4qm64GTM\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Click on the&nbsp;\u2018Start Firefox\u2019 button. Firefox will start with the new profile.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Dset7Ln9vlyNVtGHU0ULXyBKETSURBm9ifgz1XWIL3L8Qh1t7Tkfh_mR-DF7N9AZhzcN39jsrhOLCBK6KoSf-p7QVIUTXifP7cETZsbNqLIBvTB4u-2gKWT7IYtwduPmS2zYyJY\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>Note:<\/strong><strong>&nbsp;<\/strong>Once you click the Start Firefox button you will notice that the new Firefox window will not show any of your Bookmarks and Favourite icons.<\/p>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;The last selected profile will start loading automatically when you next start Firefox and you will need to restart the Profile Manager again to change profiles.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 3: Using the Custom Profile in Selenium Test Script<\/strong><\/h2>\n\n\n\n<p>Once the Profile is created, it needs to be called in the test scripts. To Instantiate the Firefox Driver you need to add the below code to your Test scripts.<\/p>\n\n\n\n<p>ProfilesIni profile = new ProfilesIni();<\/p>\n\n\n\n<p><strong>\/\/ creating an object for the Firefox profile<\/strong><\/p>\n\n\n\n<p>FirefoxProfile myprofile = profile.getProfile(&#8220;profileTestQA&#8221;);<\/p>\n\n\n\n<p><strong>\/\/ initializing the Firefox driver<\/strong><\/p>\n\n\n\n<p>WebDriver driver = new FirefoxDriver(myprofile);<\/p>\n\n\n\n<p><strong>Let see the below examples for implementation of this code.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>package<\/strong> Profile;\n\n<strong>import<\/strong> org.openqa.selenium.WebDriver;\n<strong>import<\/strong> org.openqa.selenium.firefox.FirefoxDriver;\n<strong>import<\/strong> org.openqa.selenium.firefox.FirefoxOptions;\n<strong>import<\/strong> org.openqa.selenium.firefox.FirefoxProfile;\n<strong>import<\/strong> org.openqa.selenium.firefox.internal.ProfilesIni;\n<strong>public<\/strong> <strong>class<\/strong> FirefoxProfiles {\n<strong>public<\/strong> <strong>static<\/strong> <strong>void<\/strong> main(String[] args) <strong>throws<\/strong> InterruptedException {\nSystem.<em>setProperty<\/em>(\"webdriver.gecko.driver\", \"C:\\\\Users\\\\Selenium\\\\geckodriver.exe\");\nProfilesIni profile = <strong>new<\/strong> ProfilesIni();\nFirefoxProfile fireFoxProfile = profile.getProfile(\"abcProfile\");\nFirefoxOptions opt = <strong>new<\/strong> FirefoxOptions();\nopt.setCapability(FirefoxDriver.PROFILE, fireFoxProfile);\nWebDriver driver = <strong>new<\/strong> FirefoxDriver(opt);\ndriver.get(\"https:\/\/www.google.com\");\n\n\/\/Set the timeout&nbsp; for 5 seconds for the page to load within that time\ndriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);\n\nSystem.<strong><em>out<\/em><\/strong>.println(driver.getTitle());\ndriver.close();\ndriver.quit();\n\n}\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion:<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Firefox profile is a user personalized setting that consists of the user\u2019s bookmarks, plugins, extensions, and saved passwords that can be done on the Firefox Browser.<\/li>\n\n\n\n<li>Firefox profile should be such that it must easy to load and should have some user-specific proxy settings to run the test.<\/li>\n\n\n\n<li>We need to use web drivers inbuilt class &#8216;profilesIni&#8217; and its method getProfile in Selenium Webdriver to use the newly created Firefox profile.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Call to Action<\/h2>\n\n\n\n<p>Ready to elevate your Selenium testing skills? Join H2K Infosys for an in-depth guide on &#8220;Creation of Firefox Profile in Selenium WebDriver.&#8221; Our expert-led course will walk you through each step of creating and customizing Firefox profiles, enabling you to control browser settings, extensions, and preferences tailored to your test scenarios. <\/p>\n\n\n\n<p>Learn how to enhance test performance and reliability by using personalized profiles, making your scripts more robust and efficient. This training will equip you with the practical skills to tackle real-world testing challenges and optimize automation setups. Enroll with H2K Infosys today and become a skilled Selenium WebDriver professional with advanced Firefox profile techniques!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Firefox Profile? A Firefox profile is a user-personalized setting that consists of the user\u2019s bookmarks, plugins, extensions, and saved passwords that can be done on the Firefox Browser. When Firefox is installed, it creates a profile folder by default in your local drive that saves information like passwords, bookmarks, etc. You can have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7691,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-7686","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium-tutorials"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/7686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=7686"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/7686\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/7691"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=7686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=7686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=7686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}