我尝试了下面的代码,但是请求/响应没有被捕获??
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();但是在这种情况下没有请求/响应吗?
获取价值
System.out.println("val is " + resposneText);发布于 2010-09-07 04:50:52
captureNetworkTraffic将返回通过Selenium Remote Control的流量。当您调用它时,您将获得已发生的流量的日志。这可能是您想要的,但是如果您想测试JavaScript,可能值得使用像jsTestDriver这样的东西。
当您调用getHTMLSource()时,它会将页面上或selenium当前所在的框架中的所有超文本标记语言返回给测试。然后,您可以使用HTML进行其他测试。
发布于 2011-02-11 05:54:08
我不知道你是否还需要一个答案,但是在你做了一些事情之后必须调用captureNetworkTraffic。您必须执行一个selenium.start("captureNetworkTraffic=true"),它将告诉服务器开始捕获,完成所有导航,然后调用selenium.captureNetworkTraffic("xml")。然后你就有了数据,但据我所知,它并没有捕获响应,只是捕获了请求。
https://stackoverflow.com/questions/3650454
复制相似问题