[Selenium JAVA]Response body for GET method

1,135 views
Skip to first unread message

yin...@temasys.com.sg

unread,
Feb 12, 2015, 1:08:18 AM2/12/15
to browserm...@googlegroups.com
Hi,
Followed by the test "testThatInterceptorsCanReadResponseBodies" 

I'd like to store the response body of a GET method in addResponseInterceptor
My code is like: body = response.getEntry().getResponse().getContent().getText();
What's weird is that for the POST request, this line of code works fine but for a GET request it returns null, and the getBodysize() returns 0.

So I'd like to know if I'm wrong about the method I use to get the response body? If i open IE manually to watch the GET method that I want, it works fine I can see its content, however the type of it is "binary/octet-stream" but not the "text". Could this be the reason that I cannot read it in Selenium?
I'm using WIN7 32 IE11.

Thanks in advance.

yin...@temasys.com.sg

unread,
Feb 12, 2015, 5:38:08 AM2/12/15
to browserm...@googlegroups.com
Problem solved, after decoding the text it's ok now

yin...@temasys.com.sg

unread,
Mar 2, 2015, 2:08:48 AM3/2/15
to browserm...@googlegroups.com
Hi again,
I'm using 
byte[] binaryValue = Base64.decodeBase64(res.getEntry().getResponse().getContent().getText());
in an interceptor to get the data(the data is not a string but a binary file). However it's working fine on 32bit WINDOWS7 but it returns null on a 64bit one.
Has anyone encountered the similar problem?
Reply all
Reply to author
Forward
0 new messages