I am using selenium.open(), to open a URL, which prints the cookie output to the browser window:
String cookiestr = "http://my.server.com/cookie?out=text";
selenium.open( cookiestr );
The problem is that, it opens a "Save As..." popup, to save the file named "cookie". When I open the same URL in my browser directly, it displays text in the browser window.
I want to capture the body text shown, when I open the URL, but am unable to do so. Is there any other command available which I can use to do this?
BufferedWriter outputfile = null;
String bodytext = selenium.getBodyText();
System.out.println("Body Text :" + bodytext);
Integer I = new Integer(i);
filename = "C:\\cookies\\" + I.toString() + ".txt";
outputfile = new BufferedWriter(new FileWriter( filename ));
outputfile.write( bodytext );
outputfile.newLine();开发者_运维问答
i++;
your cookie
servlet should set content type:
response.setContentType("text/plain");
精彩评论