Robot Framework : How to handle the "Select a Certificate" popup which is having multiple certificates in chrome?

Robot Framework: How to handle the “Select a Certificate” popup which is having multiple certificates in chrome and selecting a specific certificate and clicking on OK?

We have code using Sikuli but the code is not working for headless mode.

Expectation: Code should run in head/headless mode without any issues by using Robot framework selenium libraries or any other libraries.

Scenario: I have multiple certificates for the website and have to choose a specific certificate according to the scenario select 1 at a time and click on ok.

[“Select a Certificate” popup] Image Link https://i.stack.imgur.com/cJnYq.png

Note:

  1. Tried adding certificate details in Registry Key. As it will handle multiple certificates. But if we need to understand which certificate is taken from the entry key.

Please help on finding the specific code to handle in the Robot framework.

Hi,

Have you tried following the registry approach described officially here? And since that’s Chromium based, maybe it will work best if you use RPA.Browser.Playwright instead of Selenium. (see example robot and coda.yaml)

channels:
  # Define conda channels here.
  - conda-forge

dependencies:
  # Define conda packages here.
  # If available, always prefer the conda version of a package, installation will be faster and more efficient.
  # https://anaconda.org/search
  - python=3.9.13
  - nodejs=16.14.2

  - pip=22.1.2
  - pip:
      # Define pip packages here.
      # https://pypi.org/
      - robotframework-browser==13.3.0
      - rpaframework==15.5.0 # https://rpaframework.org/releasenotes.html

rccPostInstall:
  - rfbrowser init

Other useful related resources:

So long story short, if the certs are set correctly, the browser should be automatically picking them based on the URL matching the pattern configured for the certificate you want to be used. And in case Chrome from Selenium doesn’t work as expected (still asking for them), try with Chromium from Playwright as suggested.


On the other hand, going forward with Selenium, I couldn’t find in their docs any certificate setup, but at least you can ignore them as seen in this robot example. (where I extended our Selenium library with the following capabilities)

On the Playwright side, I see there’s an awaited upstream feature request still open on supporting this programatically. Therefore I believe a valid registry certs setup (with URL patterns) is your best shot, good luck!

Hi,

Thanks for your valuable response.

I have tried using the Registry Key. But the scenario is if you have multiple certificates registered in the Registry Key When it reaches the particular point in the application we are not sure which certificate has been taken.

And tried using RPA.Browser.Playwright (Handle Future Dialogs) to handle the “Select a Certificate” popup. But it did not work.

Regards,
ViswaBharath

I understand.

For the non-headless mode, if you still want to pick them at runtime and if you’re running on an env rendering the UI, you can use Desktop automation to navigate the certs with arrows and select the one you want using the Enter key with any of:

Running in headless mode on a env that doesn’t have an UI rendered, doesn’t allow you to do this and since programatically I couldn’t find a way to configure the cert you want to navigate with, then I believe you should assume that the selected one is the one matching the URL you’re currently navigating, as configured in the registry (if there’s one cert per match).


After I dug it more, we might have a few more options with Selenium and Chrome:

Look into the logs

Use this ExtendedSelenium.py as a local library placed inside your robot root, then import it with

Library    ExtendedSelenium

and navigate using

Open Site    ${URL}    browser=chrome

then retrieve the logs with

@{logs_topics} =     Create List    browser    driver    performance
FOR    ${log_topic}    IN    @{logs_topics}
    ${logs} =    Print Webdriver Log    ${log_topic}
END

and hopefully you can find certificate (Network related) info among these logs.

Additional related info:

Passing cert file as CLI arg

I was also having this problem recently while helping someone out… the only other thing I found was Firefox’s automatic selection of certificates. After selecting a certificate once for a website, Firefox remembers the choice inside the user’s profile. So, based on this, you could create a new profile for each website/certificate combo you care to use and then load the browser in the bot with the specific profile you need to access the site when you run the bot. You just need to save the resulting profiles into the source as a resource for the bot.

In order to load those profiles, in Playwright, you use the New Persistent Context keyword, and in Selenium, the use_profile, profile_name, and profile_path arguments on the Open Available Browser keyword.

1 Like