Reputation: 25
I was wondering how to use Selenium.captureNetworkTraffic to capture HTTP requests then parse out a value to pass in a query string.
Upon launching the application under test generates a UniqueID. This information is not shown the URL to the user.
I need to capture the unique ID then pass it to the query string to complete a series of requests. For example I'd need to capture Example123 in the network traffic then parse out the data and include it in other query strings
http://www/UnqiueID=EXAMPLE123&xxx=2&xxx=
I've looked at http://www.eviltester.com/index.php/2010/05/26/a-selenium-capturenetworktraffic-example-in-java/ but this seems focused on size of page, links, etc.
Upvotes: 1
Views: 779
Reputation: 9570
Don't be mislead by David Burns' and Corey Goldberg's specific use of the captureNetworkTraffic
interface - it can probably do just what you need. They're summarizing certain properties of the transactions, but the interface actually returns all the response headers, one of which will probably contain what you're looking for. The actual data returned by the Selenium server looks like this (mostly lifted from the source code):
[
{
statusCode: 200,
method: 'GET',
url: 'http://foo.com/index.html',
bytes: 12422,
start: '2009-03-15T14:23:00.000-0700',
end: '2009-03-15T14:23:00.102-0700',
timeInMillis: 102,
requestHeaders: [
{
name: 'Foo',
value: 'Bar'
},
{
name: 'Name2',
value: 'Value2'
},
...
],
responseHeaders: [
{
name: 'Baz',
value: 'Blah'
},
{
name: 'Name3',
value: 'Value3'
},
...
]
},
{
...
},
...
]
That said, the value you want is probably supplied to the browser in a cookie, which you can retrieve from Selenium much more simply by using the getCookieByName
command.
Upvotes: 1