How to setAcceptUntrustedCertificates for Safari.

2019-07-25 11:23发布

With version 2.30, selenium webdruiver has given in built support for Safari browser.

I want to know how to handle SSL Certificates in Safari (which is installed on Windows).

Below piece of code I tried but its not working:

DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capabilities.setBrowserName("SAFARI");


        driver = new SafariDriver(capabilities);
        driver.get("https://MYDUMMYSITE");

1条回答
欢心
2楼-- · 2019-07-25 11:49

I have countered the same problem. It seems that the Safari browser is using the same certification mechanism as Internet Explorer, and theoretically, you can use it to install certification and it should solve the problem. Instruction can be found here

This did not work for me, so I used AutoIt script to click on the continue button, compiled the script the EXE and called it from my test.

The script I used:

WinWait("[CLASS:#32770]","",60) 
WinActivate("[CLASS:#32770]","")
Send("{SPACE}")

Baiscally, it will wait 60 seconds for the "Safari can't verify the identity of the website" message, set the window on focus and click on the space bar button.

查看更多
登录 后发表回答