Security Certificates

PROBLEM

Security (SSL) Certificates are tricky to automate because each browser prompts its warning differently. Because Test Studio only records in Internet Explorer, the "Continue to this website" link pictured below is recorded and expected to pass when executed in IE. That specific link does not exist in the other browsers, so we expect the test to fail at that step in Firefox, Safari, and Chrome.

 

 

Click a thumbnail to see that browser's Certificate Warning:

Firefox Safari Chrome

SOLUTION

There are a few work-arounds to consider:

  1. Change the browser settings to not prompt for certificates. In Firefox this setting is located under:
    • Tools > Options > Advanced > Encryption > Certificates > Select one automatically
  2. Add a Manual Step. This will require the tester to manually accept the certificate during test execution and then press OK on the Manual Step dialog to continue. You can set the Manual Step's "RunsAgainst" property to "FirefoxOnly" and set the step that clicks the link in the image above to "InternetExplorerOnly". This way, executing in IE remains automated and only executing in an alternative browser requires manual intervention.
  3. Add a Coded Step. The code will perform different actions (such as mouse clicks and/or key presses) based on which browser is used. This will handle the different Certificate screens you encounter across browsers. Here's an example for Chrome:
  4.  

    C#

    if (ActiveBrowser.BrowserType == BrowserType.Chrome)
    {
        Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
        Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Space);
    }

     

    Visual Basic

    If ActiveBrowser.BrowserType = BrowserType.Chrome Then
        Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab)
        Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Space)
    End If

     

    Ensure you Add an Assembly Reference to System.Windows.Forms.