views:

132

answers:

1

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++;
+1  A: 

your cookie servlet should set content type:

response.setContentType("text/plain");
Bozho
hi! thanks for the answer. but I am a bit new to Selenium and Java, would it be apt to ask, where do i put this string?before I call the open() or elsewhere?
gagneet
is the server controlled by you? If yes - put this in the code where you serve the text file.
Bozho