简体   繁体   中英

Open a URL with parameters using selenium.open()

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++;

您的cookie servlet应该设置内容类型:

response.setContentType("text/plain");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM