Capture network traffic in selenium using python

4,833 views
Skip to first unread message

santosh h s

unread,
Dec 31, 2010, 4:52:17 AM12/31/10
to seleniu...@googlegroups.com
Hello All,

How to capture Capture network traffic in selenium using python, please help me out below is my sample code.



from selenium import selenium
import unittest, time, re

def sel_start():
    global sel
    sel = selenium("localhost", 4444, "iexplore", "http://gmail.com")
    sel.start()
    sel.captureNetworkTraffic(True)
    sel.open("http://gmail.com")
    time.sleep(50)
    print sel.get_cookie()
    print sel.get_all_window_names()
    print sel.get_all_window_ids()
    print sel.get_all_window_titles()
    sel.select_window(sideview_player)
    trafficOutput = sel.captureNetworkTraffic("plain")
    print trafficOutput
def tearDown(sel):
    sel.stop()

sel_start()
tearDown(sel)


with this code it doesn't capture any network trafic.

I need to capture http request sent for particular IP address please help how to ?

--
Regards,
Santosh

farheen khan

unread,
Dec 31, 2010, 4:55:02 AM12/31/10
to seleniu...@googlegroups.com
Hi,
 An example for capturing network traffic in java is here.

http://www.eviltester.com/index.php/2010/05/26/a-selenium-capturenetworktraffic-example-in-java/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.



--

Farheen
http://seleniumready.blogspot.com/



santosh h s

unread,
Dec 31, 2010, 6:09:01 AM12/31/10
to seleniu...@googlegroups.com
this doesn't work with python anyone who can tell me please
Regards,
Santosh

Aniket Deshpande

unread,
Jan 2, 2011, 11:45:20 PM1/2/11
to seleniu...@googlegroups.com
You should start your browser in proxy-injection mode...
Try starting with *piiexplore...


--
- ANIKET
http://www.aniketdeshpande.com


--

santosh h s

unread,
Jan 3, 2011, 9:07:21 AM1/3/11
to seleniu...@googlegroups.com
can i get a sample code as how to achieve this please
--
Regards,
Santosh

Aniket Deshpande

unread,
Jan 4, 2011, 12:00:37 AM1/4/11
to seleniu...@googlegroups.com
sel = selenium("localhost", 4444, "piiexplore", "http://gmail.com")

Luca Pellicoro

unread,
Jan 4, 2011, 3:51:25 AM1/4/11
to seleniu...@googlegroups.com
Santosh:

You might also need to modify the python driver to add network capture.

As described here:
http://stackoverflow.com/questions/3712278/selenium-rc-how-do-you-use-capturenetworktraffic-in-python/3717952#3717952

And the source for this project may help:
http://code.google.com/p/selenium-profiler/

santosh h s

unread,
Jan 4, 2011, 4:12:24 AM1/4/11
to seleniu...@googlegroups.com
HiAll how to capture this network traffic for a particular IP. suppose if i want capture http request for goole.com how to handle this

santosh h s

unread,
Jan 4, 2011, 8:06:21 AM1/4/11
to seleniu...@googlegroups.com
with the below code if i launch any website it shows me as "Connection is untrusted" due to some security certificates, please help me how to handle this.

Aniket Deshpande

unread,
Jan 5, 2011, 12:54:31 AM1/5/11
to seleniu...@googlegroups.com
Try the following:
1) You can try the same test case on firefox (*pifirefox)
2) In IE, add your application URL to the Trusted Sites.

Lemme know what you get...

santosh h s

unread,
Jan 5, 2011, 1:05:49 AM1/5/11
to seleniu...@googlegroups.com
if i add my Url as trusted site it will work.
Please let me know how to capture HTTP request to a particular IP address. please help me

Aniket Deshpande

unread,
Jan 5, 2011, 1:13:53 AM1/5/11
to seleniu...@googlegroups.com
What do you mean "for a particular IP"?
Reply all
Reply to author
Forward
0 new messages