tags:

views:

49

answers:

1

i tried the below code but req/response is not captured??

String trafficOutput = selenium.captureNetworkTraffic("xml");
          selenium.type("q", "selenium rc");
          selenium.click("btnG");
          selenium.waitForPageToLoad("30000");

          selenium.open("/#hl=en&source=hp&q=selenium+rc&btnG=Google
+Search&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=ff64793e1cab64b9");
                selenium.click("//ol[@id='rso']/li[1]/h3/a/em");
                selenium.waitForPageToLoad("30000");
                selenium.click("link=Selenium Core");
                selenium.waitForPageToLoad("30000");
                selenium.click("link=our documentation");
                selenium.waitForPageToLoad("30000");
                selenium.click("link=Projects");
                selenium.waitForPageToLoad("30000");
        //  assertTrue(selenium.isTextPresent("Results * for selenium
rc"));

            String  resposneText =  selenium.getHtmlSource();
             DataOutputStream  dos = new DataOutputStream(new
FileOutputStream("output", true));

              System.out.println("value is-------- "+trafficOutput);
              System.out.println("val is "+resposneText);

               dos.writeBytes(trafficOutput);
                dos.close();

but no req/response this case?? getting value for System.out.println("val is "+resposneText);

A: 

captureNetworkTraffic will return the traffic that has passed through Selenium Remote Control. When you call it you will get the log of traffic that has occured. This is probably what you want but if you want to be testing JavaScript it might be worth using something like jsTestDriver.

When you call getHTMLSource() it will return all the HTML that is on the page, or in the frame selenium is currently in, back to the test. You can then do other tests with the HTML.

AutomatedTester
problem is that output is empty and what if i want to capture all clicks request/response??
sasikumar
This sounds like you want to use Wireshark with your tests.
AutomatedTester