Advertise

Sunday, October 25, 2009

Selenium SSL Site Testing / Secure [HTTPS] Site Testing

Selenium SSL Site Testing / Secure [HTTPS] Site Testing


Selenium Secure Site [HTTPS] Testing



Below are steps that need to be followed to Test HTTPS – Secure Site :

Selenium uses its own Certificate for all https-connections, the Certificate is Cybervilian Certificate. We have to import the certificate into your Internet Explorer.

Please follow below steps to import Cybervilian Certificate.

1.Open Internet Explorer.
2.Navigate to Tool->Option.
3.Click on content Tab.


1.Now click on certificates button.


5.Click on Import button.

6.Click on Next > button.
7.Click on browse button.



8.Import cybervilliansCA .
9.Click on Next > button.
10.Again Click on Next > button.
11.Click on Finish button.
Image will be displayed as below on succesfull import of certificate.


12.Now open secure site:
Example: https://herald.cybage.com/exchange
13.Security Alert will be shown as below:


14. Click on View Certificate button.
15.Click on Install Certificate button .



16.Click on Next > button.

17.Click on Next > button.

18.Click on Finish button.
On Succesfull import of certificate

19.Click on yes button, After successful import of certificate .

20.Now you can run your Test Case.

First time while running HTTPS Test Case you may find alert box will be shown , click on OK and remember my decision .

Below example is used by be to Test my official Email Site, though password has been changed by me for confidential reason:

Below code is used to connect HTTPS site in Internet Explorer .


package Selenium;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class CertificateTest extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("https://herald.cybage.com/exchange", "*iexplore");
}
public void testSecureSite() throws Exception {
selenium.open("/exchweb/bin/auth/owalogon.asp?url=https://herald.cybage.com/exchange&reason=0");
selenium.type("username", "XXXXXX");
selenium.type("password", "XXXXXX");
selenium.click("SubmitCreds");
}
}























To run Test Case in Firefox . Please follow below steps:
1.Close all instance of Firefox .
2.Start Firefox from command prompt using command: firefox –ProfileManager


1.Create a new profile. You'll be prompted to choose a directory for the profile.
2.Select the profile and run Firefox using it.
3.Browse to the HTTPS URL (with self-signed certificate) you're going to be testing against.
4.Accept the self-signed certificate when prompted. This creates an exception for it in the profile.
5.Close the browser.
6.Go to the Firefox profile directory.
7.Delete everything in the directory except for the cert_override.txt and cert8.db files.
8.Start Selenium Server using below command:
When you run your Selenium server pass a
-firefoxProfileTemplate /path/to/profile/dir argument to it. This tells Selenium to use your partial profile (with certificate exceptions) as a basis for minting its new profile.














package Selenium;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class CertificateTest extends SeleneseTestCase {

public void setUp() throws Exception {
setUp("https://herald.cybage.com/exchange", "*firefox");
}

public void testSecureSite() throws Exception {
selenium.open("/exchweb/bin/auth/owalogon.asp?url=https://herald.cybage.com/exchange&reason=0");
selenium.type("username", "XXXXX");
selenium.type("password", "XXXXX");
selenium.click("SubmitCreds");
}

No comments:

Post a Comment