How to import and select user certificate for login with selenium and Java?

Viewed 127

I'm trying to solve the 2-factor authentication Problem and do not have solution. I tried a lot of code from different forum but it do not works. may be some persons could help with clear and functional java code.

For my project I am attempting to create a Selenium WebDriver test suite for. This site is intended to be protected by 2-factor authentication. The 2-factors would be use to deliver a certificate which would authenticate with the server.

At the moment, we have have it so that we access the server with a url beginning with "https://". When we go the url (in firefox) we see a pop-up labeled "User Identification Request" with a dropdown with the label "Choose a certificate to present as identification:".

Earlier, I added the certificate (labeled "client1.p12") by going to Options->Privacy & Security->Certificates->View Certificates, selecting the "Your Certificates" tab, clicking "Import", browsing to the "client1.p12" file and entering the password. By doing this, I can now see the appropriate certificate in the "Choose a certificate to present . . . " dropdown.

The question I have is how do I set-up Selenium WebDriver to select the certificate. The pop-up described above is a Windows component (not html), so I cannot simply click and select the certificate. I am also trying to use the headless option for geckodriver.

Thank you a lot for your support and help.

(the description of problem , is from a member of Stackoverflow ...I tried his solution but it do not work)

0 Answers
Related