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:

about:profiles

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:

about:profiles

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:

{
"moz:firefoxOptions": {
"profile_path": "C:/Users/{userName}/AppData/Roaming/Mozilla/Firefox/Profiles/{profile}"
}
}

*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:

application/msword
application/ms-doc
application/doc
application/pdf
text/plain
application/text
text/xml
application/xml
text/csv
application/xlsx
application/yaml
application/json
application/java-archive
image/jpeg
application/zip
application/octet-stream

Firefox base64 Job capabilities:

{
"moz:firefoxOptions": {
"profile": "UEsDBBQACAgIADBzZ1MAAAAAAAAAAAAAAAAHAAAAdXNlci5qc52XS2/jNhCA7/0VhU8tUDPJpnvZnNJsFlggaIrNBnsUKGok0aZIlkNadn99h5IVW5YsOXsTyeFjZr55KCC4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Oeo9ov4jJHjiGSpOT2XgaHiSj0yx0O05Cm+KXXRgSTj7MFPK97JkUs2+M5juio3KLTTNwKLeUikKTsyctFzEZf8RRDJm2PjaN01f90PY2Z1u6faFLmqyVkRl1kcQ6cKbNyvIVdntmwpR6esVECWL9uc1tf7Ur7y+TjGeZjErxmaIx+i/0s/9AyhRFnNx3h5Nl4ijcGo0fKI1SA59KFQHVsii9mimMAwN08LOKGsgGvkVsOh2cKH3oeWKPSjBTpznT9BxiXeUYbFv+D+3I/1BLBwhquWbIOwQAAF4OAABQSwECFAAUAAgICAAwc2dTarlmyDsEAABeDgAABwAAAAAAAAAAAAAAAAAAAAAAdXNlci5qc1BLBQYAAAAAAQABADUAAABwBAAAAAA="
}
}

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:

FirefoxOptions options = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "C:\\Temp");
profile.setPreference("browser.download.useDownloadDir", true);
profile.setPreference("browser.download.viewableInternally.enabledTypes", "");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword;application/ms-doc;application/doc;application/pdf;text/plain;application/text;text/xml;application/xml");
options.setProfile(profile);
FirefoxDriver driver = new FirefoxDriver("{TP_DEV_TOKEN}", options);

2. You can also create a profile out of a local path on your system:

FirefoxOptions options = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile(new File ("C:/Users/Username/AppData/Roaming/Mozilla/Firefox/Profiles/MyProfile.test"));
options.setProfile(profile);
FirefoxDriver driver = new FirefoxDriver("{TP_DEV_TOKEN}", options);
Did this answer your question?