phpunit-selenium icon indicating copy to clipboard operation
phpunit-selenium copied to clipboard

captureNetworkTraffic option?

Open daluu opened this issue 13 years ago • 3 comments

Just wondering if PHPUnit supports the Selenium captureNetworkTraffic setting that is available for other languages like Java and Python. If not, can we please consider adding as option for the Selenium extension to PHPUnit? It would be useful for additional testing of HTTP responses that come through the browser (like API requests made through AJAX that may have issues that don't show up in the browser UI) as well as perfromance benchmarks of download times of elements on a page.

For reference, I'm talking about this type of code snippet available to Python and Java:


try: sel.start('captureNetworkTraffic=true') except socket.error: print 'ERROR - can not start the selenium-rc driver. is your selenium server running?' sys.exit(1)

sel.open(path) sel.wait_for_page_to_load(60000)

end_loading = datetime.now()

raw_xml = sel.captureNetworkTraffic('xml') // we can then process the captured traffic as we please via text parsing


For an example of how someone used the network capture to do performance profiling, see this Python example:

http://code.google.com/p/selenium-profiler/source/browse/trunk/web_profiler.py

daluu avatar Sep 28 '11 21:09 daluu

If there are no plans to implement this, perhaps offering some advice on how to modify the Selenium extension of PHPUnit for this would be appreciated.

daluu avatar Sep 28 '11 21:09 daluu

I took a brief look at the PHPUnit Selenium files, and think I found 2 places that could be modified for this support, but didn't seem to work for me...maybe I'm missing something...

Under PHPUnit/Extensions/SeleniumTestCase/Driver.php

start() function, add the capture option like this?

$this->sessionId = $this->getString( 'getNewBrowserSession', array($this->browser, $this->browserUrl, 'captureNetworkTraffic=true') );

and under _call() function, add a case for that Selenium RC API command like this?

case 'captureNetworkTraffic':

daluu avatar Sep 28 '11 23:09 daluu

use that call $allTraffic = json_decode($driver->__call("captureNetworkTraffic", array('json')));

ffedoroff avatar May 01 '12 09:05 ffedoroff