Pages

Search This Blog

Wednesday, May 19, 2010

How to handle SSL certificate issue in Selenium / firefox

Selenium creates a new and clean profile each time it runs a test, so it won't keep any cookies of the previous session and it wont use any browser plug-in however you can force selenium to use your own profile.

Steps
1. Close all instances of firefox browser.
2. Create a new firefox profile : Go to Run and type firefox -p and press OK . This will open a dialog bod where you create new firefox profile, have a name "nk" and save it in C: drive.
3. Install all plug-ins in this profile ; For SSL certificate issue install SSL security bypass

https://addons.mozilla.org/en-US/firefox/addon/10246/

4. Now you write you test cases like below

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.*;
import com.thoughtworks.selenium.*;
import java.io.File;

public class firefoxprofile extends SeleneseTestCase {

private SeleniumServer seleniumServer;
private Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";

@BeforeClass
public void setUp() throws Exception {

File template = new File("C:\\nk");
RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
rc.setFirefoxProfileTemplate(template);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/");
seleniumServer.start();
selenium.start();

}


@Test
public void googling() {
selenium.open("/");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
selenium.type("q", "http://automationtricks.blogspot.com");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("http://automationtricks.blogspot.com"));
}


@AfterTest
public void tearDown() throws InterruptedException{
selenium.stop();
seleniumServer.stop();

}
}

5 comments:

  1. This is a great technical spec for an ssl installment. thanks

    ReplyDelete
  2. plz help me for version 7.0.1 as i am facing same problem to install remember certificate as it is not compatable with the mentioned version

    ReplyDelete
  3. Parkinson's disease affects my driving slipped off my tenuous physical structure Spell I wasn't lovingness.


    Here is my web site; Wattenburg Parkinson'S Disease Specialists

    ReplyDelete
  4. Hi there to every single one, it's genuinely a fastidious for me to pay a quick visit this web page, it contains priceless Information.

    Also visit my web-site ... USB thumb drives

    ReplyDelete