Articles
Help Articles
Using Firefox Profile with Selenium Desired capabilities - Permissions & Extensions
Firefox profile, Firefox, Permission, Pop-ups, desired capabilities, Extensions and auto download files

Why should we use a Firefox profile?

1) Manage Permissions:

If your website prompts you with a lot of pop-ups about permissions or access, or to choose what to do with saved files we can overcome it using a firefox profile.
2) Using browser extension
Using Firefox profile allows you to start your execution and extensions pre installed.

How to do this with TestProject? (first, we need agent version 3.2.0 and above)

To use Selenium Desired capabilities we first need to create a job. then we should assign all the tests we need a firefox profile into this job.
Where can we find the Firefox profile?
Firefox keeps the profile locally in a different location in each system.
you can see the path to the profile folder by opening Firefox browser, and search in the URL search bar the address:
1
about:profiles
Copied!

What is the Best Practice?

What we should do, is to create a designated profile for us to use in our jobs.
1) We can do it by adding a firefox profile like this:
Open Firefox browser, and search in the URL search bar the
address:
1
about:profiles
Copied!
then click on Create a New Profile
2) After we have created the firefox profile we need to open firefox with this profile and add our application URL to the permissions we need.
(use about:profiles to check current profile)
3) We can set the following Selenium Desired capabilities on our job:
And add these capabilities:
1
{
2
"moz:firefoxOptions": {
3
"profile_path": "C:/Users/{userName}/AppData/Roaming/Mozilla/Firefox/Profiles/{profile}"
4
}
5
}
Copied!
*Don't forget to replace {userName} and {profile} with your directory*

Using Firefox Profile to Auto download files (GUI / Headless)

If you want to automatically download files and avoid the download window pop-up you will need to add your type file to Firefox applications settings and change it to save files.
To change these settings follow these steps:
1) Navigate to your application and download the file that will be used in the test. Open it with a default app and tick the check box (do this automatically for files like this from now on)
For example zip file (open with WinRar):
2) Click on the zip file option in Firefox settings under the Applications section and change it from always ask to save the file, this will automatically save the file to the default directory.
*Note - Firefox ability to automatically save the content type may vary dependent on the file type*

Use already made base64 profile that contains the following MIME types:

1
application/msword
2
application/ms-doc
3
application/doc
4
application/pdf
5
text/plain
6
application/text
7
text/xml
8
application/xml
9
text/csv
10
application/xlsx
11
application/yaml
12
application/json
13
application/java-archive
14
image/jpeg
15
application/zip
16
application/octet-stream
Copied!
Firefox base64 Job capabil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x1w55mESzY58ChdKadzvWptFG/sOc7EW9wePr0z27ZfzgpKF6sS625WQyA5+6oguoaY66Kik4pY0NLCMKXC0vanCGOjtYNdVy8oEt4vFp08cfeYsHHzudKPwiTNsr3czX02dCbfbsVBmxbjLhRR5DiC3Knp+5Wl2xlnKWhcpOeo9ov4jJHjiGSpOT2XgaHiSj0yx0O05Cm+KXXRgSTj7MFPK97JkUs2+M5juio3KLTTNwKLeUikKTsyctFzEZf8RRDJm2PjaN01f90PY2Z1u6faFLmqyVkRl1kcQ6cKbNyvIVdntmwpR6esVECWL9uc1tf7Ur7y+TjGeZjErxmaIx+i/0s/9AyhRFnNx3h5Nl4ijcGo0fKI1SA59KFQHVsii9mimMAwN08LOKGsgGvkVsOh2cKH3oeWKPSjBTpznT9BxiXeUYbFv+D+3I/1BLBwhquWbIOwQAAF4OAABQSwECFAAUAAgICAAwc2dTarlmyDsEAABeDgAABwAAAAAAAAAAAAAAAAAAAAAAdXNlci5qc1BLBQYAAAAAAQABADUAAABwBAAAAAA="
4
}
5
}
Copied!

Use Firefox Profile with the open SDK (Java code)

You can pass the profile in several ways:
1. You can create a fresh profile and set preferences for it, and then set that profile in the options.
Here is an example of how to set preferences to download files automatically in Firefox without presenting the dialogue:
1
FirefoxOptions options = new FirefoxOptions();
2
FirefoxProfile profile = new FirefoxProfile();
3
profile.setPreference("browser.download.folderList", 2);
4
profile.setPreference("browser.download.dir", "C:\\Temp");
5
profile.setPreference("browser.download.useDownloadDir", true);
6
profile.setPreference("browser.download.viewableInternally.enabledTypes", "");
7
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword;application/ms-doc;application/doc;application/pdf;text/plain;application/text;text/xml;application/xml");
8
options.setProfile(profile);
9
FirefoxDriver driver = new FirefoxDriver("{TP_DEV_TOKEN}", options);
Copied!
2. You can also create a profile out of a local path on your system:
1
FirefoxOptions options = new FirefoxOptions();
2
FirefoxProfile profile = new FirefoxProfile(new File ("C:/Users/Username/AppData/Roaming/Mozilla/Firefox/Profiles/MyProfile.test"));
3
options.setProfile(profile);
4
FirefoxDriver driver = new FirefoxDriver("{TP_DEV_TOKEN}", options);
Copied!