As all we know selenium is used for automating web application. We will not have any difficulty in automating HTTP site...We face some of the below issues while automating HTTPS sites..
HTTPS sites will show some security notifications below are some:
Firefox:
Internet Explorer:
2. Set TrustAllSSLCertificates flag to TRUE
rcc.setTrustAllSSLCertificates(true);
3. Pass the rcc Instance to Selenium Server
SeleniumServer server = new SeleniumServer(rcc);
If the above steps also doesnt work you need to install cyber villian certificate to automate HTTPS sites (Especially for IE)
1. Extract selenium-server.jar
2. In selenium server folder Open sslSupport folder
3. It contains cybervillainsCA.cer please install that certificate
Now you can run your selenium rc scripts with out any problem for HTTPS sites.
Below is the code with out the Above steps:
====================================
package selenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
@SuppressWarnings("deprecation")
public class HTTPs extends SeleneseTestCase{
public SeleniumServer ss;
@Before
public void setUp() throws Exception
{
ss=new SeleniumServer();
ss.start();
selenium=new DefaultSelenium("localhost", 4444, "*firefox", "https://www.dibbs.bsm.dla.mil/");
selenium.start();
}
@Test
public void testSelenium() throws Exception
{
selenium.open("/");
selenium.windowMaximize();
Thread.sleep(5000);
}
@After
public void tearDown() throws Exception
{
selenium.stop();
ss.stop();
}
}
HTTPS sites will show some security notifications below are some:
Firefox:
Internet Explorer:
To over come this issue we need to add certification
1. Need to add remote control configuration
RemoteControlConfiguration rcc = new RemoteControlConfiguration ();
rcc.setTrustAllSSLCertificates(true);
3. Pass the rcc Instance to Selenium Server
SeleniumServer server = new SeleniumServer(rcc);
If the above steps also doesnt work you need to install cyber villian certificate to automate HTTPS sites (Especially for IE)
1. Extract selenium-server.jar
2. In selenium server folder Open sslSupport folder
3. It contains cybervillainsCA.cer please install that certificate
Now you can run your selenium rc scripts with out any problem for HTTPS sites.
Below is the code with out the Above steps:
====================================
package selenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
@SuppressWarnings("deprecation")
public class HTTPs extends SeleneseTestCase{
public SeleniumServer ss;
@Before
public void setUp() throws Exception
{
ss=new SeleniumServer();
ss.start();
selenium=new DefaultSelenium("localhost", 4444, "*firefox", "https://www.dibbs.bsm.dla.mil/");
selenium.start();
}
@Test
public void testSelenium() throws Exception
{
selenium.open("/");
selenium.windowMaximize();
Thread.sleep(5000);
}
@After
public void tearDown() throws Exception
{
selenium.stop();
ss.stop();
}
}
=============================================
If you run the above script it will give you an error..see the below image
To avoid that error please use below code:
================================================
package selenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
@SuppressWarnings("deprecation")
public class HTTPs extends SeleneseTestCase{
public SeleniumServer ss;
@Before
public void setUp() throws Exception
{
RemoteControlConfiguration rcc=new RemoteControlConfiguration();
//trust all ssl certificates
rcc.setTrustAllSSLCertificates(true);
ss=new SeleniumServer(rcc);
ss.start();
selenium=new DefaultSelenium("localhost", 4444, "*firefox", "https://www.dibbs.bsm.dla.mil/");
selenium.start();
}
@Test
public void testSelenium() throws Exception
{
selenium.open("/");
selenium.windowMaximize();
Thread.sleep(5000);
}
@After
public void tearDown() throws Exception
{
selenium.stop();
ss.stop();
}
}
========================================================
The three lines which are in blue will make your browser to trust all SSL certificates..
Hope this post will be useful..