Friday, January 31, 2014

Handling HTTPS in Selenium Remote Control

 Create RemoteControlConfiguration object  and rcc.setTrustAllSSLCertificates(true);  
Pass the RC Object to Selenium server

 public void setUp() throws Exception {
        String seleniumHost ="localhost";
        String seleniumPort = "3737";
        String seleniumBrowser = "*firefox";
        String seleniumUrl = "Base URL";
        RemoteControlConfiguration rcc = new RemoteControlConfiguration();
        rcc.setTrustAllSSLCertificates(true);
        rcc.setSingleWindow(false);
        rcc.setPort(Integer.parseInt(seleniumPort));
      try {
            server = new SeleniumServer(rcc);
            server.boot();
        } catch (Exception e) {
            throw new IllegalStateException("Can't start selenium server", e);
        }
        proc = new HttpCommandProcessor(seleniumHost, Integer.parseInt(seleniumPort),
        seleniumBrowser, seleniumUrl);
        selenium = new DefaultSelenium(proc);
        selenium.start();
    }