Desired Capabilities - The Missing Manual


#1

One of the biggest hurdles with using Katalon/Webdriver is setting the appropriate Desired Capabilities that configure various browser settings programmatically. There are a couple of reasons for this:

1.) Browsers do not expose these back-end properties in the settings menu. Instead, they offer a user-friendly GUI for configuring settings that are based on these properties. This of course makes sense for 99.9999% of browser users, but isn’t helpful for us.

2.) The appropriate Desired Capability for any given setting is constantly in flux. As a result, it’s always a moving target to get the appropriate settings. I’ve found this to be particularly true with Chrome… :unamused:

I thought I’d share my approach to isolating the EXACT back-end properties that a browser uses for any given setting, which allows you to “easily” manage the Desired Capabilities for automated testing purposes.

As an example, lets try to figure out which Desired Capability should be used to handle the following Chrome notification, which often appears when trying to download certain files from a web page (thanks to @ Patrick_Clough, I’m stealing your screenshot out of sheer laziness):

image

This is a browser-level notification, thus we will need a Desired Capability to ensure that this notification never appears, and we can download files to our heart’s content.

  • Step 1: Get a snapshot of the Preferences file for the browser instance, BEFORE clicking “Keep”.

    1.) Open a new tab in the browser.
    2.) Enter chrome://version in the address bar and press Enter
    3.) The following page will appear:

    4.) Copy the “Profile Path” from this page, and enter it into your file explorer:

    5.) Open the “Preferences” file in a text editor:

  • Step 2: Copy this JSON data into a formatter (this is optional, but I would highly recommend you do so).

    Note: A good online JSON formatter can be found here.

  • Step 3: Click the “Keep” button for the notification. Wait a few seconds for Chrome to update the Preferences file.

  • Step 4: Get a snapshot of the Preferences file for the browser instance, AFTER clicking “Keep”, following the same steps as above, and format it as well.

  • Step 5: Use a text diff tool to compare the two JSON forms, and voila, we can see the following diff:

    Note: The text diff tool I used in the above screenshot can be found here.

Using this approach, we have discovered that the following desired capability must be added in Katalon in order to handle this notification:


Loading of unpacked extensions is disabled by the administrator
How to set the chrome options value "setExperimentalOption("useAutomationExtension", false)"
Override desired capabilities at runtime
Changing the download path dynamically during runtime
Is it possible to begin a script with a Browser already opened?
How to use Desired Capabilties to handle browser notifications (was: ALERT of Facebook/ Unable to dismiss or accept)
Unable to disable pop up notifications in Chrome
How to set the chrome options value "setExperimentalOption("useAutomationExtension", false)"
how to use NOT IN "Chrome is being controlled by automated test software", but in normal mode?
How to handle browser alert popup? Is there is kayword to handle this?
Open Browser with Custom Profile
How to handle geolocation pop up
#2

#3

Pure, unadulterated, gold.

(Long overdue for me, anyway).


#4

Randon,

Thank you very much for your valuable post. This gave me a clue to solve my problem:


#5

Really wonderful @Brandon_Hein :heart_eyes:


#7

Hi @Brandon_Hein

Thanks for the detailed instruction.

Can you please advise how to do the same thing (Disable browser notification level) on Safari?

Kind Regards


#8

Hi @Brandon_Hein ! Thanks for this post. I was able to solve a big problem. In addition, if it is always required to allow notifications, simply set the value of the profile.default_content_setting_values.notifications variable to 1.0. This will change the browser settings and will default to “always allow”.

Hope it helps somebody!

Regards.


#9

My directory ends at Temp, does that matter?

Are you referring to the Preference file in Katalon?

I am wanting to continue my script with a Browser that is already open, but it opens a fresh browser w/o my saved settings.


#10

No, it doesn’t matter. This is where chrome will place all of it’s config files by default.

No, there should be a Preferences file in the Temp directory you have navigated to. This is a chrome config file essentially.


#11

Sorry, I’ve never work with Safari, but I imagine that it can be configured in a similar manner as all other browsers. You will likely need to look outside of the Katalon forums for Safari-specific questions.


#12

Question:

I am at Step 3, but not sure where the “Keep” button is located. I only see a Save Online, or Download.


#13

I was only using that particular alert as an example of how to configure a Desired Capability. A browser can present you with a bunch of different alerts, each with its own setting.


#14

Ok cool Im almost there!! On the final step. Did you create a temp Katalon folder in the C drive?


#15

Yes, but that was just for my sanity. Browsers generally place downloaded files into a “Downloads” folder (on Windows), so I just have it configured to download to a separate directory.


#16

And in this downloads folder did u include that preferences file in there also?


#17

No, that’s just where I’ve told chromedriver to put downloaded files. Nothing more, nothing less.


#18

So would you recommend me creating the folder in the C drive? or continue into creating the Number & boolean?


#19

Those are just other desired capabilities that I’ve set up for myself. You can use them as well, but they have nothing to do with the alert you are trying to handle.


#20

Ok so question. How can I verify that this worked? When I launch my chrome browser to the site it still has the Flash popup blocker.

Do I need to be logged into my gmail and launch Chrome?


#21

No, chromedriver doesn’t consider any other processes running on your computer.

Then either 1.) the desired capabilities you’ve configured are not set correctly, or 2.) the flash settings are not a browser-level setting, and thus cannot be handled using desired capabilities. I don’t think it’s number 2.