Favourite Quote

Every artist was first an amateur. - Ralph Waldo Emerson The more difficulties one has to encounter, within and without, the more significant and the higher in inspiration his life will be. - Horace Bushnell

Wednesday, November 17, 2010

How to Capture Network Traffic using Selenium

CapturingNetwork Traffic - It could be used to know details such as the browser information.

public class Epc extends SeleneseTestCase
{
public static SeleniumServer selServer;
public static DefaultSelenium selenium;
final String URL = "http://10.10.7.48:38080/";
int port = Constants.PORT;
String browser = Constants.BROWSER;

public void setUp() throws Exception
{
if(selServer == null)
{
try
{
RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.trustAllSSLCertificates();
selServer = new SeleniumServer(rc);
selServer.start();
}catch(Exception e)
{
e.printStackTrace();
}
}
}



public void testWebservices() throws Exception
{
selenium = new DefaultSelenium("localhost",Constants.PORT,Constants.BROWSER,URL);
selenium.start("captureNetworkTraffic=true");
selenium.open("/epc-client");
String trafficOutput = selenium.captureNetworkTraffic("plain");
System.out.println("\nNetwork Traffic captured in plain format !!!!"+trafficOutput);
pause(Constants.MAX_WAIT_TIME_MS);
selenium.windowFocus();
selenium.windowMaximize();
selenium.useXpathLibrary("javascript-xpath");
pause(Constants.MAX_WAIT_TIME_MS);
selenium.click("link=Search UPRN by Address Web Service");

}
}

public void tearDown()
{
selenium.stop();
selServer.stop();
}

} automationwithselenium.blogspot.com-Google pagerank and Worth

1 comment:

  1. i have ran the same code in my machine and my URL is www.google.co.in
    But Ouput in console displayed as
    []

    rather than this nothing is displaying in console.

    Please help me to get the correct output

    ReplyDelete